From d717d5bf80a5146b42ed8f0779486632668462f9 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Mon, 11 Sep 2023 23:44:40 -0700 Subject: [PATCH] chore: commit snapshotted test files (#735) --- .../dist/jscomp/test/flow_parser_reg_test.js | 9358 ++++++++--------- .../dist/jscomp/test/ocaml_parsetree_test.js | 176 +- jscomp/test/dist/jscomp/test/ocaml_re_test.js | 90 +- .../dist/jscomp/test/ocaml_typedtree_test.js | 4330 ++++---- jscomp/test/dist/jscomp/test/parser_api.js | 236 +- 5 files changed, 7095 insertions(+), 7095 deletions(-) diff --git a/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js b/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js index 9ddde8708f..47bf5aede5 100644 --- a/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js @@ -3404,403 +3404,409 @@ function token(env, lexbuf) { }; } -function __ocaml_lex_template_tail_rec(_env, lexbuf, ___ocaml_lex_state) { +function type_token(env, lexbuf) { + lexbuf.lex_mem = Caml_array.make(26, -1); + Caml_array.set(lexbuf.lex_mem, 17, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 16, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 15, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 14, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 13, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 12, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 11, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 10, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 9, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 8, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 7, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 6, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 5, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 4, lexbuf.lex_curr_pos); + var ___ocaml_lex_state = 133; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var env = _env; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + var __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : Stdlib__Lexing.new_line(lexbuf); - ___ocaml_lex_state = 393; - continue ; + return type_token(env, lexbuf); case 1 : unicode_fix_cols(lexbuf); - ___ocaml_lex_state = 393; - continue ; + return type_token(env, lexbuf); case 2 : var start = from_lb(env.lex_source, lexbuf); var buf = Stdlib__Buffer.create(127); - var match = line_comment(env, buf, lexbuf); + var match = comment(env, buf, lexbuf); var env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 393; - _env = env$1; - continue ; + return type_token(env$1, lexbuf); case 3 : + var sp = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, Caml_array.get(lexbuf.lex_mem, 0)); + var escape_type = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + var pattern = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + if (env.lex_enable_comment_syntax) { + var env$2; + if (env.lex_in_comment_syntax) { + var loc = from_lb(env.lex_source, lexbuf); + env$2 = unexpected_error(env, loc, pattern); + } else { + env$2 = env; + } + var env$3 = in_comment_syntax(true, env$2); + if (escape_type === ":") { + return [ + env$3, + /* T_COLON */77 + ]; + } else { + return type_token(env$3, lexbuf); + } + } var start$1 = from_lb(env.lex_source, lexbuf); var buf$1 = Stdlib__Buffer.create(127); + Stdlib__Buffer.add_string(buf$1, sp); + Stdlib__Buffer.add_string(buf$1, escape_type); var match$1 = comment(env, buf$1, lexbuf); - var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 393; - _env = env$2; - continue ; + var env$4 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + return type_token(env$4, lexbuf); case 4 : - var start$2 = from_lb(env.lex_source, lexbuf); - var cooked = Stdlib__Buffer.create(127); - var raw = Stdlib__Buffer.create(127); - var literal = Stdlib__Buffer.create(127); - Stdlib__Buffer.add_string(literal, "}"); - var match$2 = template_part(env, start$2, cooked, raw, literal, lexbuf); + if (env.lex_in_comment_syntax) { + var env$5 = in_comment_syntax(false, env); + return type_token(env$5, lexbuf); + } + yyback(1, lexbuf); return [ - match$2[0], - { - TAG: /* T_TEMPLATE_PART */2, - _0: [ - match$2[1], - { - cooked: Stdlib__Buffer.contents(cooked), - raw: Stdlib__Buffer.contents(raw), - literal: Stdlib__Buffer.contents(literal) - }, - match$2[2] - ] - } + env, + /* T_MULT */97 ]; case 5 : - var env$3 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); + var start$2 = from_lb(env.lex_source, lexbuf); + var buf$2 = Stdlib__Buffer.create(127); + var match$2 = line_comment(env, buf$2, lexbuf); + var env$6 = save_comment(match$2[0], start$2, match$2[1], buf$2, true); + return type_token(env$6, lexbuf); + case 6 : + var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var start$3 = from_lb(env.lex_source, lexbuf); + var buf$3 = Stdlib__Buffer.create(127); + var raw = Stdlib__Buffer.create(127); + Stdlib__Buffer.add_char(raw, quote); + var match$3 = string_quote(env, quote, buf$3, raw, false, lexbuf); return [ - env$3, + match$3[0], { - TAG: /* T_TEMPLATE_PART */2, + TAG: /* T_STRING */1, _0: [ - from_lb(env$3.lex_source, lexbuf), - { - cooked: "", - raw: "", - literal: "" - }, - true + btwn(start$3, match$3[1]), + Stdlib__Buffer.contents(buf$3), + Stdlib__Buffer.contents(raw), + match$3[2] ] } ]; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function regexp_class(env, buf, lexbuf) { - var ___ocaml_lex_state = 326; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - return env; - case 1 : - case 2 : - break; - case 3 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c); - return env; - case 4 : - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c$1); - return regexp_class(env, buf, lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - var s = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); - Stdlib__Buffer.add_string(buf, s); - return regexp_class(env, buf, lexbuf); - }; -} - -function regexp_body(env, buf, lexbuf) { - var ___ocaml_lex_state = 314; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - var loc = from_lb(env.lex_source, lexbuf); - var env$1 = lex_error(env, loc, /* UnterminatedRegExp */13); - return [ - env$1, - "" - ]; - case 1 : - var loc$1 = from_lb(env.lex_source, lexbuf); - var env$2 = lex_error(env, loc$1, /* UnterminatedRegExp */13); - return [ - env$2, - "" - ]; - case 2 : - var s = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); - Stdlib__Buffer.add_string(buf, s); - return regexp_body(env, buf, lexbuf); - case 3 : - var flags = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 1 | 0, lexbuf.lex_curr_pos); - return [ - env, - flags - ]; - case 4 : + case 7 : + var neg = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w, mk_num_singleton(/* BINARY */0, num, neg)); + case 8 : + var neg$1 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$1 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - "" - ]; - case 5 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c); - var env$3 = regexp_class(env, buf, lexbuf); - return regexp_body(env$3, buf, lexbuf); - case 6 : - var loc$2 = from_lb(env.lex_source, lexbuf); - var env$4 = lex_error(env, loc$2, /* UnterminatedRegExp */13); - return [ - env$4, - "" + mk_num_singleton(/* BINARY */0, num$1, neg$1) ]; - case 7 : - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c$1); - return regexp_body(env, buf, lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function string_escape(env, buf, lexbuf) { - var ___ocaml_lex_state = 252; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : + case 9 : + var neg$2 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$2 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$1 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$1, mk_num_singleton(/* OCTAL */2, num$2, neg$2)); + case 10 : + var neg$3 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$3 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - false + mk_num_singleton(/* OCTAL */2, num$3, neg$3) ]; - case 1 : - Stdlib__Buffer.add_string(buf, "\\"); + case 11 : + var neg$4 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$4 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$2 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$2, mk_num_singleton(/* LEGACY_OCTAL */1, num$4, neg$4)); + case 12 : + var neg$5 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$5 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - false + mk_num_singleton(/* LEGACY_OCTAL */1, num$5, neg$5) ]; - case 2 : - var a = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var b = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var code = (hexa_to_int(a) << 4) + hexa_to_int(b) | 0; - Stdlib__List.iter((function (param) { - return Stdlib__Buffer.add_char(buf, param); - }), utf16to8(code)); + case 13 : + var neg$6 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$6 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$3 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + var match$4; + try { + match$4 = [ + env, + mk_num_singleton(/* NORMAL */3, num$6, neg$6) + ]; + } + catch (exn){ + if (Stdlib__Sys.win32) { + var loc$1 = from_lb(env.lex_source, lexbuf); + var env$7 = lex_error(env, loc$1, /* WindowsFloatOfString */59); + match$4 = [ + env$7, + { + TAG: /* T_NUMBER_SINGLETON_TYPE */5, + _0: /* NORMAL */3, + _1: 789.0 + } + ]; + } else { + throw exn; + } + } + return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); + case 14 : + var neg$7 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$7 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + try { + return [ + env, + mk_num_singleton(/* NORMAL */3, num$7, neg$7) + ]; + } + catch (exn$1){ + if (Stdlib__Sys.win32) { + var loc$2 = from_lb(env.lex_source, lexbuf); + var env$8 = lex_error(env, loc$2, /* WindowsFloatOfString */59); + return [ + env$8, + { + TAG: /* T_NUMBER_SINGLETON_TYPE */5, + _0: /* NORMAL */3, + _1: 789.0 + } + ]; + } + throw exn$1; + } + case 15 : + var neg$8 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$8 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$4 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$4, mk_num_singleton(/* NORMAL */3, num$8, neg$8)); + case 16 : + var neg$9 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$9 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - false + mk_num_singleton(/* NORMAL */3, num$9, neg$9) ]; - case 3 : - var a$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var b$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var code$1 = ((oct_to_int(a$1) << 6) + (oct_to_int(b$1) << 3) | 0) + oct_to_int(c) | 0; - if (code$1 < 256) { - Stdlib__List.iter((function (param) { - return Stdlib__Buffer.add_char(buf, param); - }), utf16to8(code$1)); - } else { - var code$2 = (oct_to_int(a$1) << 3) + oct_to_int(b$1) | 0; - Stdlib__List.iter((function (param) { - return Stdlib__Buffer.add_char(buf, param); - }), utf16to8(code$2)); - Stdlib__Buffer.add_char(buf, c); - } + case 17 : + var neg$10 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$10 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$5 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$5, mk_num_singleton(/* NORMAL */3, num$10, neg$10)); + case 18 : + var neg$11 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), Caml_array.get(lexbuf.lex_mem, 0)); + var num$11 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 3), Caml_array.get(lexbuf.lex_mem, 2)); return [ env, - true + mk_num_singleton(/* NORMAL */3, num$11, neg$11) ]; - case 4 : - var a$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var b$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var code$3 = (oct_to_int(a$2) << 3) + oct_to_int(b$2) | 0; - Stdlib__List.iter((function (param) { - return Stdlib__Buffer.add_char(buf, param); - }), utf16to8(code$3)); + case 19 : + var word = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + unicode_fix_cols(lexbuf); + try { + return [ + env, + Stdlib__Hashtbl.find(type_keywords, word) + ]; + } + catch (raw_exn){ + var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn$2.RE_EXN_ID === Stdlib.Not_found) { + return [ + env, + /* T_IDENTIFIER */0 + ]; + } + throw exn$2; + } + case 22 : return [ env, - true + /* T_LCURLY */1 ]; - case 5 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(0)); + case 23 : return [ env, - false + /* T_RCURLY */2 ]; - case 6 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(8)); + case 24 : return [ env, - false + /* T_LPAREN */3 ]; - case 7 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(12)); + case 25 : return [ env, - false + /* T_RPAREN */4 ]; - case 8 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(10)); + case 26 : return [ env, - false + /* T_ELLIPSIS */11 ]; - case 9 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(13)); + case 27 : return [ env, - false + /* T_PERIOD */9 ]; - case 10 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(9)); + case 28 : return [ env, - false + /* T_SEMICOLON */7 ]; - case 11 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(11)); + case 29 : return [ env, - false + /* T_COMMA */8 ]; - case 12 : - var a$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var code$4 = oct_to_int(a$3); - Stdlib__List.iter((function (param) { - return Stdlib__Buffer.add_char(buf, param); - }), utf16to8(code$4)); + case 20 : + case 32 : return [ env, - true + /* T_LBRACKET */5 ]; - case 13 : - var a$4 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var b$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 3 | 0); - var d = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 4 | 0); - var code$5 = (((hexa_to_int(a$4) << 12) + (hexa_to_int(b$3) << 8) | 0) + (hexa_to_int(c$1) << 4) | 0) + hexa_to_int(d) | 0; - Stdlib__List.iter((function (param) { - return Stdlib__Buffer.add_char(buf, param); - }), utf16to8(code$5)); + case 21 : + case 33 : return [ env, - false + /* T_RBRACKET */6 ]; - case 14 : - var hex_code = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, lexbuf.lex_curr_pos - 1 | 0); - var code$6 = Caml_format.caml_int_of_string("0x" + hex_code); - var env$1 = code$6 > 1114111 ? lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }) : env; - Stdlib__List.iter((function (param) { - return Stdlib__Buffer.add_char(buf, param); - }), utf16to8(code$6)); + case 34 : return [ - env$1, - false + env, + /* T_LESS_THAN */89 ]; - case 15 : - var c$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var env$2 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); - Stdlib__Buffer.add_char(buf, c$2); + case 35 : return [ - env$2, - false + env, + /* T_GREATER_THAN */90 ]; - case 16 : - Stdlib__Lexing.new_line(lexbuf); + case 31 : + case 37 : return [ env, - false + /* T_PLING */76 ]; - case 17 : - var c$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c$3); + case 38 : return [ env, - false + /* T_MULT */97 ]; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function template_part(env, start, cooked, raw, literal, lexbuf) { - var ___ocaml_lex_state = 416; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); + case 30 : + case 39 : return [ - env$1, - btwn(start, from_lb(env$1.lex_source, lexbuf)), - true + env, + /* T_COLON */77 ]; - case 1 : - Stdlib__Buffer.add_char(literal, /* '`' */96); + case 40 : return [ env, - btwn(start, from_lb(env.lex_source, lexbuf)), - true + /* T_BIT_OR */80 ]; - case 2 : - Stdlib__Buffer.add_string(literal, "${"); + case 41 : return [ env, - btwn(start, from_lb(env.lex_source, lexbuf)), - false + /* T_BIT_AND */82 ]; - case 3 : - Stdlib__Buffer.add_char(raw, /* '\\' */92); - Stdlib__Buffer.add_char(literal, /* '\\' */92); - var match = string_escape(env, cooked, lexbuf); - var str = Stdlib__Lexing.lexeme(lexbuf); - Stdlib__Buffer.add_string(raw, str); - Stdlib__Buffer.add_string(literal, str); - return template_part(match[0], start, cooked, raw, literal, lexbuf); - case 4 : - var lf = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); - Stdlib__Buffer.add_string(raw, lf); - Stdlib__Buffer.add_string(literal, lf); - Stdlib__Buffer.add_string(cooked, "\n"); - Stdlib__Lexing.new_line(lexbuf); - return template_part(env, start, cooked, raw, literal, lexbuf); - case 5 : - var lf$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(raw, lf$1); - Stdlib__Buffer.add_char(literal, lf$1); - Stdlib__Buffer.add_char(cooked, /* '\n' */10); + case 42 : + return [ + env, + /* T_TYPEOF */44 + ]; + case 43 : + return [ + env, + /* T_ARROW */10 + ]; + case 36 : + case 44 : + return [ + env, + /* T_ASSIGN */75 + ]; + case 45 : + return [ + env, + /* T_PLUS */94 + ]; + case 46 : + return [ + env, + /* T_MINUS */95 + ]; + case 47 : + var env$9; + if (env.lex_in_comment_syntax) { + var loc$3 = from_lb(env.lex_source, lexbuf); + env$9 = lex_error(env, loc$3, /* UnexpectedEOS */4); + } else { + env$9 = env; + } + return [ + env$9, + /* T_EOF */105 + ]; + case 48 : + return [ + env, + /* T_ERROR */104 + ]; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function line_comment(env, buf, lexbuf) { + var ___ocaml_lex_state = 287; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; + case 1 : + var match = from_lb(env.lex_source, lexbuf); + var match$1 = match._end; Stdlib__Lexing.new_line(lexbuf); - return template_part(env, start, cooked, raw, literal, lexbuf); - case 6 : + var _end_line = match$1.line; + var _end_column = match$1.column - 1 | 0; + var _end_offset = match$1.offset - 1 | 0; + var _end = { + line: _end_line, + column: _end_column, + offset: _end_offset + }; + return [ + env, + { + source: match.source, + start: match.start, + _end: _end + } + ]; + case 2 : var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(raw, c); - Stdlib__Buffer.add_char(literal, c); - Stdlib__Buffer.add_char(cooked, c); - return template_part(env, start, cooked, raw, literal, lexbuf); + Stdlib__Buffer.add_char(buf, c); + return line_comment(env, buf, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -3861,49 +3867,6 @@ function string_quote(env, q, buf, raw, octal, lexbuf) { }; } -function line_comment(env, buf, lexbuf) { - var ___ocaml_lex_state = 287; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; - case 1 : - var match = from_lb(env.lex_source, lexbuf); - var match$1 = match._end; - Stdlib__Lexing.new_line(lexbuf); - var _end_line = match$1.line; - var _end_column = match$1.column - 1 | 0; - var _end_offset = match$1.offset - 1 | 0; - var _end = { - line: _end_line, - column: _end_column, - offset: _end_offset - }; - return [ - env, - { - source: match.source, - start: match.start, - _end: _end - } - ]; - case 2 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c); - return line_comment(env, buf, lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - function comment(env, buf, lexbuf) { var ___ocaml_lex_state = 279; while(true) { @@ -3952,495 +3915,186 @@ function comment(env, buf, lexbuf) { }; } -function type_token(env, lexbuf) { - lexbuf.lex_mem = Caml_array.make(26, -1); - Caml_array.set(lexbuf.lex_mem, 17, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 16, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 15, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 14, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 13, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 12, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 11, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 10, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 9, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 8, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 7, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 6, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 5, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 4, lexbuf.lex_curr_pos); - var ___ocaml_lex_state = 133; +function regexp_body(env, buf, lexbuf) { + var ___ocaml_lex_state = 314; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - Stdlib__Lexing.new_line(lexbuf); - return type_token(env, lexbuf); + var loc = from_lb(env.lex_source, lexbuf); + var env$1 = lex_error(env, loc, /* UnterminatedRegExp */13); + return [ + env$1, + "" + ]; case 1 : - unicode_fix_cols(lexbuf); - return type_token(env, lexbuf); + var loc$1 = from_lb(env.lex_source, lexbuf); + var env$2 = lex_error(env, loc$1, /* UnterminatedRegExp */13); + return [ + env$2, + "" + ]; case 2 : - var start = from_lb(env.lex_source, lexbuf); - var buf = Stdlib__Buffer.create(127); - var match = comment(env, buf, lexbuf); - var env$1 = save_comment(match[0], start, match[1], buf, true); - return type_token(env$1, lexbuf); + var s = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); + Stdlib__Buffer.add_string(buf, s); + return regexp_body(env, buf, lexbuf); case 3 : - var sp = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, Caml_array.get(lexbuf.lex_mem, 0)); - var escape_type = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - var pattern = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - if (env.lex_enable_comment_syntax) { - var env$2; - if (env.lex_in_comment_syntax) { - var loc = from_lb(env.lex_source, lexbuf); - env$2 = unexpected_error(env, loc, pattern); - } else { - env$2 = env; - } - var env$3 = in_comment_syntax(true, env$2); - if (escape_type === ":") { - return [ - env$3, - /* T_COLON */77 - ]; - } else { - return type_token(env$3, lexbuf); - } - } - var start$1 = from_lb(env.lex_source, lexbuf); - var buf$1 = Stdlib__Buffer.create(127); - Stdlib__Buffer.add_string(buf$1, sp); - Stdlib__Buffer.add_string(buf$1, escape_type); - var match$1 = comment(env, buf$1, lexbuf); - var env$4 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - return type_token(env$4, lexbuf); + var flags = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 1 | 0, lexbuf.lex_curr_pos); + return [ + env, + flags + ]; case 4 : - if (env.lex_in_comment_syntax) { - var env$5 = in_comment_syntax(false, env); - return type_token(env$5, lexbuf); - } - yyback(1, lexbuf); return [ env, - /* T_MULT */97 + "" ]; case 5 : - var start$2 = from_lb(env.lex_source, lexbuf); - var buf$2 = Stdlib__Buffer.create(127); - var match$2 = line_comment(env, buf$2, lexbuf); - var env$6 = save_comment(match$2[0], start$2, match$2[1], buf$2, true); - return type_token(env$6, lexbuf); + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c); + var env$3 = regexp_class(env, buf, lexbuf); + return regexp_body(env$3, buf, lexbuf); case 6 : - var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var start$3 = from_lb(env.lex_source, lexbuf); - var buf$3 = Stdlib__Buffer.create(127); - var raw = Stdlib__Buffer.create(127); - Stdlib__Buffer.add_char(raw, quote); - var match$3 = string_quote(env, quote, buf$3, raw, false, lexbuf); + var loc$2 = from_lb(env.lex_source, lexbuf); + var env$4 = lex_error(env, loc$2, /* UnterminatedRegExp */13); return [ - match$3[0], - { - TAG: /* T_STRING */1, - _0: [ - btwn(start$3, match$3[1]), - Stdlib__Buffer.contents(buf$3), - Stdlib__Buffer.contents(raw), - match$3[2] - ] - } + env$4, + "" ]; case 7 : - var neg = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w, mk_num_singleton(/* BINARY */0, num, neg)); - case 8 : - var neg$1 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$1 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c$1); + return regexp_body(env, buf, lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function __ocaml_lex_regexp_rec(_env, lexbuf, ___ocaml_lex_state) { + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var env = _env; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : return [ env, - mk_num_singleton(/* BINARY */0, num$1, neg$1) + /* T_EOF */105 ]; - case 9 : - var neg$2 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$2 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$1 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$1, mk_num_singleton(/* OCTAL */2, num$2, neg$2)); - case 10 : - var neg$3 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$3 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + case 1 : + Stdlib__Lexing.new_line(lexbuf); + ___ocaml_lex_state = 291; + continue ; + case 2 : + unicode_fix_cols(lexbuf); + ___ocaml_lex_state = 291; + continue ; + case 3 : + var start = from_lb(env.lex_source, lexbuf); + var buf = Stdlib__Buffer.create(127); + var match = line_comment(env, buf, lexbuf); + var env$1 = save_comment(match[0], start, match[1], buf, true); + ___ocaml_lex_state = 291; + _env = env$1; + continue ; + case 4 : + var start$1 = from_lb(env.lex_source, lexbuf); + var buf$1 = Stdlib__Buffer.create(127); + var match$1 = comment(env, buf$1, lexbuf); + var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + ___ocaml_lex_state = 291; + _env = env$2; + continue ; + case 5 : + var start$2 = from_lb(env.lex_source, lexbuf); + var buf$2 = Stdlib__Buffer.create(127); + var match$2 = regexp_body(env, buf$2, lexbuf); + var env$3 = match$2[0]; + var end_ = from_lb(env$3.lex_source, lexbuf); + var loc = btwn(start$2, end_); return [ - env, - mk_num_singleton(/* OCTAL */2, num$3, neg$3) + env$3, + { + TAG: /* T_REGEXP */3, + _0: [ + loc, + Stdlib__Buffer.contents(buf$2), + match$2[1] + ] + } ]; - case 11 : - var neg$4 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$4 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$2 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$2, mk_num_singleton(/* LEGACY_OCTAL */1, num$4, neg$4)); - case 12 : - var neg$5 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$5 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + case 6 : + var env$4 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }); return [ - env, - mk_num_singleton(/* LEGACY_OCTAL */1, num$5, neg$5) + env$4, + /* T_ERROR */104 ]; - case 13 : - var neg$6 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$6 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$3 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - var match$4; - try { - match$4 = [ - env, - mk_num_singleton(/* NORMAL */3, num$6, neg$6) - ]; - } - catch (exn){ - if (Stdlib__Sys.win32) { - var loc$1 = from_lb(env.lex_source, lexbuf); - var env$7 = lex_error(env, loc$1, /* WindowsFloatOfString */59); - match$4 = [ - env$7, - { - TAG: /* T_NUMBER_SINGLETON_TYPE */5, - _0: /* NORMAL */3, - _1: 789.0 + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function jsx_text(env, mode, buf, raw, lexbuf) { + var ___ocaml_lex_state = 371; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + switch (mode) { + case /* JSX_SINGLE_QUOTED_TEXT */0 : + if (c === 39) { + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; } - ]; - } else { - throw exn; - } - } - return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); - case 14 : - var neg$7 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$7 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - try { - return [ - env, - mk_num_singleton(/* NORMAL */3, num$7, neg$7) - ]; - } - catch (exn$1){ - if (Stdlib__Sys.win32) { - var loc$2 = from_lb(env.lex_source, lexbuf); - var env$8 = lex_error(env, loc$2, /* WindowsFloatOfString */59); - return [ - env$8, - { - TAG: /* T_NUMBER_SINGLETON_TYPE */5, - _0: /* NORMAL */3, - _1: 789.0 - } - ]; - } - throw exn$1; - } - case 15 : - var neg$8 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$8 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$4 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$4, mk_num_singleton(/* NORMAL */3, num$8, neg$8)); - case 16 : - var neg$9 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$9 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - return [ - env, - mk_num_singleton(/* NORMAL */3, num$9, neg$9) - ]; - case 17 : - var neg$10 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$10 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$5 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$5, mk_num_singleton(/* NORMAL */3, num$10, neg$10)); - case 18 : - var neg$11 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), Caml_array.get(lexbuf.lex_mem, 0)); - var num$11 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 3), Caml_array.get(lexbuf.lex_mem, 2)); - return [ - env, - mk_num_singleton(/* NORMAL */3, num$11, neg$11) - ]; - case 19 : - var word = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - unicode_fix_cols(lexbuf); - try { - return [ - env, - Stdlib__Hashtbl.find(type_keywords, word) - ]; - } - catch (raw_exn){ - var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn$2.RE_EXN_ID === Stdlib.Not_found) { - return [ - env, - /* T_IDENTIFIER */0 - ]; - } - throw exn$2; + break; + case /* JSX_DOUBLE_QUOTED_TEXT */1 : + if (c === 34) { + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; + } + break; + case /* JSX_CHILD_TEXT */2 : + var exit = 0; + if (!(c !== 60 && c !== 123)) { + exit = 2; + } + if (exit === 2) { + back(lexbuf); + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; + } + break; + } - case 22 : + Stdlib__Buffer.add_char(raw, c); + Stdlib__Buffer.add_char(buf, c); + return jsx_text(env, mode, buf, raw, lexbuf); + case 1 : + var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }); return [ - env, - /* T_LCURLY */1 - ]; - case 23 : - return [ - env, - /* T_RCURLY */2 - ]; - case 24 : - return [ - env, - /* T_LPAREN */3 - ]; - case 25 : - return [ - env, - /* T_RPAREN */4 - ]; - case 26 : - return [ - env, - /* T_ELLIPSIS */11 - ]; - case 27 : - return [ - env, - /* T_PERIOD */9 - ]; - case 28 : - return [ - env, - /* T_SEMICOLON */7 - ]; - case 29 : - return [ - env, - /* T_COMMA */8 - ]; - case 20 : - case 32 : - return [ - env, - /* T_LBRACKET */5 - ]; - case 21 : - case 33 : - return [ - env, - /* T_RBRACKET */6 - ]; - case 34 : - return [ - env, - /* T_LESS_THAN */89 - ]; - case 35 : - return [ - env, - /* T_GREATER_THAN */90 - ]; - case 31 : - case 37 : - return [ - env, - /* T_PLING */76 - ]; - case 38 : - return [ - env, - /* T_MULT */97 - ]; - case 30 : - case 39 : - return [ - env, - /* T_COLON */77 - ]; - case 40 : - return [ - env, - /* T_BIT_OR */80 - ]; - case 41 : - return [ - env, - /* T_BIT_AND */82 - ]; - case 42 : - return [ - env, - /* T_TYPEOF */44 - ]; - case 43 : - return [ - env, - /* T_ARROW */10 - ]; - case 36 : - case 44 : - return [ - env, - /* T_ASSIGN */75 - ]; - case 45 : - return [ - env, - /* T_PLUS */94 - ]; - case 46 : - return [ - env, - /* T_MINUS */95 - ]; - case 47 : - var env$9; - if (env.lex_in_comment_syntax) { - var loc$3 = from_lb(env.lex_source, lexbuf); - env$9 = lex_error(env, loc$3, /* UnexpectedEOS */4); - } else { - env$9 = env; - } - return [ - env$9, - /* T_EOF */105 - ]; - case 48 : - return [ - env, - /* T_ERROR */104 - ]; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function __ocaml_lex_regexp_rec(_env, lexbuf, ___ocaml_lex_state) { - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var env = _env; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - return [ - env, - /* T_EOF */105 - ]; - case 1 : - Stdlib__Lexing.new_line(lexbuf); - ___ocaml_lex_state = 291; - continue ; - case 2 : - unicode_fix_cols(lexbuf); - ___ocaml_lex_state = 291; - continue ; - case 3 : - var start = from_lb(env.lex_source, lexbuf); - var buf = Stdlib__Buffer.create(127); - var match = line_comment(env, buf, lexbuf); - var env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 291; - _env = env$1; - continue ; - case 4 : - var start$1 = from_lb(env.lex_source, lexbuf); - var buf$1 = Stdlib__Buffer.create(127); - var match$1 = comment(env, buf$1, lexbuf); - var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 291; - _env = env$2; - continue ; - case 5 : - var start$2 = from_lb(env.lex_source, lexbuf); - var buf$2 = Stdlib__Buffer.create(127); - var match$2 = regexp_body(env, buf$2, lexbuf); - var env$3 = match$2[0]; - var end_ = from_lb(env$3.lex_source, lexbuf); - var loc = btwn(start$2, end_); - return [ - env$3, - { - TAG: /* T_REGEXP */3, - _0: [ - loc, - Stdlib__Buffer.contents(buf$2), - match$2[1] - ] - } - ]; - case 6 : - var env$4 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); - return [ - env$4, - /* T_ERROR */104 - ]; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function jsx_text(env, mode, buf, raw, lexbuf) { - var ___ocaml_lex_state = 371; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - switch (mode) { - case /* JSX_SINGLE_QUOTED_TEXT */0 : - if (c === 39) { - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; - } - break; - case /* JSX_DOUBLE_QUOTED_TEXT */1 : - if (c === 34) { - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; - } - break; - case /* JSX_CHILD_TEXT */2 : - var exit = 0; - if (!(c !== 60 && c !== 123)) { - exit = 2; - } - if (exit === 2) { - back(lexbuf); - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; - } - break; - - } - Stdlib__Buffer.add_char(raw, c); - Stdlib__Buffer.add_char(buf, c); - return jsx_text(env, mode, buf, raw, lexbuf); - case 1 : - var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); - return [ - env$1, - from_lb(env$1.lex_source, lexbuf) + env$1, + from_lb(env$1.lex_source, lexbuf) ]; case 2 : var lt = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); @@ -5255,108 +4909,167 @@ function jsx_text(env, mode, buf, raw, lexbuf) { }; } -function __ocaml_lex_jsx_tag_rec(_env, lexbuf, ___ocaml_lex_state) { +function string_escape(env, buf, lexbuf) { + var ___ocaml_lex_state = 252; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var env = _env; var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : return [ env, - /* T_EOF */105 + false ]; case 1 : - Stdlib__Lexing.new_line(lexbuf); - ___ocaml_lex_state = 333; - continue ; + Stdlib__Buffer.add_string(buf, "\\"); + return [ + env, + false + ]; case 2 : - unicode_fix_cols(lexbuf); - ___ocaml_lex_state = 333; - continue ; + var a = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var b = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var code = (hexa_to_int(a) << 4) + hexa_to_int(b) | 0; + Stdlib__List.iter((function (param) { + return Stdlib__Buffer.add_char(buf, param); + }), utf16to8(code)); + return [ + env, + false + ]; case 3 : - var start = from_lb(env.lex_source, lexbuf); - var buf = Stdlib__Buffer.create(127); - var match = line_comment(env, buf, lexbuf); - var env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 333; - _env = env$1; - continue ; + var a$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var b$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var code$1 = ((oct_to_int(a$1) << 6) + (oct_to_int(b$1) << 3) | 0) + oct_to_int(c) | 0; + if (code$1 < 256) { + Stdlib__List.iter((function (param) { + return Stdlib__Buffer.add_char(buf, param); + }), utf16to8(code$1)); + } else { + var code$2 = (oct_to_int(a$1) << 3) + oct_to_int(b$1) | 0; + Stdlib__List.iter((function (param) { + return Stdlib__Buffer.add_char(buf, param); + }), utf16to8(code$2)); + Stdlib__Buffer.add_char(buf, c); + } + return [ + env, + true + ]; case 4 : - var start$1 = from_lb(env.lex_source, lexbuf); - var buf$1 = Stdlib__Buffer.create(127); - var match$1 = comment(env, buf$1, lexbuf); - var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 333; - _env = env$2; - continue ; + var a$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var b$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var code$3 = (oct_to_int(a$2) << 3) + oct_to_int(b$2) | 0; + Stdlib__List.iter((function (param) { + return Stdlib__Buffer.add_char(buf, param); + }), utf16to8(code$3)); + return [ + env, + true + ]; case 5 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(0)); return [ env, - /* T_LESS_THAN */89 + false ]; case 6 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(8)); return [ env, - /* T_DIV */96 + false ]; case 7 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(12)); return [ env, - /* T_GREATER_THAN */90 + false ]; case 8 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(10)); return [ env, - /* T_LCURLY */1 + false ]; case 9 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(13)); return [ env, - /* T_COLON */77 + false ]; case 10 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(9)); return [ env, - /* T_PERIOD */9 + false ]; case 11 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(11)); return [ env, - /* T_ASSIGN */75 + false ]; case 12 : - unicode_fix_cols(lexbuf); + var a$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var code$4 = oct_to_int(a$3); + Stdlib__List.iter((function (param) { + return Stdlib__Buffer.add_char(buf, param); + }), utf16to8(code$4)); return [ env, - /* T_JSX_IDENTIFIER */106 + true ]; case 13 : - var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var start$2 = from_lb(env.lex_source, lexbuf); - var buf$2 = Stdlib__Buffer.create(127); - var raw = Stdlib__Buffer.create(127); - Stdlib__Buffer.add_char(raw, quote); - var mode = quote === /* '\'' */39 ? /* JSX_SINGLE_QUOTED_TEXT */0 : /* JSX_DOUBLE_QUOTED_TEXT */1; - var match$2 = jsx_text(env, mode, buf$2, raw, lexbuf); - Stdlib__Buffer.add_char(raw, quote); - var value = Stdlib__Buffer.contents(buf$2); - var raw$1 = Stdlib__Buffer.contents(raw); + var a$4 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var b$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 3 | 0); + var d = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 4 | 0); + var code$5 = (((hexa_to_int(a$4) << 12) + (hexa_to_int(b$3) << 8) | 0) + (hexa_to_int(c$1) << 4) | 0) + hexa_to_int(d) | 0; + Stdlib__List.iter((function (param) { + return Stdlib__Buffer.add_char(buf, param); + }), utf16to8(code$5)); return [ - match$2[0], - { - TAG: /* T_JSX_TEXT */4, - _0: [ - btwn(start$2, match$2[1]), - value, - raw$1 - ] - } + env, + false ]; case 14 : + var hex_code = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, lexbuf.lex_curr_pos - 1 | 0); + var code$6 = Caml_format.caml_int_of_string("0x" + hex_code); + var env$1 = code$6 > 1114111 ? lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }) : env; + Stdlib__List.iter((function (param) { + return Stdlib__Buffer.add_char(buf, param); + }), utf16to8(code$6)); + return [ + env$1, + false + ]; + case 15 : + var c$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var env$2 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }); + Stdlib__Buffer.add_char(buf, c$2); + return [ + env$2, + false + ]; + case 16 : + Stdlib__Lexing.new_line(lexbuf); return [ env, - /* T_ERROR */104 + false + ]; + case 17 : + var c$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c$3); + return [ + env, + false ]; default: Curry._1(lexbuf.refill_buff, lexbuf); @@ -5366,64 +5079,64 @@ function __ocaml_lex_jsx_tag_rec(_env, lexbuf, ___ocaml_lex_state) { }; } -function jsx_child(env, start, buf, raw, lexbuf) { - var ___ocaml_lex_state = 364; +function template_part(env, start, cooked, raw, literal, lexbuf) { + var ___ocaml_lex_state = 416; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - var lt = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - Stdlib__Buffer.add_string(raw, lt); - Stdlib__Buffer.add_string(buf, lt); - Stdlib__Lexing.new_line(lexbuf); - var match = jsx_text(env, /* JSX_CHILD_TEXT */2, buf, raw, lexbuf); - var value = Stdlib__Buffer.contents(buf); - var raw$1 = Stdlib__Buffer.contents(raw); + var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }); return [ - match[0], - { - TAG: /* T_JSX_TEXT */4, - _0: [ - btwn(start, match[1]), - value, - raw$1 - ] - } + env$1, + btwn(start, from_lb(env$1.lex_source, lexbuf)), + true ]; case 1 : + Stdlib__Buffer.add_char(literal, /* '`' */96); return [ env, - /* T_EOF */105 + btwn(start, from_lb(env.lex_source, lexbuf)), + true ]; case 2 : + Stdlib__Buffer.add_string(literal, "${"); return [ env, - /* T_LESS_THAN */89 + btwn(start, from_lb(env.lex_source, lexbuf)), + false ]; case 3 : - return [ - env, - /* T_LCURLY */1 - ]; + Stdlib__Buffer.add_char(raw, /* '\\' */92); + Stdlib__Buffer.add_char(literal, /* '\\' */92); + var match = string_escape(env, cooked, lexbuf); + var str = Stdlib__Lexing.lexeme(lexbuf); + Stdlib__Buffer.add_string(raw, str); + Stdlib__Buffer.add_string(literal, str); + return template_part(match[0], start, cooked, raw, literal, lexbuf); case 4 : + var lf = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); + Stdlib__Buffer.add_string(raw, lf); + Stdlib__Buffer.add_string(literal, lf); + Stdlib__Buffer.add_string(cooked, "\n"); + Stdlib__Lexing.new_line(lexbuf); + return template_part(env, start, cooked, raw, literal, lexbuf); + case 5 : + var lf$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(raw, lf$1); + Stdlib__Buffer.add_char(literal, lf$1); + Stdlib__Buffer.add_char(cooked, /* '\n' */10); + Stdlib__Lexing.new_line(lexbuf); + return template_part(env, start, cooked, raw, literal, lexbuf); + case 6 : var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); Stdlib__Buffer.add_char(raw, c); - Stdlib__Buffer.add_char(buf, c); - var match$1 = jsx_text(env, /* JSX_CHILD_TEXT */2, buf, raw, lexbuf); - var value$1 = Stdlib__Buffer.contents(buf); - var raw$2 = Stdlib__Buffer.contents(raw); - return [ - match$1[0], - { - TAG: /* T_JSX_TEXT */4, - _0: [ - btwn(start, match$1[1]), - value$1, - raw$2 - ] - } - ]; + Stdlib__Buffer.add_char(literal, c); + Stdlib__Buffer.add_char(cooked, c); + return template_part(env, start, cooked, raw, literal, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -5432,502 +5145,789 @@ function jsx_child(env, start, buf, raw, lexbuf) { }; } -function regexp(env) { - return get_result_and_clear_state(__ocaml_lex_regexp_rec(env, env.lex_lb, 291)); -} - -function jsx_child$1(env) { - var start = from_curr_lb(env.lex_source, env.lex_lb); - var buf = Stdlib__Buffer.create(127); - var raw = Stdlib__Buffer.create(127); - var match = jsx_child(env, start, buf, raw, env.lex_lb); - return get_result_and_clear_state([ - match[0], - match[1] - ]); -} - -function jsx_tag(env) { - return get_result_and_clear_state(__ocaml_lex_jsx_tag_rec(env, env.lex_lb, 333)); -} - -function template_tail(env) { - return get_result_and_clear_state(__ocaml_lex_template_tail_rec(env, env.lex_lb, 393)); -} - -function type_token$1(env) { - return get_result_and_clear_state(type_token(env, env.lex_lb)); -} - -function token$1(env) { - return get_result_and_clear_state(token(env, env.lex_lb)); -} - -var funarg = { - compare: Stdlib__String.compare -}; - -function height(param) { - if (param) { - return param.h; - } else { - return 0; - } -} - -function create(l, v, r) { - var hl = l ? l.h : 0; - var hr = r ? r.h : 0; - return /* Node */{ - l: l, - v: v, - r: r, - h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; -} - -function bal(l, v, r) { - var hl = l ? l.h : 0; - var hr = r ? r.h : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l.r; - var lv = l.v; - var ll = l.l; - if (height(ll) >= height(lr)) { - return create(ll, lv, create(lr, v, r)); - } - if (lr) { - return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); - } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; - } - if (hr <= (hl + 2 | 0)) { - return /* Node */{ - l: l, - v: v, - r: r, - h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (r) { - var rr = r.r; - var rv = r.v; - var rl = r.l; - if (height(rr) >= height(rl)) { - return create(create(l, v, rl), rv, rr); - } - if (rl) { - return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); - } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; -} - -function add(x, t) { - if (!t) { - return /* Node */{ - l: /* Empty */0, - v: x, - r: /* Empty */0, - h: 1 - }; - } - var r = t.r; - var v = t.v; - var l = t.l; - var c = Curry._2(funarg.compare, x, v); - if (c === 0) { - return t; - } - if (c < 0) { - var ll = add(x, l); - if (l === ll) { - return t; - } else { - return bal(ll, v, r); - } - } - var rr = add(x, r); - if (r === rr) { - return t; - } else { - return bal(l, v, rr); - } -} - -function mem(x, _param) { +function __ocaml_lex_template_tail_rec(_env, lexbuf, ___ocaml_lex_state) { while(true) { - var param = _param; - if (!param) { - return false; - } - var c = Curry._2(funarg.compare, x, param.v); - if (c === 0) { - return true; + var __ocaml_lex_state = ___ocaml_lex_state; + var env = _env; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + Stdlib__Lexing.new_line(lexbuf); + ___ocaml_lex_state = 393; + continue ; + case 1 : + unicode_fix_cols(lexbuf); + ___ocaml_lex_state = 393; + continue ; + case 2 : + var start = from_lb(env.lex_source, lexbuf); + var buf = Stdlib__Buffer.create(127); + var match = line_comment(env, buf, lexbuf); + var env$1 = save_comment(match[0], start, match[1], buf, true); + ___ocaml_lex_state = 393; + _env = env$1; + continue ; + case 3 : + var start$1 = from_lb(env.lex_source, lexbuf); + var buf$1 = Stdlib__Buffer.create(127); + var match$1 = comment(env, buf$1, lexbuf); + var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + ___ocaml_lex_state = 393; + _env = env$2; + continue ; + case 4 : + var start$2 = from_lb(env.lex_source, lexbuf); + var cooked = Stdlib__Buffer.create(127); + var raw = Stdlib__Buffer.create(127); + var literal = Stdlib__Buffer.create(127); + Stdlib__Buffer.add_string(literal, "}"); + var match$2 = template_part(env, start$2, cooked, raw, literal, lexbuf); + return [ + match$2[0], + { + TAG: /* T_TEMPLATE_PART */2, + _0: [ + match$2[1], + { + cooked: Stdlib__Buffer.contents(cooked), + raw: Stdlib__Buffer.contents(raw), + literal: Stdlib__Buffer.contents(literal) + }, + match$2[2] + ] + } + ]; + case 5 : + var env$3 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }); + return [ + env$3, + { + TAG: /* T_TEMPLATE_PART */2, + _0: [ + from_lb(env$3.lex_source, lexbuf), + { + cooked: "", + raw: "", + literal: "" + }, + true + ] + } + ]; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; } - _param = c < 0 ? param.l : param.r; - continue ; - }; -} - -function create$1(lex_env, mode) { - var lexbuf = lex_env.lex_lb; - var lexbuf$1 = { - refill_buff: lexbuf.refill_buff, - lex_buffer: lexbuf.lex_buffer, - lex_buffer_len: lexbuf.lex_buffer_len, - lex_abs_pos: lexbuf.lex_abs_pos, - lex_start_pos: lexbuf.lex_start_pos, - lex_curr_pos: lexbuf.lex_curr_pos, - lex_last_pos: lexbuf.lex_last_pos, - lex_last_action: lexbuf.lex_last_action, - lex_eof_reached: lexbuf.lex_eof_reached, - lex_mem: lexbuf.lex_mem, - lex_start_p: lexbuf.lex_start_p, - lex_curr_p: lexbuf.lex_curr_p }; - var lex_env$1 = with_lexbuf(lexbuf$1, lex_env); - return { - la_results: [], - la_num_lexed: 0, - la_lex_mode: mode, - la_lex_env: lex_env$1 - }; } -function next_power_of_two(n) { - var _i = 1; +function __ocaml_lex_jsx_tag_rec(_env, lexbuf, ___ocaml_lex_state) { while(true) { - var i = _i; - if (i >= n) { - return i; - } - _i = (i << 1); - continue ; - }; -} - -function grow(t, n) { - if (t.la_results.length >= n) { - return ; - } - var new_size = next_power_of_two(n); - var filler = function (i) { - if (i < t.la_results.length) { - return Caml_array.get(t.la_results, i); + var __ocaml_lex_state = ___ocaml_lex_state; + var env = _env; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + return [ + env, + /* T_EOF */105 + ]; + case 1 : + Stdlib__Lexing.new_line(lexbuf); + ___ocaml_lex_state = 333; + continue ; + case 2 : + unicode_fix_cols(lexbuf); + ___ocaml_lex_state = 333; + continue ; + case 3 : + var start = from_lb(env.lex_source, lexbuf); + var buf = Stdlib__Buffer.create(127); + var match = line_comment(env, buf, lexbuf); + var env$1 = save_comment(match[0], start, match[1], buf, true); + ___ocaml_lex_state = 333; + _env = env$1; + continue ; + case 4 : + var start$1 = from_lb(env.lex_source, lexbuf); + var buf$1 = Stdlib__Buffer.create(127); + var match$1 = comment(env, buf$1, lexbuf); + var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + ___ocaml_lex_state = 333; + _env = env$2; + continue ; + case 5 : + return [ + env, + /* T_LESS_THAN */89 + ]; + case 6 : + return [ + env, + /* T_DIV */96 + ]; + case 7 : + return [ + env, + /* T_GREATER_THAN */90 + ]; + case 8 : + return [ + env, + /* T_LCURLY */1 + ]; + case 9 : + return [ + env, + /* T_COLON */77 + ]; + case 10 : + return [ + env, + /* T_PERIOD */9 + ]; + case 11 : + return [ + env, + /* T_ASSIGN */75 + ]; + case 12 : + unicode_fix_cols(lexbuf); + return [ + env, + /* T_JSX_IDENTIFIER */106 + ]; + case 13 : + var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var start$2 = from_lb(env.lex_source, lexbuf); + var buf$2 = Stdlib__Buffer.create(127); + var raw = Stdlib__Buffer.create(127); + Stdlib__Buffer.add_char(raw, quote); + var mode = quote === /* '\'' */39 ? /* JSX_SINGLE_QUOTED_TEXT */0 : /* JSX_DOUBLE_QUOTED_TEXT */1; + var match$2 = jsx_text(env, mode, buf$2, raw, lexbuf); + Stdlib__Buffer.add_char(raw, quote); + var value = Stdlib__Buffer.contents(buf$2); + var raw$1 = Stdlib__Buffer.contents(raw); + return [ + match$2[0], + { + TAG: /* T_JSX_TEXT */4, + _0: [ + btwn(start$2, match$2[1]), + value, + raw$1 + ] + } + ]; + case 14 : + return [ + env, + /* T_ERROR */104 + ]; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; } - }; - var new_arr = Stdlib__Array.init(new_size, filler); - t.la_results = new_arr; } -function lex(t) { - var lex_env = t.la_lex_env; - var match = t.la_lex_mode; - var match$1; - switch (match) { - case /* TYPE */1 : - match$1 = type_token$1(lex_env); - break; - case /* JSX_TAG */2 : - match$1 = jsx_tag(lex_env); - break; - case /* JSX_CHILD */3 : - match$1 = jsx_child$1(lex_env); - break; - case /* TEMPLATE */4 : - match$1 = template_tail(lex_env); - break; - case /* REGEXP */5 : - match$1 = regexp(lex_env); - break; - case /* NORMAL */0 : - case /* PREDICATE */6 : - match$1 = token$1(lex_env); - break; - - } - var lex_env$1 = match$1[0]; - var lexbuf = lex_env$1.lex_lb; - var lexbuf$1 = { - refill_buff: lexbuf.refill_buff, - lex_buffer: lexbuf.lex_buffer, - lex_buffer_len: lexbuf.lex_buffer_len, - lex_abs_pos: lexbuf.lex_abs_pos, - lex_start_pos: lexbuf.lex_start_pos, - lex_curr_pos: lexbuf.lex_curr_pos, - lex_last_pos: lexbuf.lex_last_pos, - lex_last_action: lexbuf.lex_last_action, - lex_eof_reached: lexbuf.lex_eof_reached, - lex_mem: lexbuf.lex_mem, - lex_start_p: lexbuf.lex_start_p, - lex_curr_p: lexbuf.lex_curr_p +function regexp_class(env, buf, lexbuf) { + var ___ocaml_lex_state = 326; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + return env; + case 1 : + case 2 : + break; + case 3 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c); + return env; + case 4 : + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c$1); + return regexp_class(env, buf, lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + var s = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); + Stdlib__Buffer.add_string(buf, s); + return regexp_class(env, buf, lexbuf); }; - var cloned_env = with_lexbuf(lexbuf$1, lex_env$1); - t.la_lex_env = lex_env$1; - Caml_array.set(t.la_results, t.la_num_lexed, [ - cloned_env, - match$1[1] - ]); - t.la_num_lexed = t.la_num_lexed + 1 | 0; } -function lex_until(t, i) { - grow(t, i + 1 | 0); - while(t.la_num_lexed <= i) { - lex(t); +function jsx_child(env, start, buf, raw, lexbuf) { + var ___ocaml_lex_state = 364; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + var lt = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + Stdlib__Buffer.add_string(raw, lt); + Stdlib__Buffer.add_string(buf, lt); + Stdlib__Lexing.new_line(lexbuf); + var match = jsx_text(env, /* JSX_CHILD_TEXT */2, buf, raw, lexbuf); + var value = Stdlib__Buffer.contents(buf); + var raw$1 = Stdlib__Buffer.contents(raw); + return [ + match[0], + { + TAG: /* T_JSX_TEXT */4, + _0: [ + btwn(start, match[1]), + value, + raw$1 + ] + } + ]; + case 1 : + return [ + env, + /* T_EOF */105 + ]; + case 2 : + return [ + env, + /* T_LESS_THAN */89 + ]; + case 3 : + return [ + env, + /* T_LCURLY */1 + ]; + case 4 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(raw, c); + Stdlib__Buffer.add_char(buf, c); + var match$1 = jsx_text(env, /* JSX_CHILD_TEXT */2, buf, raw, lexbuf); + var value$1 = Stdlib__Buffer.contents(buf); + var raw$2 = Stdlib__Buffer.contents(raw); + return [ + match$1[0], + { + TAG: /* T_JSX_TEXT */4, + _0: [ + btwn(start, match$1[1]), + value$1, + raw$2 + ] + } + ]; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } }; } -var default_parse_options = { - esproposal_class_instance_fields: false, - esproposal_class_static_fields: false, - esproposal_decorators: false, - esproposal_export_star_as: false, - types: true, - use_strict: false -}; +function regexp(env) { + return get_result_and_clear_state(__ocaml_lex_regexp_rec(env, env.lex_lb, 291)); +} -function init_env(token_sinkOpt, parse_optionsOpt, source, content) { - var token_sink = token_sinkOpt !== undefined ? Caml_option.valFromOption(token_sinkOpt) : undefined; - var parse_options = parse_optionsOpt !== undefined ? Caml_option.valFromOption(parse_optionsOpt) : undefined; - var lb = Stdlib__Lexing.from_string(undefined, content); - if (source !== undefined && typeof source !== "number") { - var init = lb.lex_curr_p; - lb.lex_curr_p = { - pos_fname: source._0, - pos_lnum: init.pos_lnum, - pos_bol: init.pos_bol, - pos_cnum: init.pos_cnum - }; - } - var parse_options$1 = parse_options !== undefined ? parse_options : default_parse_options; - var enable_types_in_comments = parse_options$1.types; - var lex_env = new_lex_env(source, lb, enable_types_in_comments); - return { - errors: { - contents: /* [] */0 - }, - comments: { - contents: /* [] */0 - }, - labels: /* Empty */0, - exports: { - contents: /* Empty */0 - }, - last_loc: { - contents: undefined - }, - in_strict_mode: parse_options$1.use_strict, - in_export: false, - in_loop: false, - in_switch: false, - in_function: false, - no_in: false, - no_call: false, - no_let: false, - allow_yield: true, - allow_await: false, - error_callback: undefined, - lex_mode_stack: { - contents: { - hd: /* NORMAL */0, - tl: /* [] */0 - } - }, - lex_env: { - contents: lex_env - }, - lookahead: { - contents: create$1(lex_env, /* NORMAL */0) - }, - token_sink: { - contents: token_sink - }, - parse_options: parse_options$1, - source: source - }; +function jsx_child$1(env) { + var start = from_curr_lb(env.lex_source, env.lex_lb); + var buf = Stdlib__Buffer.create(127); + var raw = Stdlib__Buffer.create(127); + var match = jsx_child(env, start, buf, raw, env.lex_lb); + return get_result_and_clear_state([ + match[0], + match[1] + ]); } -function error_at(env, param) { - var e = param[1]; - env.errors.contents = { - hd: [ - param[0], - e - ], - tl: env.errors.contents - }; - var callback = env.error_callback; - if (callback !== undefined) { - return Curry._2(callback, env, e); - } - +function jsx_tag(env) { + return get_result_and_clear_state(__ocaml_lex_jsx_tag_rec(env, env.lex_lb, 333)); } -function comment_list(env) { - return function (param) { - return Stdlib__List.iter((function (c) { - env.comments.contents = { - hd: c, - tl: env.comments.contents - }; - }), param); - }; +function template_tail(env) { + return get_result_and_clear_state(__ocaml_lex_template_tail_rec(env, env.lex_lb, 393)); } -function record_export(env, param) { - var export_name = param[1]; - var $$exports = env.exports.contents; - if (Curry._2(mem, export_name, $$exports)) { - return error_at(env, [ - param[0], - { - TAG: /* DuplicateExport */7, - _0: export_name - } - ]); +function type_token$1(env) { + return get_result_and_clear_state(type_token(env, env.lex_lb)); +} + +function token$1(env) { + return get_result_and_clear_state(token(env, env.lex_lb)); +} + +var funarg = { + compare: Stdlib__String.compare +}; + +function height(param) { + if (param) { + return param.h; } else { - env.exports.contents = Curry._2(add, export_name, env.exports.contents); - return ; + return 0; } } -function lookahead(iOpt, env) { - var i = iOpt !== undefined ? iOpt : 0; - if (i >= 2) { +function create(l, v, r) { + var hl = l ? l.h : 0; + var hr = r ? r.h : 0; + return /* Node */{ + l: l, + v: v, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; +} + +function bal(l, v, r) { + var hl = l ? l.h : 0; + var hr = r ? r.h : 0; + if (hl > (hr + 2 | 0)) { + if (l) { + var lr = l.r; + var lv = l.v; + var ll = l.l; + if (height(ll) >= height(lr)) { + return create(ll, lv, create(lr, v, r)); + } + if (lr) { + return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; + } throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "parser_env.ml", - 288, - 2 - ], + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", Error: new Error() }; } - var t = env.lookahead.contents; - lex_until(t, i); - var match = Caml_array.get(t.la_results, i); - if (match !== undefined) { - return match[1]; + if (hr <= (hl + 2 | 0)) { + return /* Node */{ + l: l, + v: v, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (r) { + var rr = r.r; + var rv = r.v; + var rl = r.l; + if (height(rr) >= height(rl)) { + return create(create(l, v, rl), rv, rr); + } + if (rl) { + return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; } throw { - RE_EXN_ID: "Failure", - _1: "Lookahead.peek failed", + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", Error: new Error() }; } -function with_strict(in_strict_mode, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.in_strict_mode = in_strict_mode; - return newrecord; +function add(x, t) { + if (!t) { + return /* Node */{ + l: /* Empty */0, + v: x, + r: /* Empty */0, + h: 1 + }; + } + var r = t.r; + var v = t.v; + var l = t.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + return t; + } + if (c < 0) { + var ll = add(x, l); + if (l === ll) { + return t; + } else { + return bal(ll, v, r); + } + } + var rr = add(x, r); + if (r === rr) { + return t; + } else { + return bal(l, v, rr); + } } -function with_in_function(in_function, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.in_function = in_function; - return newrecord; +function mem(x, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + var c = Curry._2(funarg.compare, x, param.v); + if (c === 0) { + return true; + } + _param = c < 0 ? param.l : param.r; + continue ; + }; } -function with_allow_yield(allow_yield, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.allow_yield = allow_yield; - return newrecord; +function create$1(lex_env, mode) { + var lexbuf = lex_env.lex_lb; + var lexbuf$1 = { + refill_buff: lexbuf.refill_buff, + lex_buffer: lexbuf.lex_buffer, + lex_buffer_len: lexbuf.lex_buffer_len, + lex_abs_pos: lexbuf.lex_abs_pos, + lex_start_pos: lexbuf.lex_start_pos, + lex_curr_pos: lexbuf.lex_curr_pos, + lex_last_pos: lexbuf.lex_last_pos, + lex_last_action: lexbuf.lex_last_action, + lex_eof_reached: lexbuf.lex_eof_reached, + lex_mem: lexbuf.lex_mem, + lex_start_p: lexbuf.lex_start_p, + lex_curr_p: lexbuf.lex_curr_p + }; + var lex_env$1 = with_lexbuf(lexbuf$1, lex_env); + return { + la_results: [], + la_num_lexed: 0, + la_lex_mode: mode, + la_lex_env: lex_env$1 + }; } -function with_no_let(no_let, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.no_let = no_let; - return newrecord; +function next_power_of_two(n) { + var _i = 1; + while(true) { + var i = _i; + if (i >= n) { + return i; + } + _i = (i << 1); + continue ; + }; } -function with_in_loop(in_loop, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.in_loop = in_loop; - return newrecord; +function grow(t, n) { + if (t.la_results.length >= n) { + return ; + } + var new_size = next_power_of_two(n); + var filler = function (i) { + if (i < t.la_results.length) { + return Caml_array.get(t.la_results, i); + } + + }; + var new_arr = Stdlib__Array.init(new_size, filler); + t.la_results = new_arr; } -function with_no_in(no_in, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.no_in = no_in; - return newrecord; +function lex(t) { + var lex_env = t.la_lex_env; + var match = t.la_lex_mode; + var match$1; + switch (match) { + case /* TYPE */1 : + match$1 = type_token$1(lex_env); + break; + case /* JSX_TAG */2 : + match$1 = jsx_tag(lex_env); + break; + case /* JSX_CHILD */3 : + match$1 = jsx_child$1(lex_env); + break; + case /* TEMPLATE */4 : + match$1 = template_tail(lex_env); + break; + case /* REGEXP */5 : + match$1 = regexp(lex_env); + break; + case /* NORMAL */0 : + case /* PREDICATE */6 : + match$1 = token$1(lex_env); + break; + + } + var lex_env$1 = match$1[0]; + var lexbuf = lex_env$1.lex_lb; + var lexbuf$1 = { + refill_buff: lexbuf.refill_buff, + lex_buffer: lexbuf.lex_buffer, + lex_buffer_len: lexbuf.lex_buffer_len, + lex_abs_pos: lexbuf.lex_abs_pos, + lex_start_pos: lexbuf.lex_start_pos, + lex_curr_pos: lexbuf.lex_curr_pos, + lex_last_pos: lexbuf.lex_last_pos, + lex_last_action: lexbuf.lex_last_action, + lex_eof_reached: lexbuf.lex_eof_reached, + lex_mem: lexbuf.lex_mem, + lex_start_p: lexbuf.lex_start_p, + lex_curr_p: lexbuf.lex_curr_p + }; + var cloned_env = with_lexbuf(lexbuf$1, lex_env$1); + t.la_lex_env = lex_env$1; + Caml_array.set(t.la_results, t.la_num_lexed, [ + cloned_env, + match$1[1] + ]); + t.la_num_lexed = t.la_num_lexed + 1 | 0; } -function with_in_switch(in_switch, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.in_switch = in_switch; - return newrecord; +function lex_until(t, i) { + grow(t, i + 1 | 0); + while(t.la_num_lexed <= i) { + lex(t); + }; } -function with_in_export(in_export, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.in_export = in_export; - return newrecord; -} +var default_parse_options = { + esproposal_class_instance_fields: false, + esproposal_class_static_fields: false, + esproposal_decorators: false, + esproposal_export_star_as: false, + types: true, + use_strict: false +}; -function with_no_call(no_call, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.no_call = no_call; - return newrecord; +function init_env(token_sinkOpt, parse_optionsOpt, source, content) { + var token_sink = token_sinkOpt !== undefined ? Caml_option.valFromOption(token_sinkOpt) : undefined; + var parse_options = parse_optionsOpt !== undefined ? Caml_option.valFromOption(parse_optionsOpt) : undefined; + var lb = Stdlib__Lexing.from_string(undefined, content); + if (source !== undefined && typeof source !== "number") { + var init = lb.lex_curr_p; + lb.lex_curr_p = { + pos_fname: source._0, + pos_lnum: init.pos_lnum, + pos_bol: init.pos_bol, + pos_cnum: init.pos_cnum + }; + } + var parse_options$1 = parse_options !== undefined ? parse_options : default_parse_options; + var enable_types_in_comments = parse_options$1.types; + var lex_env = new_lex_env(source, lb, enable_types_in_comments); + return { + errors: { + contents: /* [] */0 + }, + comments: { + contents: /* [] */0 + }, + labels: /* Empty */0, + exports: { + contents: /* Empty */0 + }, + last_loc: { + contents: undefined + }, + in_strict_mode: parse_options$1.use_strict, + in_export: false, + in_loop: false, + in_switch: false, + in_function: false, + no_in: false, + no_call: false, + no_let: false, + allow_yield: true, + allow_await: false, + error_callback: undefined, + lex_mode_stack: { + contents: { + hd: /* NORMAL */0, + tl: /* [] */0 + } + }, + lex_env: { + contents: lex_env + }, + lookahead: { + contents: create$1(lex_env, /* NORMAL */0) + }, + token_sink: { + contents: token_sink + }, + parse_options: parse_options$1, + source: source + }; } -function with_error_callback(error_callback, env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.error_callback = error_callback; - return newrecord; +function error_at(env, param) { + var e = param[1]; + env.errors.contents = { + hd: [ + param[0], + e + ], + tl: env.errors.contents + }; + var callback = env.error_callback; + if (callback !== undefined) { + return Curry._2(callback, env, e); + } + } -function error_list(env) { +function comment_list(env) { return function (param) { - return Stdlib__List.iter((function (param) { - return error_at(env, param); + return Stdlib__List.iter((function (c) { + env.comments.contents = { + hd: c, + tl: env.comments.contents + }; }), param); }; } -function without_error_callback(env) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.error_callback = undefined; - return newrecord; -} - -function add_label(env, label) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.labels = Curry._2(add, label, env.labels); - return newrecord; +function record_export(env, param) { + var export_name = param[1]; + var $$exports = env.exports.contents; + if (Curry._2(mem, export_name, $$exports)) { + return error_at(env, [ + param[0], + { + TAG: /* DuplicateExport */7, + _0: export_name + } + ]); + } else { + env.exports.contents = Curry._2(add, export_name, env.exports.contents); + return ; + } } -function enter_function(env, async, generator) { - var newrecord = Caml_obj.caml_obj_dup(env); - newrecord.allow_await = async; - newrecord.allow_yield = generator; - newrecord.in_function = true; - newrecord.in_switch = false; - newrecord.in_loop = false; - newrecord.labels = /* Empty */0; +function lookahead(iOpt, env) { + var i = iOpt !== undefined ? iOpt : 0; + if (i >= 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "parser_env.ml", + 288, + 2 + ], + Error: new Error() + }; + } + var t = env.lookahead.contents; + lex_until(t, i); + var match = Caml_array.get(t.la_results, i); + if (match !== undefined) { + return match[1]; + } + throw { + RE_EXN_ID: "Failure", + _1: "Lookahead.peek failed", + Error: new Error() + }; +} + +function with_strict(in_strict_mode, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.in_strict_mode = in_strict_mode; + return newrecord; +} + +function with_in_function(in_function, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.in_function = in_function; + return newrecord; +} + +function with_allow_yield(allow_yield, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.allow_yield = allow_yield; + return newrecord; +} + +function with_no_let(no_let, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.no_let = no_let; + return newrecord; +} + +function with_in_loop(in_loop, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.in_loop = in_loop; + return newrecord; +} + +function with_no_in(no_in, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.no_in = no_in; + return newrecord; +} + +function with_in_switch(in_switch, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.in_switch = in_switch; + return newrecord; +} + +function with_in_export(in_export, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.in_export = in_export; + return newrecord; +} + +function with_no_call(no_call, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.no_call = no_call; + return newrecord; +} + +function with_error_callback(error_callback, env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.error_callback = error_callback; + return newrecord; +} + +function error_list(env) { + return function (param) { + return Stdlib__List.iter((function (param) { + return error_at(env, param); + }), param); + }; +} + +function without_error_callback(env) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.error_callback = undefined; + return newrecord; +} + +function add_label(env, label) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.labels = Curry._2(add, label, env.labels); + return newrecord; +} + +function enter_function(env, async, generator) { + var newrecord = Caml_obj.caml_obj_dup(env); + newrecord.allow_await = async; + newrecord.allow_yield = generator; + newrecord.in_function = true; + newrecord.in_switch = false; + newrecord.in_loop = false; + newrecord.labels = /* Empty */0; return newrecord; } @@ -6909,24 +6909,137 @@ var Parse = Caml_module.init_mod([ ] }); -function prefix(env) { - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (match !== 76) { - var t = primary(env); - return postfix_with(env, t); +function param_list_or_type(env) { + token$4(env, /* T_LPAREN */3); + var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); + var ret; + var exit = 0; + if (typeof token$5 === "number") { + if (token$5 !== 105) { + if (token$5 >= 12) { + exit = 1; + } else { + switch (token$5) { + case /* T_IDENTIFIER */0 : + ret = function_param_or_generic_type(env); + break; + case /* T_RPAREN */4 : + ret = { + TAG: /* ParamList */0, + _0: [ + undefined, + /* [] */0 + ] + }; + break; + case /* T_LCURLY */1 : + case /* T_RCURLY */2 : + case /* T_LPAREN */3 : + case /* T_LBRACKET */5 : + case /* T_RBRACKET */6 : + case /* T_SEMICOLON */7 : + case /* T_COMMA */8 : + case /* T_PERIOD */9 : + case /* T_ARROW */10 : + exit = 1; + break; + case /* T_ELLIPSIS */11 : + ret = { + TAG: /* ParamList */0, + _0: Curry._2(function_param_list_without_parens, env, /* [] */0) + }; + break; + + } + } + } else { + ret = { + TAG: /* ParamList */0, + _0: Curry._2(function_param_list_without_parens, env, /* [] */0) + }; + } + } else { + exit = 1; } - var loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_PLING */76); - var t$1 = prefix(env); + if (exit === 1) { + var match = primitive(token$5); + if (match !== undefined) { + var match$1 = Curry._2(Parser_env_Peek.token, 1, env); + if (typeof match$1 === "number" && (match$1 === 77 || match$1 === 76)) { + var match$2 = Curry._1(Parse.identifier_or_reserved_keyword, env); + var name = match$2[0]; + if (!env.parse_options.types) { + error$1(env, /* UnexpectedTypeAnnotation */6); + } + var optional = maybe(env, /* T_PLING */76); + token$4(env, /* T_COLON */77); + var typeAnnotation = union(env); + if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RPAREN */4)) { + token$4(env, /* T_COMMA */8); + } + var param_0 = btwn(name[0], typeAnnotation[0]); + var param_1 = { + name: name, + typeAnnotation: typeAnnotation, + optional: optional + }; + var param = [ + param_0, + param_1 + ]; + ret = { + TAG: /* ParamList */0, + _0: Curry._2(function_param_list_without_parens, env, { + hd: param, + tl: /* [] */0 + }) + }; + } else { + ret = { + TAG: /* Type */1, + _0: union(env) + }; + } + } else { + ret = { + TAG: /* Type */1, + _0: union(env) + }; + } + } + token$4(env, /* T_RPAREN */4); + return ret; +} + +function union(env) { + maybe(env, /* T_BIT_OR */80); + var left = intersection(env); + return Curry._2(union_with, env, left); +} + +function function_param_with_id(env, name) { + if (!env.parse_options.types) { + error$1(env, /* UnexpectedTypeAnnotation */6); + } + var optional = maybe(env, /* T_PLING */76); + token$4(env, /* T_COLON */77); + var typeAnnotation = union(env); return [ - btwn(loc, t$1[0]), + btwn(name[0], typeAnnotation[0]), { - TAG: /* Nullable */0, - _0: t$1 + name: name, + typeAnnotation: typeAnnotation, + optional: optional } ]; } +function intersection(env) { + maybe(env, /* T_BIT_AND */82); + var left = prefix(env); + return Curry._2(intersection_with, env, left); +} + function rev_nonempty_acc(acc) { var end_loc; if (acc) { @@ -6963,23 +7076,6 @@ function rev_nonempty_acc(acc) { ]; } -function function_param_with_id(env, name) { - if (!env.parse_options.types) { - error$1(env, /* UnexpectedTypeAnnotation */6); - } - var optional = maybe(env, /* T_PLING */76); - token$4(env, /* T_COLON */77); - var typeAnnotation = union(env); - return [ - btwn(name[0], typeAnnotation[0]), - { - name: name, - typeAnnotation: typeAnnotation, - optional: optional - } - ]; -} - function function_param_list(env) { token$4(env, /* T_LPAREN */3); var ret = Curry._2(function_param_list_without_parens, env, /* [] */0); @@ -6987,10 +7083,67 @@ function function_param_list(env) { return ret; } -function union(env) { - maybe(env, /* T_BIT_OR */80); - var left = intersection(env); - return Curry._2(union_with, env, left); +function primitive(param) { + if (typeof param !== "number") { + return ; + } + if (param === 27) { + return /* Null */2; + } + if (param < 107) { + return ; + } + switch (param) { + case /* T_ANY_TYPE */107 : + return /* Any */0; + case /* T_BOOLEAN_TYPE */108 : + return /* Boolean */5; + case /* T_NUMBER_TYPE */109 : + return /* Number */3; + case /* T_STRING_TYPE */110 : + return /* String */4; + case /* T_VOID_TYPE */111 : + return /* Void */1; + + } +} + +function function_param_or_generic_type(env) { + var id = Curry._2(Parse.identifier, undefined, env); + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "number" && (match === 77 || match === 76)) { + var param = function_param_with_id(env, id); + maybe(env, /* T_COMMA */8); + return { + TAG: /* ParamList */0, + _0: Curry._2(function_param_list_without_parens, env, { + hd: param, + tl: /* [] */0 + }) + }; + } + return { + TAG: /* Type */1, + _0: Curry._2(union_with, env, Curry._2(intersection_with, env, postfix_with(env, generic_type_with_identifier(env, id)))) + }; +} + +function prefix(env) { + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (match !== 76) { + var t = primary(env); + return postfix_with(env, t); + } + var loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_PLING */76); + var t$1 = prefix(env); + return [ + btwn(loc, t$1[0]), + { + TAG: /* Nullable */0, + _0: t$1 + } + ]; } function postfix_with(env, _t) { @@ -7015,6 +7168,21 @@ function postfix_with(env, _t) { }; } +function generic_type_with_identifier(env, id) { + var match = Curry._2(raw_generic_with_identifier, env, id); + return [ + match[0], + { + TAG: /* Generic */4, + _0: match[1] + } + ]; +} + +function generic(env) { + return Curry._2(raw_generic_with_identifier, env, Curry._2(Parse.identifier, undefined, env)); +} + function primary(env) { var loc = Curry._2(Parser_env_Peek.loc, undefined, env); var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); @@ -7207,260 +7375,135 @@ function primary(env) { } } -function primitive(param) { - if (typeof param !== "number") { - return ; - } - if (param === 27) { - return /* Null */2; - } - if (param < 107) { +function params(env, _acc) { + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "number") { + if (match === 90) { + return Stdlib__List.rev(acc); + } + if (match === 105) { + return Stdlib__List.rev(acc); + } + + } + var acc_0 = union(env); + var acc$1 = { + hd: acc_0, + tl: acc + }; + if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_GREATER_THAN */90)) { + token$4(env, /* T_COMMA */8); + } + _acc = acc$1; + continue ; + }; +} + +function type_parameter_instantiation(env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + if (!Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_LESS_THAN */89)) { return ; } - switch (param) { - case /* T_ANY_TYPE */107 : - return /* Any */0; - case /* T_BOOLEAN_TYPE */108 : - return /* Boolean */5; - case /* T_NUMBER_TYPE */109 : - return /* Number */3; - case /* T_STRING_TYPE */110 : - return /* String */4; - case /* T_VOID_TYPE */111 : - return /* Void */1; - - } + token$4(env, /* T_LESS_THAN */89); + var params$1 = params(env, /* [] */0); + var loc = btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env)); + token$4(env, /* T_GREATER_THAN */90); + return [ + loc, + { + params: params$1 + } + ]; } -function generic(env) { - return Curry._2(raw_generic_with_identifier, env, Curry._2(Parse.identifier, undefined, env)); +function params$1(env, allow_default, _require_default, _acc) { + while(true) { + var acc = _acc; + var require_default = _require_default; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + var variance = typeof match === "number" ? ( + match !== 94 ? ( + match !== 95 ? undefined : (token$3(env), /* Minus */1) + ) : (token$3(env), /* Plus */0) + ) : undefined; + var match$1 = Curry._2(Parse.identifier_with_type, env, /* StrictParamName */28); + var id = match$1[1]; + var loc = match$1[0]; + var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); + var match$3 = allow_default ? ( + match$2 === 75 ? (token$3(env), [ + union(env), + true + ]) : (require_default ? error_at(env, [ + loc, + /* MissingTypeParamDefault */58 + ]) : undefined, [ + undefined, + require_default + ]) + ) : [ + undefined, + false + ]; + var param_1 = { + name: id.name, + bound: id.typeAnnotation, + variance: variance, + default: match$3[0] + }; + var param = [ + loc, + param_1 + ]; + var acc$1 = { + hd: param, + tl: acc + }; + var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match$4 === "number") { + if (match$4 === 90) { + return Stdlib__List.rev(acc$1); + } + if (match$4 === 105) { + return Stdlib__List.rev(acc$1); + } + + } + token$4(env, /* T_COMMA */8); + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_GREATER_THAN */90)) { + return Stdlib__List.rev(acc$1); + } + _acc = acc$1; + _require_default = match$3[1]; + continue ; + }; } -function generic_type_with_identifier(env, id) { - var match = Curry._2(raw_generic_with_identifier, env, id); +function type_parameter_declaration(allow_default, env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + if (!Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_LESS_THAN */89)) { + return ; + } + if (!env.parse_options.types) { + error$1(env, /* UnexpectedTypeAnnotation */6); + } + token$4(env, /* T_LESS_THAN */89); + var params$2 = params$1(env, allow_default, false, /* [] */0); + var loc = btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env)); + token$4(env, /* T_GREATER_THAN */90); return [ - match[0], + loc, { - TAG: /* Generic */4, - _0: match[1] + params: params$2 } ]; } -function intersection(env) { - maybe(env, /* T_BIT_AND */82); - var left = prefix(env); - return Curry._2(intersection_with, env, left); -} - -function param_list_or_type(env) { - token$4(env, /* T_LPAREN */3); - var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); - var ret; - var exit = 0; - if (typeof token$5 === "number") { - if (token$5 !== 105) { - if (token$5 >= 12) { - exit = 1; - } else { - switch (token$5) { - case /* T_IDENTIFIER */0 : - ret = function_param_or_generic_type(env); - break; - case /* T_RPAREN */4 : - ret = { - TAG: /* ParamList */0, - _0: [ - undefined, - /* [] */0 - ] - }; - break; - case /* T_LCURLY */1 : - case /* T_RCURLY */2 : - case /* T_LPAREN */3 : - case /* T_LBRACKET */5 : - case /* T_RBRACKET */6 : - case /* T_SEMICOLON */7 : - case /* T_COMMA */8 : - case /* T_PERIOD */9 : - case /* T_ARROW */10 : - exit = 1; - break; - case /* T_ELLIPSIS */11 : - ret = { - TAG: /* ParamList */0, - _0: Curry._2(function_param_list_without_parens, env, /* [] */0) - }; - break; - - } - } - } else { - ret = { - TAG: /* ParamList */0, - _0: Curry._2(function_param_list_without_parens, env, /* [] */0) - }; - } - } else { - exit = 1; - } - if (exit === 1) { - var match = primitive(token$5); - if (match !== undefined) { - var match$1 = Curry._2(Parser_env_Peek.token, 1, env); - if (typeof match$1 === "number" && (match$1 === 77 || match$1 === 76)) { - var match$2 = Curry._1(Parse.identifier_or_reserved_keyword, env); - var name = match$2[0]; - if (!env.parse_options.types) { - error$1(env, /* UnexpectedTypeAnnotation */6); - } - var optional = maybe(env, /* T_PLING */76); - token$4(env, /* T_COLON */77); - var typeAnnotation = union(env); - if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RPAREN */4)) { - token$4(env, /* T_COMMA */8); - } - var param_0 = btwn(name[0], typeAnnotation[0]); - var param_1 = { - name: name, - typeAnnotation: typeAnnotation, - optional: optional - }; - var param = [ - param_0, - param_1 - ]; - ret = { - TAG: /* ParamList */0, - _0: Curry._2(function_param_list_without_parens, env, { - hd: param, - tl: /* [] */0 - }) - }; - } else { - ret = { - TAG: /* Type */1, - _0: union(env) - }; - } - } else { - ret = { - TAG: /* Type */1, - _0: union(env) - }; - } - } - token$4(env, /* T_RPAREN */4); - return ret; -} - -function function_param_or_generic_type(env) { - var id = Curry._2(Parse.identifier, undefined, env); - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number" && (match === 77 || match === 76)) { - var param = function_param_with_id(env, id); - maybe(env, /* T_COMMA */8); - return { - TAG: /* ParamList */0, - _0: Curry._2(function_param_list_without_parens, env, { - hd: param, - tl: /* [] */0 - }) - }; - } - return { - TAG: /* Type */1, - _0: Curry._2(union_with, env, Curry._2(intersection_with, env, postfix_with(env, generic_type_with_identifier(env, id)))) - }; -} - -function params(env, allow_default, _require_default, _acc) { - while(true) { - var acc = _acc; - var require_default = _require_default; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - var variance = typeof match === "number" ? ( - match !== 94 ? ( - match !== 95 ? undefined : (token$3(env), /* Minus */1) - ) : (token$3(env), /* Plus */0) - ) : undefined; - var match$1 = Curry._2(Parse.identifier_with_type, env, /* StrictParamName */28); - var id = match$1[1]; - var loc = match$1[0]; - var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); - var match$3 = allow_default ? ( - match$2 === 75 ? (token$3(env), [ - union(env), - true - ]) : (require_default ? error_at(env, [ - loc, - /* MissingTypeParamDefault */58 - ]) : undefined, [ - undefined, - require_default - ]) - ) : [ - undefined, - false - ]; - var param_1 = { - name: id.name, - bound: id.typeAnnotation, - variance: variance, - default: match$3[0] - }; - var param = [ - loc, - param_1 - ]; - var acc$1 = { - hd: param, - tl: acc - }; - var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match$4 === "number") { - if (match$4 === 90) { - return Stdlib__List.rev(acc$1); - } - if (match$4 === 105) { - return Stdlib__List.rev(acc$1); - } - - } - token$4(env, /* T_COMMA */8); - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_GREATER_THAN */90)) { - return Stdlib__List.rev(acc$1); - } - _acc = acc$1; - _require_default = match$3[1]; - continue ; - }; -} - -function type_parameter_declaration(allow_default, env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (!Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_LESS_THAN */89)) { - return ; - } - if (!env.parse_options.types) { - error$1(env, /* UnexpectedTypeAnnotation */6); - } - token$4(env, /* T_LESS_THAN */89); - var params$1 = params(env, allow_default, false, /* [] */0); - var loc = btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env)); - token$4(env, /* T_GREATER_THAN */90); - return [ - loc, - { - params: params$1 - } - ]; -} - -function param(env) { - var match = Curry._1(Parse.identifier_or_reserved_keyword, env); - return function_param_with_id(env, match[0]); +function param(env) { + var match = Curry._1(Parse.identifier_or_reserved_keyword, env); + return function_param_with_id(env, match[0]); } function function_param_list_without_parens(env) { @@ -7501,85 +7544,66 @@ function function_param_list_without_parens(env) { }; } -function identifier(env, _param) { - while(true) { - var param = _param; - var qualification = param[1]; - var q_loc = param[0]; - if (!Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_PERIOD */9)) { +function intersection_with(env, left) { + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_BIT_AND */82)) { + var _acc = { + hd: left, + tl: /* [] */0 + }; + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (match === 82) { + token$4(env, /* T_BIT_AND */82); + _acc = { + hd: prefix(env), + tl: acc + }; + continue ; + } + var match$1 = rev_nonempty_acc(acc); return [ - q_loc, - qualification + match$1[0], + { + TAG: /* Intersection */6, + _0: match$1[1] + } ]; - } - token$4(env, /* T_PERIOD */9); - var id = Curry._2(Parse.identifier, undefined, env); - var loc = btwn(q_loc, id[0]); - var qualification$1 = { - TAG: /* Qualified */1, - _0: [ - loc, - { - qualification: qualification, - id: id - } - ] }; - _param = [ - loc, - qualification$1 - ]; - continue ; - }; + } else { + return left; + } } -function raw_generic_with_identifier(env, id) { - var id_0 = id[0]; - var id_1 = { - TAG: /* Unqualified */0, - _0: id - }; - var id$1 = [ - id_0, - id_1 - ]; - var match = identifier(env, id$1); - var id_loc = match[0]; - var typeParameters = Curry._1(type_parameter_instantiation, env); - var loc = typeParameters !== undefined ? btwn(id_loc, typeParameters[0]) : id_loc; - return [ - loc, - { - id: match[1], - typeParameters: typeParameters - } - ]; -} - -function types(env, _acc) { - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number") { - if (match === 6) { - return Stdlib__List.rev(acc); - } - if (match === 105) { - return Stdlib__List.rev(acc); +function union_with(env, left) { + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_BIT_OR */80)) { + var _acc = { + hd: left, + tl: /* [] */0 + }; + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (match === 80) { + token$4(env, /* T_BIT_OR */80); + _acc = { + hd: intersection(env), + tl: acc + }; + continue ; } - - } - var acc_0 = union(env); - var acc$1 = { - hd: acc_0, - tl: acc + var match$1 = rev_nonempty_acc(acc); + return [ + match$1[0], + { + TAG: /* Union */5, + _0: match$1[1] + } + ]; }; - if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RBRACKET */6)) { - token$4(env, /* T_COMMA */8); - } - _acc = acc$1; - continue ; - }; + } else { + return left; + } } function methodish(env, start_loc) { @@ -7841,74 +7865,12 @@ function _object(allow_staticOpt, env) { ]; } -function union_with(env, left) { - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_BIT_OR */80)) { - var _acc = { - hd: left, - tl: /* [] */0 - }; - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (match === 80) { - token$4(env, /* T_BIT_OR */80); - _acc = { - hd: intersection(env), - tl: acc - }; - continue ; - } - var match$1 = rev_nonempty_acc(acc); - return [ - match$1[0], - { - TAG: /* Union */5, - _0: match$1[1] - } - ]; - }; - } else { - return left; - } -} - -function intersection_with(env, left) { - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_BIT_AND */82)) { - var _acc = { - hd: left, - tl: /* [] */0 - }; - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (match === 82) { - token$4(env, /* T_BIT_AND */82); - _acc = { - hd: prefix(env), - tl: acc - }; - continue ; - } - var match$1 = rev_nonempty_acc(acc); - return [ - match$1[0], - { - TAG: /* Intersection */6, - _0: match$1[1] - } - ]; - }; - } else { - return left; - } -} - -function params$1(env, _acc) { +function types(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); if (typeof match === "number") { - if (match === 90) { + if (match === 6) { return Stdlib__List.rev(acc); } if (match === 105) { @@ -7921,7 +7883,7 @@ function params$1(env, _acc) { hd: acc_0, tl: acc }; - if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_GREATER_THAN */90)) { + if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RBRACKET */6)) { token$4(env, /* T_COMMA */8); } _acc = acc$1; @@ -7929,19 +7891,57 @@ function params$1(env, _acc) { }; } -function type_parameter_instantiation(env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (!Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_LESS_THAN */89)) { - return ; - } - token$4(env, /* T_LESS_THAN */89); - var params$2 = params$1(env, /* [] */0); - var loc = btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env)); - token$4(env, /* T_GREATER_THAN */90); +function identifier(env, _param) { + while(true) { + var param = _param; + var qualification = param[1]; + var q_loc = param[0]; + if (!Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_PERIOD */9)) { + return [ + q_loc, + qualification + ]; + } + token$4(env, /* T_PERIOD */9); + var id = Curry._2(Parse.identifier, undefined, env); + var loc = btwn(q_loc, id[0]); + var qualification$1 = { + TAG: /* Qualified */1, + _0: [ + loc, + { + qualification: qualification, + id: id + } + ] + }; + _param = [ + loc, + qualification$1 + ]; + continue ; + }; +} + +function raw_generic_with_identifier(env, id) { + var id_0 = id[0]; + var id_1 = { + TAG: /* Unqualified */0, + _0: id + }; + var id$1 = [ + id_0, + id_1 + ]; + var match = identifier(env, id$1); + var id_loc = match[0]; + var typeParameters = Curry._1(type_parameter_instantiation, env); + var loc = typeParameters !== undefined ? btwn(id_loc, typeParameters[0]) : id_loc; return [ loc, { - params: params$2 + id: match[1], + typeParameters: typeParameters } ]; } @@ -9869,1135 +9869,185 @@ function binary_op(env) { ]; break; case /* T_EXP */98 : - ret = [ - /* Exp */14, - { - TAG: /* Right_assoc */1, - _0: 10 - } - ]; - break; - case /* T_MOD */99 : - ret = [ - /* Mod */16, - { - TAG: /* Left_assoc */0, - _0: 9 - } - ]; - break; - case /* T_NOT */100 : - case /* T_BIT_NOT */101 : - case /* T_INCR */102 : - case /* T_DECR */103 : - case /* T_ERROR */104 : - case /* T_EOF */105 : - case /* T_JSX_IDENTIFIER */106 : - case /* T_ANY_TYPE */107 : - case /* T_BOOLEAN_TYPE */108 : - case /* T_NUMBER_TYPE */109 : - case /* T_STRING_TYPE */110 : - case /* T_VOID_TYPE */111 : - ret = undefined; - break; - - } - } else { - ret = undefined; - } - } else { - ret = undefined; - } - if (ret !== undefined) { - token$3(env); - } - return ret; -} - -function make_binary(left, right, operator, loc) { - return [ - loc, - { - TAG: /* Binary */6, - _0: { - operator: operator, - left: left, - right: right - } - } - ]; -} - -function add_to_stack(_right, _param, _rloc, _stack) { - while(true) { - var param = _param; - var stack = _stack; - var rloc = _rloc; - var right = _right; - var rpri = param[1]; - var rop = param[0]; - if (stack) { - var match = stack.hd; - var match$1 = match[1]; - if (is_tighter(match$1[1], rpri)) { - var loc = btwn(match[2], rloc); - var right$1 = make_binary(match[0], right, match$1[0], loc); - _stack = stack.tl; - _rloc = loc; - _param = [ - rop, - rpri - ]; - _right = right$1; - continue ; - } - - } - return { - hd: [ - right, - [ - rop, - rpri - ], - rloc - ], - tl: stack - }; - }; -} - -function binary(env) { - var _stack = /* [] */0; - while(true) { - var stack = _stack; - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var is_unary = peek_unary_op(env) !== undefined; - var right = unary(with_no_in(false, env)); - var loc = env.last_loc.contents; - var end_loc = loc !== undefined ? loc : right[0]; - var right_loc = btwn(start_loc, end_loc); - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_LESS_THAN */89)) { - var tmp = right[1]; - if (typeof tmp !== "number" && tmp.TAG === /* JSXElement */22) { - error$1(env, /* AdjacentJSXElements */46); - } - - } - var match = binary_op(env); - if (match === undefined) { - var _right = right; - var _rloc = right_loc; - var _param = stack; - while(true) { - var param = _param; - var rloc = _rloc; - var right$1 = _right; - if (!param) { - return right$1; - } - var match$1 = param.hd; - var loc$1 = btwn(match$1[2], rloc); - _param = param.tl; - _rloc = loc$1; - _right = make_binary(match$1[0], right$1, match$1[1][0], loc$1); - continue ; - }; - } - var rop = match[0]; - if (is_unary && rop === /* Exp */14) { - error_at(env, [ - right_loc, - /* InvalidLHSInExponentiation */15 - ]); - } - _stack = add_to_stack(right, [ - rop, - match[1] - ], right_loc, stack); - continue ; - }; -} - -function argument(env) { - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (match !== 11) { - return { - TAG: /* Expression */0, - _0: Curry._1(assignment, env) - }; - } - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_ELLIPSIS */11); - var argument$1 = Curry._1(assignment, env); - var loc = btwn(start_loc, argument$1[0]); - return { - TAG: /* Spread */1, - _0: [ - loc, - { - argument: argument$1 - } - ] - }; -} - -function arguments$p(env, _acc) { - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number") { - if (match === 4) { - return Stdlib__List.rev(acc); - } - if (match === 105) { - return Stdlib__List.rev(acc); - } - - } - var acc_0 = argument(env); - var acc$1 = { - hd: acc_0, - tl: acc - }; - if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RPAREN */4)) { - token$4(env, /* T_COMMA */8); - } - _acc = acc$1; - continue ; - }; -} - -function $$arguments(env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_LPAREN */3); - var args = arguments$p(env, /* [] */0); - var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_RPAREN */4); - return [ - btwn(start_loc, end_loc), - args - ]; -} - -function template_parts(env, _quasis, _expressions) { - while(true) { - var expressions = _expressions; - var quasis = _quasis; - var expr = Curry._1(Parse.expression, env); - var expressions$1 = { - hd: expr, - tl: expressions - }; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (match === 2) { - push_lex_mode(env, /* TEMPLATE */4); - var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); - var match$2; - if (typeof match$1 === "number") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 1602, - 19 - ], - Error: new Error() - }; - } - if (match$1.TAG === /* T_TEMPLATE_PART */2) { - var match$3 = match$1._0; - var tail = match$3[2]; - var match$4 = match$3[1]; - token$3(env); - match$2 = [ - match$3[0], - { - value: { - raw: match$4.raw, - cooked: match$4.cooked - }, - tail: tail - }, - tail - ]; - } else { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 1602, - 19 - ], - Error: new Error() - }; - } - var loc = match$2[0]; - pop_lex_mode(env); - var quasis_0 = [ - loc, - match$2[1] - ]; - var quasis$1 = { - hd: quasis_0, - tl: quasis - }; - if (match$2[2]) { - return [ - loc, - Stdlib__List.rev(quasis$1), - Stdlib__List.rev(expressions$1) - ]; - } - _expressions = expressions$1; - _quasis = quasis$1; - continue ; - } - error_unexpected(env); - var imaginary_quasi_0 = expr[0]; - var imaginary_quasi_1 = { - value: { - raw: "", - cooked: "" - }, - tail: true - }; - var imaginary_quasi = [ - imaginary_quasi_0, - imaginary_quasi_1 - ]; - return [ - expr[0], - Stdlib__List.rev({ - hd: imaginary_quasi, - tl: quasis - }), - Stdlib__List.rev(expressions$1) - ]; - }; -} - -function template_literal(env, part) { - var is_tail = part[2]; - var match = part[1]; - var start_loc = part[0]; - token$4(env, { - TAG: /* T_TEMPLATE_PART */2, - _0: part - }); - var head_1 = { - value: { - raw: match.raw, - cooked: match.cooked - }, - tail: is_tail - }; - var head = [ - start_loc, - head_1 - ]; - var match$1 = is_tail ? [ - start_loc, - { - hd: head, - tl: /* [] */0 - }, - /* [] */0 - ] : template_parts(env, { - hd: head, - tl: /* [] */0 - }, /* [] */0); - var loc = btwn(start_loc, match$1[0]); - return [ - loc, - { - quasis: match$1[1], - expressions: match$1[2] - } - ]; -} - -function elements(env, _acc) { - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number") { - if (match === 105) { - return Stdlib__List.rev(acc); - } - if (match < 12) { - switch (match) { - case /* T_RBRACKET */6 : - return Stdlib__List.rev(acc); - case /* T_COMMA */8 : - token$4(env, /* T_COMMA */8); - _acc = { - hd: undefined, - tl: acc - }; - continue ; - case /* T_IDENTIFIER */0 : - case /* T_LCURLY */1 : - case /* T_RCURLY */2 : - case /* T_LPAREN */3 : - case /* T_RPAREN */4 : - case /* T_LBRACKET */5 : - case /* T_SEMICOLON */7 : - case /* T_PERIOD */9 : - case /* T_ARROW */10 : - break; - case /* T_ELLIPSIS */11 : - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_ELLIPSIS */11); - var argument = Curry._1(assignment, env); - var loc = btwn(start_loc, argument[0]); - var elem = { - TAG: /* Spread */1, - _0: [ - loc, - { - argument: argument - } - ] - }; - _acc = { - hd: elem, - tl: acc - }; - continue ; - - } - } - - } - var elem$1 = { - TAG: /* Expression */0, - _0: Curry._1(assignment, env) - }; - if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RBRACKET */6)) { - token$4(env, /* T_COMMA */8); - } - _acc = { - hd: elem$1, - tl: acc - }; - continue ; - }; -} - -function array_initializer(env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_LBRACKET */5); - var elements$1 = elements(env, /* [] */0); - var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_RBRACKET */6); - return [ - btwn(start_loc, end_loc), - { - elements: elements$1 - } - ]; -} - -function error_callback$1(param) { - return function (param) { - if (typeof param === "number") { - if (param > 44 || param < 28) { - if (param === 47) { - return ; - } - throw { - RE_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; - } - if (param > 43 || param < 29) { - return ; - } - throw { - RE_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; - } - throw { - RE_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; - }; -} - -function try_arrow_function(env) { - var env$1 = with_error_callback(error_callback$1, env); - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env$1); - var async = Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, 1, env$1), /* T_ARROW */10) && maybe(env$1, /* T_ASYNC */61); - var typeParameters = Curry._1(type_parameter_declaration$1, env$1); - var match; - if (Curry._2(Parser_env_Peek.is_identifier, undefined, env$1) && typeParameters === undefined) { - var id = Curry._2(Parse.identifier, /* StrictParamName */28, env$1); - var param_0 = id[0]; - var param_1 = { - TAG: /* Identifier */3, - _0: id - }; - var param = [ - param_0, - param_1 - ]; - match = [ - { - hd: param, - tl: /* [] */0 - }, - /* [] */0, - undefined, - undefined - ]; - } else { - var match$1 = function_params(env$1); - match = [ - match$1[0], - match$1[1], - match$1[2], - wrap(annotation_opt, env$1) - ]; - } - var rest = match[2]; - var defaults = match[1]; - var params = match[0]; - var predicate = Curry._1(Parse.predicate, env$1); - var env$2 = Caml_obj.caml_equal(params, /* [] */0) || rest !== undefined ? without_error_callback(env$1) : env$1; - if (Curry._1(Parser_env_Peek.is_line_terminator, env$2) && Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env$2), /* T_ARROW */10)) { - error$1(env$2, /* NewlineBeforeArrow */44); - } - token$4(env$2, /* T_ARROW */10); - var env$3 = without_error_callback(env$2); - var match$2 = with_loc((function (param) { - var generator = false; - var env = with_in_function(true, param); - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (match === 1) { - var match$1 = function_body(env, async, generator); - return [ - match$1[1], - match$1[2] - ]; - } - var env$1 = enter_function(env, async, generator); - var expr = Curry._1(Parse.assignment, env$1); - return [ - { - TAG: /* BodyExpression */1, - _0: expr - }, - env$1.in_strict_mode - ]; - }), env$3); - var match$3 = match$2[1]; - var body = match$3[0]; - var simple = is_simple_function_params(params, defaults, rest); - strict_post_check(env$3, match$3[1], simple, undefined, params); - var expression; - expression = body.TAG === /* BodyBlock */0 ? false : true; - var loc = btwn(start_loc, match$2[0]); - return [ - loc, - { - TAG: /* ArrowFunction */3, - _0: { - id: undefined, - params: params, - defaults: defaults, - rest: rest, - body: body, - async: async, - generator: false, - predicate: predicate, - expression: expression, - returnType: match[3], - typeParameters: typeParameters - } - } - ]; -} - -function decorator_list_helper(env, _decorators) { - while(true) { - var decorators = _decorators; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (match !== 12) { - return decorators; - } - token$3(env); - _decorators = { - hd: left_hand_side(env), - tl: decorators - }; - continue ; - }; -} - -function decorator_list(env) { - if (env.parse_options.esproposal_decorators) { - return Stdlib__List.rev(decorator_list_helper(env, /* [] */0)); - } else { - return /* [] */0; - } -} - -function key(env) { - var number_type = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof number_type === "number") { - if (number_type === /* T_LBRACKET */5) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_LBRACKET */5); - var expr = Curry._1(Parse.assignment, with_no_in(false, env)); - var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_RBRACKET */6); - return [ - btwn(start_loc, end_loc), - { - TAG: /* Computed */2, - _0: expr - } - ]; - } - - } else { - switch (number_type.TAG | 0) { - case /* T_NUMBER */0 : - var raw = Curry._2(Parser_env_Peek.value, undefined, env); - var loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var value = number(env, number_type._0); - var value$1 = { - TAG: /* Number */2, - _0: value - }; - return [ - loc, - { - TAG: /* Literal */0, - _0: [ - loc, - { - value: value$1, - raw: raw - } - ] - } - ]; - case /* T_STRING */1 : - var match = number_type._0; - var octal = match[3]; - var raw$1 = match[2]; - var value$2 = match[1]; - var loc$1 = match[0]; - if (octal) { - strict_error(env, /* StrictOctalLiteral */31); - } - token$4(env, { - TAG: /* T_STRING */1, - _0: [ - loc$1, - value$2, - raw$1, - octal - ] - }); - var value$3 = { - TAG: /* String */0, - _0: value$2 - }; - return [ - loc$1, - { - TAG: /* Literal */0, - _0: [ - loc$1, - { - value: value$3, - raw: raw$1 - } - ] - } - ]; - default: - - } - } - var match$1 = identifier_or_reserved_keyword(env); - var id = match$1[0]; - return [ - id[0], - { - TAG: /* Identifier */1, - _0: id - } - ]; -} - -function _method(env, kind) { - var generator$1 = generator(env, false); - var match = key(env); - var typeParameters = kind ? undefined : Curry._1(type_parameter_declaration$1, env); - token$4(env, /* T_LPAREN */3); - var params; - switch (kind) { - case /* Init */0 : - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 1954, - 16 - ], - Error: new Error() - }; - case /* Get */1 : - params = /* [] */0; - break; - case /* Set */2 : - var param = Curry._2(Parse.identifier_with_type, env, /* StrictParamName */28); - params = { - hd: [ - param[0], - { - TAG: /* Identifier */3, - _0: param - } - ], - tl: /* [] */0 - }; - break; - - } - token$4(env, /* T_RPAREN */4); - var returnType = wrap(annotation_opt, env); - var match$1 = function_body(env, false, generator$1); - var body = match$1[1]; - var simple = is_simple_function_params(params, /* [] */0, undefined); - strict_post_check(env, match$1[2], simple, undefined, params); - var match$2; - match$2 = body.TAG === /* BodyBlock */0 ? [ - body._0[0], - false - ] : [ - body._0[0], - true - ]; - var value_0 = match$2[0]; - var value_1 = { - id: undefined, - params: params, - defaults: /* [] */0, - rest: undefined, - body: body, - async: false, - generator: generator$1, - predicate: undefined, - expression: match$2[1], - returnType: returnType, - typeParameters: typeParameters - }; - var value = [ - value_0, - value_1 - ]; - return [ - match[1], - value - ]; -} - -function property$1(env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_ELLIPSIS */11)) { - token$4(env, /* T_ELLIPSIS */11); - var argument = Curry._1(Parse.assignment, env); - return { - TAG: /* SpreadProperty */1, - _0: [ - btwn(start_loc, argument[0]), - { - argument: argument - } - ] - }; - } - var async = Curry._2(Parser_env_Peek.is_identifier, 1, env) && maybe(env, /* T_ASYNC */61); - var match = generator(env, async); - var match$1 = key(env); - var tmp; - var exit = 0; - if (async || match) { - exit = 1; - } else { - var key$1 = match$1[1]; - switch (key$1.TAG | 0) { - case /* Identifier */1 : - switch (key$1._0[1].name) { - case "get" : - var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); - tmp = typeof match$2 === "number" ? ( - match$2 > 77 || match$2 < 3 ? ( - match$2 !== 89 ? get(env, start_loc) : init(env, start_loc, key$1, false, false) - ) : ( - match$2 > 76 || match$2 < 4 ? init(env, start_loc, key$1, false, false) : get(env, start_loc) - ) - ) : get(env, start_loc); - break; - case "set" : - var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); - tmp = typeof match$3 === "number" ? ( - match$3 > 77 || match$3 < 3 ? ( - match$3 !== 89 ? set(env, start_loc) : init(env, start_loc, key$1, false, false) - ) : ( - match$3 > 76 || match$3 < 4 ? init(env, start_loc, key$1, false, false) : set(env, start_loc) - ) - ) : set(env, start_loc); - break; - default: - exit = 1; - } - break; - case /* Literal */0 : - case /* Computed */2 : - exit = 1; - break; - - } - } - if (exit === 1) { - tmp = init(env, start_loc, match$1[1], async, match); - } - return { - TAG: /* Property */0, - _0: tmp - }; -} - -function get(env, start_loc) { - var match = _method(env, /* Get */1); - var match$1 = match[1]; - var end_loc = match$1[0]; - var value_1 = { - TAG: /* Function */2, - _0: match$1[1] - }; - var value = [ - end_loc, - value_1 - ]; - return [ - btwn(start_loc, end_loc), - { - key: match[0], - value: value, - kind: /* Get */1, - _method: false, - shorthand: false - } - ]; -} - -function set(env, start_loc) { - var match = _method(env, /* Set */2); - var match$1 = match[1]; - var end_loc = match$1[0]; - var value_1 = { - TAG: /* Function */2, - _0: match$1[1] - }; - var value = [ - end_loc, - value_1 - ]; - return [ - btwn(start_loc, end_loc), - { - key: match[0], - value: value, - kind: /* Set */2, - _method: false, - shorthand: false - } - ]; -} - -function init(env, start_loc, key, async, generator) { - var match = Curry._2(Parser_env_Peek.token, undefined, env); - var match$1; - var exit = 0; - if (typeof match === "number") { - if (match !== 89) { - if (match >= 9) { - exit = 1; - } else { - switch (match) { - case /* T_LPAREN */3 : - exit = 3; - break; - case /* T_IDENTIFIER */0 : - case /* T_LCURLY */1 : - case /* T_RPAREN */4 : - case /* T_LBRACKET */5 : - case /* T_RBRACKET */6 : - case /* T_SEMICOLON */7 : - exit = 1; - break; - case /* T_RCURLY */2 : - case /* T_COMMA */8 : - exit = 2; - break; - - } - } - } else { - exit = 3; - } - } else { - exit = 1; - } - switch (exit) { - case 1 : - token$4(env, /* T_COLON */77); - match$1 = [ - Curry._1(Parse.assignment, env), - false, - false - ]; - break; - case 2 : - var tmp; - switch (key.TAG | 0) { - case /* Literal */0 : - var lit = key._0; - tmp = [ - lit[0], - { - TAG: /* Literal */19, - _0: lit[1] - } - ]; - break; - case /* Identifier */1 : - var id = key._0; - tmp = [ - id[0], - { - TAG: /* Identifier */18, - _0: id - } - ]; - break; - case /* Computed */2 : - tmp = key._0; - break; - - } - match$1 = [ - tmp, - true, - false - ]; - break; - case 3 : - var typeParameters = Curry._1(type_parameter_declaration$1, env); - var match$2 = function_params(env); - var rest = match$2[2]; - var defaults = match$2[1]; - var params = match$2[0]; - var returnType = wrap(annotation_opt, env); - var match$3 = function_body(env, async, generator); - var body = match$3[1]; - var simple = is_simple_function_params(params, defaults, rest); - strict_post_check(env, match$3[2], simple, undefined, params); - var match$4; - match$4 = body.TAG === /* BodyBlock */0 ? [ - body._0[0], - false - ] : [ - body._0[0], - true - ]; - var value_0 = match$4[0]; - var value_1 = { - TAG: /* Function */2, - _0: { - id: undefined, - params: params, - defaults: defaults, - rest: rest, - body: body, - async: async, - generator: generator, - predicate: undefined, - expression: match$4[1], - returnType: returnType, - typeParameters: typeParameters - } - }; - var value = [ - value_0, - value_1 - ]; - match$1 = [ - value, - false, - true - ]; - break; - + ret = [ + /* Exp */14, + { + TAG: /* Right_assoc */1, + _0: 10 + } + ]; + break; + case /* T_MOD */99 : + ret = [ + /* Mod */16, + { + TAG: /* Left_assoc */0, + _0: 9 + } + ]; + break; + case /* T_NOT */100 : + case /* T_BIT_NOT */101 : + case /* T_INCR */102 : + case /* T_DECR */103 : + case /* T_ERROR */104 : + case /* T_EOF */105 : + case /* T_JSX_IDENTIFIER */106 : + case /* T_ANY_TYPE */107 : + case /* T_BOOLEAN_TYPE */108 : + case /* T_NUMBER_TYPE */109 : + case /* T_STRING_TYPE */110 : + case /* T_VOID_TYPE */111 : + ret = undefined; + break; + + } + } else { + ret = undefined; + } + } else { + ret = undefined; } - var value$1 = match$1[0]; + if (ret !== undefined) { + token$3(env); + } + return ret; +} + +function make_binary(left, right, operator, loc) { return [ - btwn(start_loc, value$1[0]), + loc, { - key: key, - value: value$1, - kind: /* Init */0, - _method: match$1[2], - shorthand: match$1[1] + TAG: /* Binary */6, + _0: { + operator: operator, + left: left, + right: right + } } ]; } -function check_property(env, prop_map, prop) { - if (prop.TAG !== /* Property */0) { - return prop_map; - } - var match = prop._0; - var prop$1 = match[1]; - var prop_loc = match[0]; - var exit = 0; - switch (prop$1.key.TAG | 0) { - case /* Literal */0 : - case /* Identifier */1 : - exit = 1; - break; - case /* Computed */2 : - return prop_map; - - } - if (exit === 1) { - var match$1 = prop$1.key; - var key; - switch (match$1.TAG | 0) { - case /* Literal */0 : - var s = match$1._0[1].value; - if (typeof s === "number") { - key = "null"; - } else { - switch (s.TAG | 0) { - case /* String */0 : - key = s._0; - break; - case /* Boolean */1 : - var b = s._0; - key = b ? "true" : "false"; - break; - case /* Number */2 : - key = Stdlib.string_of_float(s._0); - break; - case /* RegExp */3 : - throw { - RE_EXN_ID: "Failure", - _1: "RegExp cannot be property key", - Error: new Error() - }; - - } - } - break; - case /* Identifier */1 : - key = match$1._0[1].name; - break; - case /* Computed */2 : - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 2103, - 30 - ], - Error: new Error() - }; +function add_to_stack(_right, _param, _rloc, _stack) { + while(true) { + var param = _param; + var stack = _stack; + var rloc = _rloc; + var right = _right; + var rpri = param[1]; + var rop = param[0]; + if (stack) { + var match = stack.hd; + var match$1 = match[1]; + if (is_tighter(match$1[1], rpri)) { + var loc = btwn(match[2], rloc); + var right$1 = make_binary(match[0], right, match$1[0], loc); + _stack = stack.tl; + _rloc = loc; + _param = [ + rop, + rpri + ]; + _right = right$1; + continue ; + } } - var prev_kinds; - try { - prev_kinds = Curry._2(find, key, prop_map); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === Stdlib.Not_found) { - prev_kinds = /* Empty */0; - } else { - throw exn; + return { + hd: [ + right, + [ + rop, + rpri + ], + rloc + ], + tl: stack + }; + }; +} + +function binary(env) { + var _stack = /* [] */0; + while(true) { + var stack = _stack; + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var is_unary = peek_unary_op(env) !== undefined; + var right = unary(with_no_in(false, env)); + var loc = env.last_loc.contents; + var end_loc = loc !== undefined ? loc : right[0]; + var right_loc = btwn(start_loc, end_loc); + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_LESS_THAN */89)) { + var tmp = right[1]; + if (typeof tmp !== "number" && tmp.TAG === /* JSXElement */22) { + error$1(env, /* AdjacentJSXElements */46); } - } - var match$2 = prop$1.kind; - var kind_string; - switch (match$2) { - case /* Init */0 : - kind_string = "Init"; - break; - case /* Get */1 : - kind_string = "Get"; - break; - case /* Set */2 : - kind_string = "Set"; - break; } - var exit$1 = 0; - switch (kind_string) { - case "Init" : - if (Curry._2(mem$1, "Init", prev_kinds)) { - strict_error_at(env, [ - prop_loc, - /* StrictDuplicateProperty */33 - ]); - } else if (Curry._2(mem$1, "Set", prev_kinds) || Curry._2(mem$1, "Get", prev_kinds)) { - error_at(env, [ - prop_loc, - /* AccessorDataProperty */34 - ]); - } - break; - case "Get" : - case "Set" : - exit$1 = 2; - break; - default: - + var match = binary_op(env); + if (match === undefined) { + var _right = right; + var _rloc = right_loc; + var _param = stack; + while(true) { + var param = _param; + var rloc = _rloc; + var right$1 = _right; + if (!param) { + return right$1; + } + var match$1 = param.hd; + var loc$1 = btwn(match$1[2], rloc); + _param = param.tl; + _rloc = loc$1; + _right = make_binary(match$1[0], right$1, match$1[1][0], loc$1); + continue ; + }; } - if (exit$1 === 2) { - if (Curry._2(mem$1, "Init", prev_kinds)) { - error_at(env, [ - prop_loc, - /* AccessorDataProperty */34 - ]); - } else if (Curry._2(mem$1, kind_string, prev_kinds)) { - error_at(env, [ - prop_loc, - /* AccessorGetSet */35 - ]); - } - + var rop = match[0]; + if (is_unary && rop === /* Exp */14) { + error_at(env, [ + right_loc, + /* InvalidLHSInExponentiation */15 + ]); } - var kinds = Curry._2(add$1, kind_string, prev_kinds); - return Curry._3(add$2, key, kinds, prop_map); + _stack = add_to_stack(right, [ + rop, + match[1] + ], right_loc, stack); + continue ; + }; +} + +function argument(env) { + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (match !== 11) { + return { + TAG: /* Expression */0, + _0: Curry._1(assignment, env) + }; } - + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_ELLIPSIS */11); + var argument$1 = Curry._1(assignment, env); + var loc = btwn(start_loc, argument$1[0]); + return { + TAG: /* Spread */1, + _0: [ + loc, + { + argument: argument$1 + } + ] + }; } -function properties$1(env, _param) { +function arguments$p(env, _acc) { while(true) { - var param = _param; - var acc = param[1]; + var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); if (typeof match === "number") { - if (match === 2) { + if (match === 4) { return Stdlib__List.rev(acc); } if (match === 105) { @@ -11005,1024 +10055,1600 @@ function properties$1(env, _param) { } } - var prop = property$1(env); - var prop_map = check_property(env, param[0], prop); - if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RCURLY */2)) { + var acc_0 = argument(env); + var acc$1 = { + hd: acc_0, + tl: acc + }; + if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RPAREN */4)) { token$4(env, /* T_COMMA */8); } - _param = [ - prop_map, - { - hd: prop, - tl: acc + _acc = acc$1; + continue ; + }; +} + +function $$arguments(env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_LPAREN */3); + var args = arguments$p(env, /* [] */0); + var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_RPAREN */4); + return [ + btwn(start_loc, end_loc), + args + ]; +} + +function template_parts(env, _quasis, _expressions) { + while(true) { + var expressions = _expressions; + var quasis = _quasis; + var expr = Curry._1(Parse.expression, env); + var expressions$1 = { + hd: expr, + tl: expressions + }; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (match === 2) { + push_lex_mode(env, /* TEMPLATE */4); + var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); + var match$2; + if (typeof match$1 === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 1602, + 19 + ], + Error: new Error() + }; + } + if (match$1.TAG === /* T_TEMPLATE_PART */2) { + var match$3 = match$1._0; + var tail = match$3[2]; + var match$4 = match$3[1]; + token$3(env); + match$2 = [ + match$3[0], + { + value: { + raw: match$4.raw, + cooked: match$4.cooked + }, + tail: tail + }, + tail + ]; + } else { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 1602, + 19 + ], + Error: new Error() + }; + } + var loc = match$2[0]; + pop_lex_mode(env); + var quasis_0 = [ + loc, + match$2[1] + ]; + var quasis$1 = { + hd: quasis_0, + tl: quasis + }; + if (match$2[2]) { + return [ + loc, + Stdlib__List.rev(quasis$1), + Stdlib__List.rev(expressions$1) + ]; } + _expressions = expressions$1; + _quasis = quasis$1; + continue ; + } + error_unexpected(env); + var imaginary_quasi_0 = expr[0]; + var imaginary_quasi_1 = { + value: { + raw: "", + cooked: "" + }, + tail: true + }; + var imaginary_quasi = [ + imaginary_quasi_0, + imaginary_quasi_1 ]; + return [ + expr[0], + Stdlib__List.rev({ + hd: imaginary_quasi, + tl: quasis + }), + Stdlib__List.rev(expressions$1) + ]; + }; +} + +function template_literal(env, part) { + var is_tail = part[2]; + var match = part[1]; + var start_loc = part[0]; + token$4(env, { + TAG: /* T_TEMPLATE_PART */2, + _0: part + }); + var head_1 = { + value: { + raw: match.raw, + cooked: match.cooked + }, + tail: is_tail + }; + var head = [ + start_loc, + head_1 + ]; + var match$1 = is_tail ? [ + start_loc, + { + hd: head, + tl: /* [] */0 + }, + /* [] */0 + ] : template_parts(env, { + hd: head, + tl: /* [] */0 + }, /* [] */0); + var loc = btwn(start_loc, match$1[0]); + return [ + loc, + { + quasis: match$1[1], + expressions: match$1[2] + } + ]; +} + +function elements(env, _acc) { + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "number") { + if (match === 105) { + return Stdlib__List.rev(acc); + } + if (match < 12) { + switch (match) { + case /* T_RBRACKET */6 : + return Stdlib__List.rev(acc); + case /* T_COMMA */8 : + token$4(env, /* T_COMMA */8); + _acc = { + hd: undefined, + tl: acc + }; + continue ; + case /* T_IDENTIFIER */0 : + case /* T_LCURLY */1 : + case /* T_RCURLY */2 : + case /* T_LPAREN */3 : + case /* T_RPAREN */4 : + case /* T_LBRACKET */5 : + case /* T_SEMICOLON */7 : + case /* T_PERIOD */9 : + case /* T_ARROW */10 : + break; + case /* T_ELLIPSIS */11 : + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_ELLIPSIS */11); + var argument = Curry._1(assignment, env); + var loc = btwn(start_loc, argument[0]); + var elem = { + TAG: /* Spread */1, + _0: [ + loc, + { + argument: argument + } + ] + }; + _acc = { + hd: elem, + tl: acc + }; + continue ; + + } + } + + } + var elem$1 = { + TAG: /* Expression */0, + _0: Curry._1(assignment, env) + }; + if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RBRACKET */6)) { + token$4(env, /* T_COMMA */8); + } + _acc = { + hd: elem$1, + tl: acc + }; continue ; }; } -function _initializer(env) { +function array_initializer(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_LCURLY */1); - var props = properties$1(env, [ - /* Empty */0, - /* [] */0 - ]); + token$4(env, /* T_LBRACKET */5); + var elements$1 = elements(env, /* [] */0); var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_RCURLY */2); + token$4(env, /* T_RBRACKET */6); return [ btwn(start_loc, end_loc), { - properties: props + elements: elements$1 } ]; } -function class_implements(env, _acc) { - while(true) { - var acc = _acc; - var id = Curry._2(Parse.identifier, undefined, env); - var typeParameters = wrap(type_parameter_instantiation, env); - var loc = typeParameters !== undefined ? btwn(id[0], typeParameters[0]) : id[0]; - var implement_1 = { - id: id, - typeParameters: typeParameters +function error_callback$1(param) { + return function (param) { + if (typeof param === "number") { + if (param > 44 || param < 28) { + if (param === 47) { + return ; + } + throw { + RE_EXN_ID: Parser_env_Try.Rollback, + Error: new Error() + }; + } + if (param > 43 || param < 29) { + return ; + } + throw { + RE_EXN_ID: Parser_env_Try.Rollback, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Parser_env_Try.Rollback, + Error: new Error() + }; + }; +} + +function try_arrow_function(env) { + var env$1 = with_error_callback(error_callback$1, env); + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env$1); + var async = Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, 1, env$1), /* T_ARROW */10) && maybe(env$1, /* T_ASYNC */61); + var typeParameters = Curry._1(type_parameter_declaration$1, env$1); + var match; + if (Curry._2(Parser_env_Peek.is_identifier, undefined, env$1) && typeParameters === undefined) { + var id = Curry._2(Parse.identifier, /* StrictParamName */28, env$1); + var param_0 = id[0]; + var param_1 = { + TAG: /* Identifier */3, + _0: id }; - var implement = [ - loc, - implement_1 + var param = [ + param_0, + param_1 ]; - var acc$1 = { - hd: implement, - tl: acc - }; + match = [ + { + hd: param, + tl: /* [] */0 + }, + /* [] */0, + undefined, + undefined + ]; + } else { + var match$1 = function_params(env$1); + match = [ + match$1[0], + match$1[1], + match$1[2], + wrap(annotation_opt, env$1) + ]; + } + var rest = match[2]; + var defaults = match[1]; + var params = match[0]; + var predicate = Curry._1(Parse.predicate, env$1); + var env$2 = Caml_obj.caml_equal(params, /* [] */0) || rest !== undefined ? without_error_callback(env$1) : env$1; + if (Curry._1(Parser_env_Peek.is_line_terminator, env$2) && Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env$2), /* T_ARROW */10)) { + error$1(env$2, /* NewlineBeforeArrow */44); + } + token$4(env$2, /* T_ARROW */10); + var env$3 = without_error_callback(env$2); + var match$2 = with_loc((function (param) { + var generator = false; + var env = with_in_function(true, param); + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (match === 1) { + var match$1 = function_body(env, async, generator); + return [ + match$1[1], + match$1[2] + ]; + } + var env$1 = enter_function(env, async, generator); + var expr = Curry._1(Parse.assignment, env$1); + return [ + { + TAG: /* BodyExpression */1, + _0: expr + }, + env$1.in_strict_mode + ]; + }), env$3); + var match$3 = match$2[1]; + var body = match$3[0]; + var simple = is_simple_function_params(params, defaults, rest); + strict_post_check(env$3, match$3[1], simple, undefined, params); + var expression; + expression = body.TAG === /* BodyBlock */0 ? false : true; + var loc = btwn(start_loc, match$2[0]); + return [ + loc, + { + TAG: /* ArrowFunction */3, + _0: { + id: undefined, + params: params, + defaults: defaults, + rest: rest, + body: body, + async: async, + generator: false, + predicate: predicate, + expression: expression, + returnType: match[3], + typeParameters: typeParameters + } + } + ]; +} + +function decorator_list_helper(env, _decorators) { + while(true) { + var decorators = _decorators; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (match !== 8) { - return Stdlib__List.rev(acc$1); + if (match !== 12) { + return decorators; + } + token$3(env); + _decorators = { + hd: left_hand_side(env), + tl: decorators + }; + continue ; + }; +} + +function decorator_list(env) { + if (env.parse_options.esproposal_decorators) { + return Stdlib__List.rev(decorator_list_helper(env, /* [] */0)); + } else { + return /* [] */0; + } +} + +function key(env) { + var number_type = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof number_type === "number") { + if (number_type === /* T_LBRACKET */5) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_LBRACKET */5); + var expr = Curry._1(Parse.assignment, with_no_in(false, env)); + var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_RBRACKET */6); + return [ + btwn(start_loc, end_loc), + { + TAG: /* Computed */2, + _0: expr + } + ]; + } + + } else { + switch (number_type.TAG | 0) { + case /* T_NUMBER */0 : + var raw = Curry._2(Parser_env_Peek.value, undefined, env); + var loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var value = number(env, number_type._0); + var value$1 = { + TAG: /* Number */2, + _0: value + }; + return [ + loc, + { + TAG: /* Literal */0, + _0: [ + loc, + { + value: value$1, + raw: raw + } + ] + } + ]; + case /* T_STRING */1 : + var match = number_type._0; + var octal = match[3]; + var raw$1 = match[2]; + var value$2 = match[1]; + var loc$1 = match[0]; + if (octal) { + strict_error(env, /* StrictOctalLiteral */31); + } + token$4(env, { + TAG: /* T_STRING */1, + _0: [ + loc$1, + value$2, + raw$1, + octal + ] + }); + var value$3 = { + TAG: /* String */0, + _0: value$2 + }; + return [ + loc$1, + { + TAG: /* Literal */0, + _0: [ + loc$1, + { + value: value$3, + raw: raw$1 + } + ] + } + ]; + default: + } - token$4(env, /* T_COMMA */8); - _acc = acc$1; - continue ; - }; + } + var match$1 = identifier_or_reserved_keyword(env); + var id = match$1[0]; + return [ + id[0], + { + TAG: /* Identifier */1, + _0: id + } + ]; } -function init$1(env, start_loc, decorators, key, async, generator, $$static) { - var match = Curry._2(Parser_env_Peek.token, undefined, env); - var exit = 0; - if (typeof match === "number") { - if (match > 77 || match < 75) { - if (match === 7) { - exit = 2; - } - - } else if (match !== 76) { - exit = 2; - } +function _method(env, kind) { + var generator$1 = generator(env, false); + var match = key(env); + var typeParameters = kind ? undefined : Curry._1(type_parameter_declaration$1, env); + token$4(env, /* T_LPAREN */3); + var params; + switch (kind) { + case /* Init */0 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 1954, + 16 + ], + Error: new Error() + }; + case /* Get */1 : + params = /* [] */0; + break; + case /* Set */2 : + var param = Curry._2(Parse.identifier_with_type, env, /* StrictParamName */28); + params = { + hd: [ + param[0], + { + TAG: /* Identifier */3, + _0: param + } + ], + tl: /* [] */0 + }; + break; } - if (exit === 2 && !async && !generator) { - var typeAnnotation = wrap(annotation_opt, env); - var options = env.parse_options; - var value = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_ASSIGN */75) && ($$static && options.esproposal_class_static_fields || !$$static && options.esproposal_class_instance_fields) ? (token$4(env, /* T_ASSIGN */75), Curry._1(Parse.expression, env)) : undefined; - var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (maybe(env, /* T_SEMICOLON */7) || !(Curry._2(Parser_env_Peek.token, undefined, env) === /* T_LBRACKET */5 || Curry._2(Parser_env_Peek.token, undefined, env) === /* T_LPAREN */3)) { - - } else { - error_unexpected(env); - } - var loc = btwn(start_loc, end_loc); - return { - TAG: /* Property */1, - _0: [ - loc, - { - key: key, - value: value, - typeAnnotation: typeAnnotation, - static: $$static - } - ] - }; - } - var typeParameters = Curry._1(type_parameter_declaration$1, env); - var match$1 = function_params(env); - var rest = match$1[2]; - var defaults = match$1[1]; - var params = match$1[0]; + token$4(env, /* T_RPAREN */4); var returnType = wrap(annotation_opt, env); - var match$2 = function_body(env, async, generator); - var body = match$2[1]; - var simple = is_simple_function_params(params, defaults, rest); - strict_post_check(env, match$2[2], simple, undefined, params); - var match$3; - match$3 = body.TAG === /* BodyBlock */0 ? [ + var match$1 = function_body(env, false, generator$1); + var body = match$1[1]; + var simple = is_simple_function_params(params, /* [] */0, undefined); + strict_post_check(env, match$1[2], simple, undefined, params); + var match$2; + match$2 = body.TAG === /* BodyBlock */0 ? [ body._0[0], false ] : [ body._0[0], true ]; - var end_loc$1 = match$3[0]; + var value_0 = match$2[0]; var value_1 = { id: undefined, params: params, - defaults: defaults, - rest: rest, + defaults: /* [] */0, + rest: undefined, body: body, - async: async, - generator: generator, + async: false, + generator: generator$1, predicate: undefined, - expression: match$3[1], + expression: match$2[1], returnType: returnType, typeParameters: typeParameters }; - var value$1 = [ - end_loc$1, + var value = [ + value_0, value_1 ]; - var kind; - switch (key.TAG | 0) { - case /* Literal */0 : - var match$4 = key._0[1].value; - kind = typeof match$4 === "number" || !(match$4.TAG === /* String */0 && match$4._0 === "constructor") ? /* Method */1 : /* Constructor */0; - break; - case /* Identifier */1 : - kind = key._0[1].name === "constructor" ? /* Constructor */0 : /* Method */1; - break; - case /* Computed */2 : - kind = /* Method */1; - break; - - } - return { - TAG: /* Method */0, - _0: [ - btwn(start_loc, end_loc$1), - { - kind: kind, - key: key, - value: value$1, - static: $$static, - decorators: decorators - } - ] - }; + return [ + match[1], + value + ]; } -function class_element(env) { +function property$1(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var decorators = decorator_list(env); - var $$static = maybe(env, /* T_STATIC */40); - var async = Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, 1, env), /* T_LPAREN */3) && Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, 1, env), /* T_COLON */77) && maybe(env, /* T_ASYNC */61); - var generator$1 = generator(env, async); - var match = key(env); - if (!async && !generator$1) { - var key$1 = match[1]; + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_ELLIPSIS */11)) { + token$4(env, /* T_ELLIPSIS */11); + var argument = Curry._1(Parse.assignment, env); + return { + TAG: /* SpreadProperty */1, + _0: [ + btwn(start_loc, argument[0]), + { + argument: argument + } + ] + }; + } + var async = Curry._2(Parser_env_Peek.is_identifier, 1, env) && maybe(env, /* T_ASYNC */61); + var match = generator(env, async); + var match$1 = key(env); + var tmp; + var exit = 0; + if (async || match) { + exit = 1; + } else { + var key$1 = match$1[1]; switch (key$1.TAG | 0) { case /* Identifier */1 : switch (key$1._0[1].name) { case "get" : - var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); - var exit = 0; - exit = typeof match$1 === "number" ? ( - match$1 >= 75 ? ( - match$1 >= 78 ? ( - match$1 !== 89 ? 2 : 3 - ) : ( - match$1 !== 76 ? 3 : 2 - ) + var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); + tmp = typeof match$2 === "number" ? ( + match$2 > 77 || match$2 < 3 ? ( + match$2 !== 89 ? get(env, start_loc) : init(env, start_loc, key$1, false, false) ) : ( - match$1 !== 3 && match$1 !== 7 ? 2 : 3 + match$2 > 76 || match$2 < 4 ? init(env, start_loc, key$1, false, false) : get(env, start_loc) ) - ) : 2; - switch (exit) { - case 2 : - var match$2 = _method(env, /* Get */1); - var value = match$2[1]; - return { - TAG: /* Method */0, - _0: [ - btwn(start_loc, value[0]), - { - kind: /* Get */2, - key: match$2[0], - value: value, - static: $$static, - decorators: decorators - } - ] - }; - case 3 : - return init$1(env, start_loc, decorators, key$1, async, generator$1, $$static); - - } + ) : get(env, start_loc); break; case "set" : var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); - var exit$1 = 0; - exit$1 = typeof match$3 === "number" ? ( - match$3 >= 75 ? ( - match$3 >= 78 ? ( - match$3 !== 89 ? 2 : 3 - ) : ( - match$3 !== 76 ? 3 : 2 - ) - ) : ( - match$3 !== 3 && match$3 !== 7 ? 2 : 3 - ) - ) : 2; - switch (exit$1) { - case 2 : - var match$4 = _method(env, /* Set */2); - var value$1 = match$4[1]; - return { - TAG: /* Method */0, - _0: [ - btwn(start_loc, value$1[0]), - { - kind: /* Set */3, - key: match$4[0], - value: value$1, - static: $$static, - decorators: decorators - } - ] - }; - case 3 : - return init$1(env, start_loc, decorators, key$1, async, generator$1, $$static); - - } + tmp = typeof match$3 === "number" ? ( + match$3 > 77 || match$3 < 3 ? ( + match$3 !== 89 ? set(env, start_loc) : init(env, start_loc, key$1, false, false) + ) : ( + match$3 > 76 || match$3 < 4 ? init(env, start_loc, key$1, false, false) : set(env, start_loc) + ) + ) : set(env, start_loc); break; default: - + exit = 1; } break; case /* Literal */0 : case /* Computed */2 : + exit = 1; break; } } - return init$1(env, start_loc, decorators, match[1], async, generator$1, $$static); + if (exit === 1) { + tmp = init(env, start_loc, match$1[1], async, match); + } + return { + TAG: /* Property */0, + _0: tmp + }; } -function elements$1(env, _acc) { - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number") { - if (match > 104 || match < 3) { - if (!(match > 105 || match < 2)) { - return Stdlib__List.rev(acc); - } - - } else if (match === 7) { - token$4(env, /* T_SEMICOLON */7); - continue ; - } - - } - _acc = { - hd: Curry._1(class_element, env), - tl: acc - }; - continue ; +function get(env, start_loc) { + var match = _method(env, /* Get */1); + var match$1 = match[1]; + var end_loc = match$1[0]; + var value_1 = { + TAG: /* Function */2, + _0: match$1[1] }; + var value = [ + end_loc, + value_1 + ]; + return [ + btwn(start_loc, end_loc), + { + key: match[0], + value: value, + kind: /* Get */1, + _method: false, + shorthand: false + } + ]; } -function class_body(env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_LCURLY */1); - var body = elements$1(env, /* [] */0); - var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_RCURLY */2); +function set(env, start_loc) { + var match = _method(env, /* Set */2); + var match$1 = match[1]; + var end_loc = match$1[0]; + var value_1 = { + TAG: /* Function */2, + _0: match$1[1] + }; + var value = [ + end_loc, + value_1 + ]; return [ btwn(start_loc, end_loc), { - body: body + key: match[0], + value: value, + kind: /* Set */2, + _method: false, + shorthand: false } ]; } -function _class(env) { - var match; - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_EXTENDS */39)) { - token$4(env, /* T_EXTENDS */39); - var superClass = left_hand_side(with_allow_yield(false, env)); - var superTypeParameters = wrap(type_parameter_instantiation, env); - match = [ - superClass, - superTypeParameters - ]; +function init(env, start_loc, key, async, generator) { + var match = Curry._2(Parser_env_Peek.token, undefined, env); + var match$1; + var exit = 0; + if (typeof match === "number") { + if (match !== 89) { + if (match >= 9) { + exit = 1; + } else { + switch (match) { + case /* T_LPAREN */3 : + exit = 3; + break; + case /* T_IDENTIFIER */0 : + case /* T_LCURLY */1 : + case /* T_RPAREN */4 : + case /* T_LBRACKET */5 : + case /* T_RBRACKET */6 : + case /* T_SEMICOLON */7 : + exit = 1; + break; + case /* T_RCURLY */2 : + case /* T_COMMA */8 : + exit = 2; + break; + + } + } + } else { + exit = 3; + } } else { - match = [ - undefined, - undefined - ]; + exit = 1; } - var $$implements = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_IMPLEMENTS */50) ? (!env.parse_options.types ? error$1(env, /* UnexpectedTypeInterface */10) : undefined, token$4(env, /* T_IMPLEMENTS */50), class_implements(env, /* [] */0)) : /* [] */0; - var body = Curry._1(class_body, env); - return [ - body, - match[0], - match[1], - $$implements + switch (exit) { + case 1 : + token$4(env, /* T_COLON */77); + match$1 = [ + Curry._1(Parse.assignment, env), + false, + false ]; -} - -function class_declaration(env, decorators) { - var env$1 = with_strict(true, env); - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env$1); - var decorators$1 = Stdlib.$at(decorators, decorator_list(env$1)); - token$4(env$1, /* T_CLASS */38); - var tmp_env = with_no_let(true, env$1); - var match = env$1.in_export; - var match$1 = Curry._2(Parser_env_Peek.is_identifier, undefined, tmp_env); - var id = match && !match$1 ? undefined : Curry._2(Parse.identifier, undefined, tmp_env); - var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env$1); - var match$2 = _class(env$1); - var body = match$2[0]; - var loc = btwn(start_loc, body[0]); + break; + case 2 : + var tmp; + switch (key.TAG | 0) { + case /* Literal */0 : + var lit = key._0; + tmp = [ + lit[0], + { + TAG: /* Literal */19, + _0: lit[1] + } + ]; + break; + case /* Identifier */1 : + var id = key._0; + tmp = [ + id[0], + { + TAG: /* Identifier */18, + _0: id + } + ]; + break; + case /* Computed */2 : + tmp = key._0; + break; + + } + match$1 = [ + tmp, + true, + false + ]; + break; + case 3 : + var typeParameters = Curry._1(type_parameter_declaration$1, env); + var match$2 = function_params(env); + var rest = match$2[2]; + var defaults = match$2[1]; + var params = match$2[0]; + var returnType = wrap(annotation_opt, env); + var match$3 = function_body(env, async, generator); + var body = match$3[1]; + var simple = is_simple_function_params(params, defaults, rest); + strict_post_check(env, match$3[2], simple, undefined, params); + var match$4; + match$4 = body.TAG === /* BodyBlock */0 ? [ + body._0[0], + false + ] : [ + body._0[0], + true + ]; + var value_0 = match$4[0]; + var value_1 = { + TAG: /* Function */2, + _0: { + id: undefined, + params: params, + defaults: defaults, + rest: rest, + body: body, + async: async, + generator: generator, + predicate: undefined, + expression: match$4[1], + returnType: returnType, + typeParameters: typeParameters + } + }; + var value = [ + value_0, + value_1 + ]; + match$1 = [ + value, + false, + true + ]; + break; + + } + var value$1 = match$1[0]; return [ - loc, + btwn(start_loc, value$1[0]), { - TAG: /* ClassDeclaration */20, - _0: { - id: id, - body: body, - superClass: match$2[1], - typeParameters: typeParameters, - superTypeParameters: match$2[2], - implements: match$2[3], - classDecorators: decorators$1 - } + key: key, + value: value$1, + kind: /* Init */0, + _method: match$1[2], + shorthand: match$1[1] } ]; } -function class_expression(env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var decorators = decorator_list(env); - token$4(env, /* T_CLASS */38); - var match = Curry._2(Parser_env_Peek.token, undefined, env); - var match$1; +function check_property(env, prop_map, prop) { + if (prop.TAG !== /* Property */0) { + return prop_map; + } + var match = prop._0; + var prop$1 = match[1]; + var prop_loc = match[0]; var exit = 0; - if (typeof match === "number") { - if (match > 39 || match < 1) { - if (match !== 89) { + switch (prop$1.key.TAG | 0) { + case /* Literal */0 : + case /* Identifier */1 : exit = 1; - } else { - match$1 = [ - undefined, - undefined - ]; - } - } else if (match > 38 || match < 2) { - match$1 = [ - undefined, - undefined - ]; - } else { - exit = 1; - } - } else { - exit = 1; + break; + case /* Computed */2 : + return prop_map; + } if (exit === 1) { - var id = Curry._2(Parse.identifier, undefined, env); - var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); - match$1 = [ - id, - typeParameters - ]; - } - var match$2 = _class(env); - var body = match$2[0]; - var loc = btwn(start_loc, body[0]); - return [ - loc, - { - TAG: /* Class */23, - _0: { - id: match$1[0], - body: body, - superClass: match$2[1], - typeParameters: match$1[1], - superTypeParameters: match$2[2], - implements: match$2[3], - classDecorators: decorators + var match$1 = prop$1.key; + var key; + switch (match$1.TAG | 0) { + case /* Literal */0 : + var s = match$1._0[1].value; + if (typeof s === "number") { + key = "null"; + } else { + switch (s.TAG | 0) { + case /* String */0 : + key = s._0; + break; + case /* Boolean */1 : + var b = s._0; + key = b ? "true" : "false"; + break; + case /* Number */2 : + key = Stdlib.string_of_float(s._0); + break; + case /* RegExp */3 : + throw { + RE_EXN_ID: "Failure", + _1: "RegExp cannot be property key", + Error: new Error() + }; + } } - ]; -} - -function declare_var(env, start_loc) { - token$4(env, /* T_VAR */22); - var id = Curry._2(Parse.identifier_with_type, env, /* StrictVarName */27); - var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc = loc !== undefined ? loc : id[0]; - var loc$1 = btwn(start_loc, end_loc); - semicolon(env); - return [ - loc$1, - { - id: id + break; + case /* Identifier */1 : + key = match$1._0[1].name; + break; + case /* Computed */2 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 2103, + 30 + ], + Error: new Error() + }; + + } + var prev_kinds; + try { + prev_kinds = Curry._2(find, key, prop_map); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + prev_kinds = /* Empty */0; + } else { + throw exn; + } + } + var match$2 = prop$1.kind; + var kind_string; + switch (match$2) { + case /* Init */0 : + kind_string = "Init"; + break; + case /* Get */1 : + kind_string = "Get"; + break; + case /* Set */2 : + kind_string = "Set"; + break; + + } + var exit$1 = 0; + switch (kind_string) { + case "Init" : + if (Curry._2(mem$1, "Init", prev_kinds)) { + strict_error_at(env, [ + prop_loc, + /* StrictDuplicateProperty */33 + ]); + } else if (Curry._2(mem$1, "Set", prev_kinds) || Curry._2(mem$1, "Get", prev_kinds)) { + error_at(env, [ + prop_loc, + /* AccessorDataProperty */34 + ]); } - ]; -} - -function extract_ident_name(param) { - return param[1].name; + break; + case "Get" : + case "Set" : + exit$1 = 2; + break; + default: + + } + if (exit$1 === 2) { + if (Curry._2(mem$1, "Init", prev_kinds)) { + error_at(env, [ + prop_loc, + /* AccessorDataProperty */34 + ]); + } else if (Curry._2(mem$1, kind_string, prev_kinds)) { + error_at(env, [ + prop_loc, + /* AccessorGetSet */35 + ]); + } + + } + var kinds = Curry._2(add$1, kind_string, prev_kinds); + return Curry._3(add$2, key, kinds, prop_map); + } + } -function export_specifiers_and_errs(env, _specifiers, _errs) { +function properties$1(env, _param) { while(true) { - var errs = _errs; - var specifiers = _specifiers; + var param = _param; + var acc = param[1]; var match = Curry._2(Parser_env_Peek.token, undefined, env); if (typeof match === "number") { if (match === 2) { - return [ - Stdlib__List.rev(specifiers), - Stdlib__List.rev(errs) - ]; + return Stdlib__List.rev(acc); } if (match === 105) { - return [ - Stdlib__List.rev(specifiers), - Stdlib__List.rev(errs) - ]; + return Stdlib__List.rev(acc); } } - var match$1 = Curry._1(Parse.identifier_or_reserved_keyword, env); - var id = match$1[0]; - var match$2; - if (Curry._2(Parser_env_Peek.value, undefined, env) === "as") { - contextual(env, "as"); - var match$3 = Curry._1(Parse.identifier_or_reserved_keyword, env); - var name = match$3[0]; - record_export(env, [ - name[0], - extract_ident_name(name) - ]); - match$2 = [ - name, - undefined, - name[0] - ]; - } else { - var loc = id[0]; - record_export(env, [ - loc, - extract_ident_name(id) - ]); - match$2 = [ - undefined, - match$1[1], - loc - ]; - } - var err = match$2[1]; - var loc$1 = btwn(id[0], match$2[2]); - var specifier_1 = { - id: id, - name: match$2[0] - }; - var specifier = [ - loc$1, - specifier_1 - ]; - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_COMMA */8)) { + var prop = property$1(env); + var prop_map = check_property(env, param[0], prop); + if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_RCURLY */2)) { token$4(env, /* T_COMMA */8); - } - var errs$1 = err !== undefined ? ({ - hd: err, - tl: errs - }) : errs; - _errs = errs$1; - _specifiers = { - hd: specifier, - tl: specifiers - }; + } + _param = [ + prop_map, + { + hd: prop, + tl: acc + } + ]; continue ; }; } -function expression(env) { - var expression$1 = Curry._1(Parse.expression, env); - var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc = loc !== undefined ? loc : expression$1[0]; - semicolon(env); +function _initializer(env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_LCURLY */1); + var props = properties$1(env, [ + /* Empty */0, + /* [] */0 + ]); + var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_RCURLY */2); return [ - btwn(expression$1[0], end_loc), + btwn(start_loc, end_loc), { - TAG: /* Expression */1, - _0: { - expression: expression$1 - } + properties: props } ]; } -function declare_function(env, start_loc) { - token$4(env, /* T_FUNCTION */13); - var id = Curry._2(Parse.identifier, undefined, env); - var start_sig_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var typeParameters = Curry._1(type_parameter_declaration$1, env); - var match = wrap(function_param_list, env); - token$4(env, /* T_COLON */77); - var returnType = wrap(_type, env); - var end_loc = returnType[0]; - var loc = btwn(start_sig_loc, end_loc); - var value_1 = { - TAG: /* Function */1, - _0: { - params: match[1], - returnType: returnType, - rest: match[0], +function class_implements(env, _acc) { + while(true) { + var acc = _acc; + var id = Curry._2(Parse.identifier, undefined, env); + var typeParameters = wrap(type_parameter_instantiation, env); + var loc = typeParameters !== undefined ? btwn(id[0], typeParameters[0]) : id[0]; + var implement_1 = { + id: id, typeParameters: typeParameters + }; + var implement = [ + loc, + implement_1 + ]; + var acc$1 = { + hd: implement, + tl: acc + }; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (match !== 8) { + return Stdlib__List.rev(acc$1); } + token$4(env, /* T_COMMA */8); + _acc = acc$1; + continue ; }; - var value = [ - loc, - value_1 - ]; - var typeAnnotation = [ - loc, - value - ]; - var init = id[1]; - var id_0 = btwn(id[0], end_loc); - var id_1 = { - name: init.name, - typeAnnotation: typeAnnotation, - optional: init.optional +} + +function init$1(env, start_loc, decorators, key, async, generator, $$static) { + var match = Curry._2(Parser_env_Peek.token, undefined, env); + var exit = 0; + if (typeof match === "number") { + if (match > 77 || match < 75) { + if (match === 7) { + exit = 2; + } + + } else if (match !== 76) { + exit = 2; + } + + } + if (exit === 2 && !async && !generator) { + var typeAnnotation = wrap(annotation_opt, env); + var options = env.parse_options; + var value = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_ASSIGN */75) && ($$static && options.esproposal_class_static_fields || !$$static && options.esproposal_class_instance_fields) ? (token$4(env, /* T_ASSIGN */75), Curry._1(Parse.expression, env)) : undefined; + var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + if (maybe(env, /* T_SEMICOLON */7) || !(Curry._2(Parser_env_Peek.token, undefined, env) === /* T_LBRACKET */5 || Curry._2(Parser_env_Peek.token, undefined, env) === /* T_LPAREN */3)) { + + } else { + error_unexpected(env); + } + var loc = btwn(start_loc, end_loc); + return { + TAG: /* Property */1, + _0: [ + loc, + { + key: key, + value: value, + typeAnnotation: typeAnnotation, + static: $$static + } + ] + }; + } + var typeParameters = Curry._1(type_parameter_declaration$1, env); + var match$1 = function_params(env); + var rest = match$1[2]; + var defaults = match$1[1]; + var params = match$1[0]; + var returnType = wrap(annotation_opt, env); + var match$2 = function_body(env, async, generator); + var body = match$2[1]; + var simple = is_simple_function_params(params, defaults, rest); + strict_post_check(env, match$2[2], simple, undefined, params); + var match$3; + match$3 = body.TAG === /* BodyBlock */0 ? [ + body._0[0], + false + ] : [ + body._0[0], + true + ]; + var end_loc$1 = match$3[0]; + var value_1 = { + id: undefined, + params: params, + defaults: defaults, + rest: rest, + body: body, + async: async, + generator: generator, + predicate: undefined, + expression: match$3[1], + returnType: returnType, + typeParameters: typeParameters }; - var id$1 = [ - id_0, - id_1 + var value$1 = [ + end_loc$1, + value_1 ]; - var end_loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$2 = end_loc$1 !== undefined ? end_loc$1 : end_loc; - var predicate = Curry._1(Parse.predicate, env); - semicolon(env); - var loc$1 = btwn(start_loc, end_loc$2); - return [ - loc$1, - { - id: id$1, - predicate: predicate + var kind; + switch (key.TAG | 0) { + case /* Literal */0 : + var match$4 = key._0[1].value; + kind = typeof match$4 === "number" || !(match$4.TAG === /* String */0 && match$4._0 === "constructor") ? /* Method */1 : /* Constructor */0; + break; + case /* Identifier */1 : + kind = key._0[1].name === "constructor" ? /* Constructor */0 : /* Method */1; + break; + case /* Computed */2 : + kind = /* Method */1; + break; + + } + return { + TAG: /* Method */0, + _0: [ + btwn(start_loc, end_loc$1), + { + kind: kind, + key: key, + value: value$1, + static: $$static, + decorators: decorators + } + ] + }; +} + +function class_element(env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var decorators = decorator_list(env); + var $$static = maybe(env, /* T_STATIC */40); + var async = Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, 1, env), /* T_LPAREN */3) && Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, 1, env), /* T_COLON */77) && maybe(env, /* T_ASYNC */61); + var generator$1 = generator(env, async); + var match = key(env); + if (!async && !generator$1) { + var key$1 = match[1]; + switch (key$1.TAG | 0) { + case /* Identifier */1 : + switch (key$1._0[1].name) { + case "get" : + var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); + var exit = 0; + exit = typeof match$1 === "number" ? ( + match$1 >= 75 ? ( + match$1 >= 78 ? ( + match$1 !== 89 ? 2 : 3 + ) : ( + match$1 !== 76 ? 3 : 2 + ) + ) : ( + match$1 !== 3 && match$1 !== 7 ? 2 : 3 + ) + ) : 2; + switch (exit) { + case 2 : + var match$2 = _method(env, /* Get */1); + var value = match$2[1]; + return { + TAG: /* Method */0, + _0: [ + btwn(start_loc, value[0]), + { + kind: /* Get */2, + key: match$2[0], + value: value, + static: $$static, + decorators: decorators + } + ] + }; + case 3 : + return init$1(env, start_loc, decorators, key$1, async, generator$1, $$static); + + } + break; + case "set" : + var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); + var exit$1 = 0; + exit$1 = typeof match$3 === "number" ? ( + match$3 >= 75 ? ( + match$3 >= 78 ? ( + match$3 !== 89 ? 2 : 3 + ) : ( + match$3 !== 76 ? 3 : 2 + ) + ) : ( + match$3 !== 3 && match$3 !== 7 ? 2 : 3 + ) + ) : 2; + switch (exit$1) { + case 2 : + var match$4 = _method(env, /* Set */2); + var value$1 = match$4[1]; + return { + TAG: /* Method */0, + _0: [ + btwn(start_loc, value$1[0]), + { + kind: /* Set */3, + key: match$4[0], + value: value$1, + static: $$static, + decorators: decorators + } + ] + }; + case 3 : + return init$1(env, start_loc, decorators, key$1, async, generator$1, $$static); + + } + break; + default: + } - ]; + break; + case /* Literal */0 : + case /* Computed */2 : + break; + + } + } + return init$1(env, start_loc, decorators, match[1], async, generator$1, $$static); } -function export_source(env) { - contextual(env, "from"); - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "number" && match.TAG === /* T_STRING */1) { - var match$1 = match._0; - var octal = match$1[3]; - var raw = match$1[2]; - var value = match$1[1]; - var loc = match$1[0]; - if (octal) { - strict_error(env, /* StrictOctalLiteral */31); +function elements$1(env, _acc) { + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "number") { + if (match > 104 || match < 3) { + if (!(match > 105 || match < 2)) { + return Stdlib__List.rev(acc); + } + + } else if (match === 7) { + token$4(env, /* T_SEMICOLON */7); + continue ; + } + } - token$4(env, { - TAG: /* T_STRING */1, - _0: [ - loc, - value, - raw, - octal - ] - }); - var value$1 = { - TAG: /* String */0, - _0: value + _acc = { + hd: Curry._1(class_element, env), + tl: acc }; - return [ - loc, - { - value: value$1, - raw: raw - } - ]; - } - var raw$1 = Curry._2(Parser_env_Peek.value, undefined, env); - var value$2 = { - TAG: /* String */0, - _0: raw$1 - }; - var ret_0 = Curry._2(Parser_env_Peek.loc, undefined, env); - var ret_1 = { - value: value$2, - raw: raw$1 + continue ; }; - var ret = [ - ret_0, - ret_1 - ]; - error_unexpected(env); - return ret; } -function type_alias_helper(env) { +function class_body(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (!env.parse_options.types) { - error$1(env, /* UnexpectedTypeAlias */5); - } - token$4(env, /* T_TYPE */59); - push_lex_mode(env, /* TYPE */1); - var id = Curry._2(Parse.identifier, undefined, env); - var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); - token$4(env, /* T_ASSIGN */75); - var right = wrap(_type, env); - var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$1 = end_loc !== undefined ? end_loc : right[0]; - semicolon(env); - pop_lex_mode(env); + token$4(env, /* T_LCURLY */1); + var body = elements$1(env, /* [] */0); + var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_RCURLY */2); return [ - btwn(start_loc, end_loc$1), + btwn(start_loc, end_loc), { - id: id, - typeParameters: typeParameters, - right: right + body: body } ]; } -function declare_export_declaration(allow_export_typeOpt, env) { - var allow_export_type = allow_export_typeOpt !== undefined ? allow_export_typeOpt : false; - if (!env.parse_options.types) { - error$1(env, /* UnexpectedTypeDeclaration */7); +function _class(env) { + var match; + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_EXTENDS */39)) { + token$4(env, /* T_EXTENDS */39); + var superClass = left_hand_side(with_allow_yield(false, env)); + var superTypeParameters = wrap(type_parameter_instantiation, env); + match = [ + superClass, + superTypeParameters + ]; + } else { + match = [ + undefined, + undefined + ]; } - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_DECLARE */58); - var env$1 = with_in_export(true, with_strict(true, env)); - token$4(env$1, /* T_EXPORT */47); - var match = Curry._2(Parser_env_Peek.token, undefined, env$1); - var exit = 0; - if (typeof match === "number") { - if (match >= 52) { - if (match !== 59) { - if (match !== 97) { - exit = 1; - } else { - var loc = Curry._2(Parser_env_Peek.loc, undefined, env$1); - token$4(env$1, /* T_MULT */97); - var parse_export_star_as = env$1.parse_options.esproposal_export_star_as; - var local_name = Curry._2(Parser_env_Peek.value, undefined, env$1) === "as" ? (contextual(env$1, "as"), parse_export_star_as ? Curry._2(Parse.identifier, undefined, env$1) : (error$1(env$1, /* UnexpectedTypeDeclaration */7), undefined)) : undefined; - var specifiers = { - TAG: /* ExportBatchSpecifier */1, - _0: loc, - _1: local_name - }; - var source = export_source(env$1); - var loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); - var end_loc = loc$1 !== undefined ? loc$1 : source[0]; - var source$1 = source; - semicolon(env$1); - return [ - btwn(start_loc, end_loc), - { - TAG: /* DeclareExportDeclaration */27, - _0: { - default: false, - declaration: undefined, - specifiers: specifiers, - source: source$1 - } - } - ]; - } - } else { - if (allow_export_type) { - var match$1 = type_alias_helper(env$1); - var alias_loc = match$1[0]; - var loc$2 = btwn(start_loc, alias_loc); - return [ - loc$2, - { - TAG: /* DeclareExportDeclaration */27, - _0: { - default: false, - declaration: { - TAG: /* NamedType */4, - _0: [ - alias_loc, - match$1[1] - ] - }, - specifiers: undefined, - source: undefined - } - } - ]; - } - exit = 1; - } - } else if (match >= 39) { - if (match >= 51) { - if (allow_export_type) { - var match$2 = Curry._1(interface_helper, env$1); - var iface_loc = match$2[0]; - var loc$3 = btwn(start_loc, iface_loc); - return [ - loc$3, - { - TAG: /* DeclareExportDeclaration */27, - _0: { - default: false, - declaration: { - TAG: /* Interface */5, - _0: [ - iface_loc, - match$2[1] - ] - }, - specifiers: undefined, - source: undefined - } - } - ]; - } + var $$implements = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_IMPLEMENTS */50) ? (!env.parse_options.types ? error$1(env, /* UnexpectedTypeInterface */10) : undefined, token$4(env, /* T_IMPLEMENTS */50), class_implements(env, /* [] */0)) : /* [] */0; + var body = Curry._1(class_body, env); + return [ + body, + match[0], + match[1], + $$implements + ]; +} + +function class_declaration(env, decorators) { + var env$1 = with_strict(true, env); + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env$1); + var decorators$1 = Stdlib.$at(decorators, decorator_list(env$1)); + token$4(env$1, /* T_CLASS */38); + var tmp_env = with_no_let(true, env$1); + var match = env$1.in_export; + var match$1 = Curry._2(Parser_env_Peek.is_identifier, undefined, tmp_env); + var id = match && !match$1 ? undefined : Curry._2(Parse.identifier, undefined, tmp_env); + var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env$1); + var match$2 = _class(env$1); + var body = match$2[0]; + var loc = btwn(start_loc, body[0]); + return [ + loc, + { + TAG: /* ClassDeclaration */20, + _0: { + id: id, + body: body, + superClass: match$2[1], + typeParameters: typeParameters, + superTypeParameters: match$2[2], + implements: match$2[3], + classDecorators: decorators$1 + } + } + ]; +} + +function class_expression(env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var decorators = decorator_list(env); + token$4(env, /* T_CLASS */38); + var match = Curry._2(Parser_env_Peek.token, undefined, env); + var match$1; + var exit = 0; + if (typeof match === "number") { + if (match > 39 || match < 1) { + if (match !== 89) { exit = 1; } else { - exit = 1; - } - } else if (match >= 13) { - switch (match) { - case /* T_DEFAULT */34 : - token$4(env$1, /* T_DEFAULT */34); - var match$3 = Curry._2(Parser_env_Peek.token, undefined, env$1); - var match$4; - var exit$1 = 0; - if (typeof match$3 === "number") { - if (match$3 !== 13) { - if (match$3 !== 38) { - exit$1 = 3; - } else { - var _class = Curry._2(declare_class, env$1, start_loc); - match$4 = [ - _class[0], - { - TAG: /* Class */2, - _0: _class - } - ]; - } - } else { - var fn = declare_function(env$1, start_loc); - match$4 = [ - fn[0], - { - TAG: /* Function */1, - _0: fn - } - ]; - } - } else { - exit$1 = 3; - } - if (exit$1 === 3) { - var _type$1 = wrap(_type, env$1); - var loc$4 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); - var end_loc$1 = loc$4 !== undefined ? loc$4 : _type$1[0]; - semicolon(env$1); - match$4 = [ - end_loc$1, - { - TAG: /* DefaultType */3, - _0: _type$1 - } - ]; - } - return [ - btwn(start_loc, match$4[0]), - { - TAG: /* DeclareExportDeclaration */27, - _0: { - default: true, - declaration: match$4[1], - specifiers: undefined, - source: undefined - } - } - ]; - case /* T_IF */14 : - case /* T_IN */15 : - case /* T_INSTANCEOF */16 : - case /* T_RETURN */17 : - case /* T_SWITCH */18 : - case /* T_THIS */19 : - case /* T_THROW */20 : - case /* T_TRY */21 : - case /* T_WHILE */23 : - case /* T_WITH */24 : - case /* T_NULL */27 : - case /* T_FALSE */28 : - case /* T_TRUE */29 : - case /* T_BREAK */30 : - case /* T_CASE */31 : - case /* T_CATCH */32 : - case /* T_CONTINUE */33 : - case /* T_DO */35 : - case /* T_FINALLY */36 : - case /* T_FOR */37 : - exit = 1; - break; - case /* T_FUNCTION */13 : - case /* T_VAR */22 : - case /* T_CONST */25 : - case /* T_LET */26 : - case /* T_CLASS */38 : - exit = 2; - break; - + match$1 = [ + undefined, + undefined + ]; } + } else if (match > 38 || match < 2) { + match$1 = [ + undefined, + undefined + ]; } else { exit = 1; } } else { exit = 1; } - switch (exit) { - case 1 : - var match$5 = Curry._2(Parser_env_Peek.token, undefined, env$1); - if (typeof match$5 === "number") { - if (match$5 !== 51) { - if (match$5 !== 59) { - - } else { - error$1(env$1, /* DeclareExportType */52); - } - } else { - error$1(env$1, /* DeclareExportInterface */53); - } - } - token$4(env$1, /* T_LCURLY */1); - var match$6 = export_specifiers_and_errs(env$1, /* [] */0, /* [] */0); - var specifiers$1 = { - TAG: /* ExportSpecifiers */0, - _0: match$6[0] - }; - var end_loc$2 = Curry._2(Parser_env_Peek.loc, undefined, env$1); - token$4(env$1, /* T_RCURLY */2); - var source$2 = Curry._2(Parser_env_Peek.value, undefined, env$1) === "from" ? export_source(env$1) : (Stdlib__List.iter((function (param) { - return error_at(env$1, param); - }), match$6[1]), undefined); - var loc$5 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); - var end_loc$3 = loc$5 !== undefined ? loc$5 : ( - source$2 !== undefined ? source$2[0] : end_loc$2 - ); - semicolon(env$1); - return [ - btwn(start_loc, end_loc$3), - { - TAG: /* DeclareExportDeclaration */27, - _0: { - default: false, - declaration: undefined, - specifiers: specifiers$1, - source: source$2 - } - } - ]; - case 2 : - var token$5 = Curry._2(Parser_env_Peek.token, undefined, env$1); - var match$7; - var exit$2 = 0; - if (typeof token$5 === "number") { - if (token$5 >= 23) { - if (token$5 >= 27) { - if (token$5 !== 38) { - exit$2 = 3; - } else { - var _class$1 = Curry._2(declare_class, env$1, start_loc); - match$7 = [ - _class$1[0], - { - TAG: /* Class */2, - _0: _class$1 - } - ]; - } - } else { - exit$2 = token$5 >= 25 ? 4 : 3; - } - } else if (token$5 !== 13) { - exit$2 = token$5 >= 22 ? 4 : 3; - } else { - var fn$1 = declare_function(env$1, start_loc); - match$7 = [ - fn$1[0], - { - TAG: /* Function */1, - _0: fn$1 - } - ]; - } - } else { - exit$2 = 3; - } - switch (exit$2) { - case 3 : - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 3480, - 17 - ], - Error: new Error() - }; - case 4 : - if (typeof token$5 === "number") { - if (token$5 !== 25) { - if (token$5 !== 26) { - - } else { - error$1(env$1, /* DeclareExportLet */50); - } - } else { - error$1(env$1, /* DeclareExportConst */51); - } - } - var $$var = declare_var(env$1, start_loc); - match$7 = [ - $$var[0], - { - TAG: /* Variable */0, - _0: $$var - } + if (exit === 1) { + var id = Curry._2(Parse.identifier, undefined, env); + var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); + match$1 = [ + id, + typeParameters + ]; + } + var match$2 = _class(env); + var body = match$2[0]; + var loc = btwn(start_loc, body[0]); + return [ + loc, + { + TAG: /* Class */23, + _0: { + id: match$1[0], + body: body, + superClass: match$2[1], + typeParameters: match$1[1], + superTypeParameters: match$2[2], + implements: match$2[3], + classDecorators: decorators + } + } + ]; +} + +function export_source(env) { + contextual(env, "from"); + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match !== "number" && match.TAG === /* T_STRING */1) { + var match$1 = match._0; + var octal = match$1[3]; + var raw = match$1[2]; + var value = match$1[1]; + var loc = match$1[0]; + if (octal) { + strict_error(env, /* StrictOctalLiteral */31); + } + token$4(env, { + TAG: /* T_STRING */1, + _0: [ + loc, + value, + raw, + octal + ] + }); + var value$1 = { + TAG: /* String */0, + _0: value + }; + return [ + loc, + { + value: value$1, + raw: raw + } + ]; + } + var raw$1 = Curry._2(Parser_env_Peek.value, undefined, env); + var value$2 = { + TAG: /* String */0, + _0: raw$1 + }; + var ret_0 = Curry._2(Parser_env_Peek.loc, undefined, env); + var ret_1 = { + value: value$2, + raw: raw$1 + }; + var ret = [ + ret_0, + ret_1 + ]; + error_unexpected(env); + return ret; +} + +function export_specifiers_and_errs(env, _specifiers, _errs) { + while(true) { + var errs = _errs; + var specifiers = _specifiers; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "number") { + if (match === 2) { + return [ + Stdlib__List.rev(specifiers), + Stdlib__List.rev(errs) ]; - break; - - } + } + if (match === 105) { return [ - btwn(start_loc, match$7[0]), - { - TAG: /* DeclareExportDeclaration */27, - _0: { - default: false, - declaration: match$7[1], - specifiers: undefined, - source: undefined - } - } + Stdlib__List.rev(specifiers), + Stdlib__List.rev(errs) ]; - - } + } + + } + var match$1 = Curry._1(Parse.identifier_or_reserved_keyword, env); + var id = match$1[0]; + var match$2; + if (Curry._2(Parser_env_Peek.value, undefined, env) === "as") { + contextual(env, "as"); + var match$3 = Curry._1(Parse.identifier_or_reserved_keyword, env); + var name = match$3[0]; + record_export(env, [ + name[0], + extract_ident_name(name) + ]); + match$2 = [ + name, + undefined, + name[0] + ]; + } else { + var loc = id[0]; + record_export(env, [ + loc, + extract_ident_name(id) + ]); + match$2 = [ + undefined, + match$1[1], + loc + ]; + } + var err = match$2[1]; + var loc$1 = btwn(id[0], match$2[2]); + var specifier_1 = { + id: id, + name: match$2[0] + }; + var specifier = [ + loc$1, + specifier_1 + ]; + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_COMMA */8)) { + token$4(env, /* T_COMMA */8); + } + var errs$1 = err !== undefined ? ({ + hd: err, + tl: errs + }) : errs; + _errs = errs$1; + _specifiers = { + hd: specifier, + tl: specifiers + }; + continue ; + }; } -function $$interface(env) { - if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { - return expression(env); - } - var match = Curry._1(interface_helper, env); +function extract_ident_name(param) { + return param[1].name; +} + +function declare_var(env, start_loc) { + token$4(env, /* T_VAR */22); + var id = Curry._2(Parse.identifier_with_type, env, /* StrictVarName */27); + var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc = loc !== undefined ? loc : id[0]; + var loc$1 = btwn(start_loc, end_loc); + semicolon(env); return [ - match[0], + loc$1, { - TAG: /* InterfaceDeclaration */21, - _0: match[1] + id: id } ]; } -function type_alias(env) { - if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { - return Curry._1(Parse.statement, env); - } - var match = type_alias_helper(env); +function expression(env) { + var expression$1 = Curry._1(Parse.expression, env); + var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc = loc !== undefined ? loc : expression$1[0]; + semicolon(env); return [ - match[0], + btwn(expression$1[0], end_loc), { - TAG: /* TypeAlias */7, - _0: match[1] + TAG: /* Expression */1, + _0: { + expression: expression$1 + } } ]; } -function declare_function_statement(env, start_loc) { - var match = declare_function(env, start_loc); +function type_alias_helper(env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + if (!env.parse_options.types) { + error$1(env, /* UnexpectedTypeAlias */5); + } + token$4(env, /* T_TYPE */59); + push_lex_mode(env, /* TYPE */1); + var id = Curry._2(Parse.identifier, undefined, env); + var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); + token$4(env, /* T_ASSIGN */75); + var right = wrap(_type, env); + var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$1 = end_loc !== undefined ? end_loc : right[0]; + semicolon(env); + pop_lex_mode(env); return [ - match[0], + btwn(start_loc, end_loc$1), { - TAG: /* DeclareFunction */23, - _0: match[1] + id: id, + typeParameters: typeParameters, + right: right } ]; } -function declare_var_statement(env, start_loc) { - var match = declare_var(env, start_loc); +function declare_function(env, start_loc) { + token$4(env, /* T_FUNCTION */13); + var id = Curry._2(Parse.identifier, undefined, env); + var start_sig_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var typeParameters = Curry._1(type_parameter_declaration$1, env); + var match = wrap(function_param_list, env); + token$4(env, /* T_COLON */77); + var returnType = wrap(_type, env); + var end_loc = returnType[0]; + var loc = btwn(start_sig_loc, end_loc); + var value_1 = { + TAG: /* Function */1, + _0: { + params: match[1], + returnType: returnType, + rest: match[0], + typeParameters: typeParameters + } + }; + var value = [ + loc, + value_1 + ]; + var typeAnnotation = [ + loc, + value + ]; + var init = id[1]; + var id_0 = btwn(id[0], end_loc); + var id_1 = { + name: init.name, + typeAnnotation: typeAnnotation, + optional: init.optional + }; + var id$1 = [ + id_0, + id_1 + ]; + var end_loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$2 = end_loc$1 !== undefined ? end_loc$1 : end_loc; + var predicate = Curry._1(Parse.predicate, env); + semicolon(env); + var loc$1 = btwn(start_loc, end_loc$2); return [ - match[0], + loc$1, { - TAG: /* DeclareVariable */22, - _0: match[1] + id: id$1, + predicate: predicate } ]; } @@ -12176,28 +11802,402 @@ function declare(in_moduleOpt, env) { return [ loc$3, { - TAG: /* DeclareModule */25, - _0: { - id: id, - body: body, - kind: kind - } + TAG: /* DeclareModule */25, + _0: { + id: id, + body: body, + kind: kind + } + } + ]; + } + } + + } else { + token$4(env, /* T_DECLARE */58); + return declare_function_statement(env, start_loc); + } + } + if (in_module) { + token$4(env, /* T_DECLARE */58); + return declare_var_statement(env, start_loc); + } else { + return Curry._1(Parse.statement, env); + } +} + +function declare_function_statement(env, start_loc) { + var match = declare_function(env, start_loc); + return [ + match[0], + { + TAG: /* DeclareFunction */23, + _0: match[1] + } + ]; +} + +function declare_export_declaration(allow_export_typeOpt, env) { + var allow_export_type = allow_export_typeOpt !== undefined ? allow_export_typeOpt : false; + if (!env.parse_options.types) { + error$1(env, /* UnexpectedTypeDeclaration */7); + } + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_DECLARE */58); + var env$1 = with_in_export(true, with_strict(true, env)); + token$4(env$1, /* T_EXPORT */47); + var match = Curry._2(Parser_env_Peek.token, undefined, env$1); + var exit = 0; + if (typeof match === "number") { + if (match >= 52) { + if (match !== 59) { + if (match !== 97) { + exit = 1; + } else { + var loc = Curry._2(Parser_env_Peek.loc, undefined, env$1); + token$4(env$1, /* T_MULT */97); + var parse_export_star_as = env$1.parse_options.esproposal_export_star_as; + var local_name = Curry._2(Parser_env_Peek.value, undefined, env$1) === "as" ? (contextual(env$1, "as"), parse_export_star_as ? Curry._2(Parse.identifier, undefined, env$1) : (error$1(env$1, /* UnexpectedTypeDeclaration */7), undefined)) : undefined; + var specifiers = { + TAG: /* ExportBatchSpecifier */1, + _0: loc, + _1: local_name + }; + var source = export_source(env$1); + var loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); + var end_loc = loc$1 !== undefined ? loc$1 : source[0]; + var source$1 = source; + semicolon(env$1); + return [ + btwn(start_loc, end_loc), + { + TAG: /* DeclareExportDeclaration */27, + _0: { + default: false, + declaration: undefined, + specifiers: specifiers, + source: source$1 + } + } + ]; + } + } else { + if (allow_export_type) { + var match$1 = type_alias_helper(env$1); + var alias_loc = match$1[0]; + var loc$2 = btwn(start_loc, alias_loc); + return [ + loc$2, + { + TAG: /* DeclareExportDeclaration */27, + _0: { + default: false, + declaration: { + TAG: /* NamedType */4, + _0: [ + alias_loc, + match$1[1] + ] + }, + specifiers: undefined, + source: undefined + } + } + ]; + } + exit = 1; + } + } else if (match >= 39) { + if (match >= 51) { + if (allow_export_type) { + var match$2 = Curry._1(interface_helper, env$1); + var iface_loc = match$2[0]; + var loc$3 = btwn(start_loc, iface_loc); + return [ + loc$3, + { + TAG: /* DeclareExportDeclaration */27, + _0: { + default: false, + declaration: { + TAG: /* Interface */5, + _0: [ + iface_loc, + match$2[1] + ] + }, + specifiers: undefined, + source: undefined + } + } + ]; + } + exit = 1; + } else { + exit = 1; + } + } else if (match >= 13) { + switch (match) { + case /* T_DEFAULT */34 : + token$4(env$1, /* T_DEFAULT */34); + var match$3 = Curry._2(Parser_env_Peek.token, undefined, env$1); + var match$4; + var exit$1 = 0; + if (typeof match$3 === "number") { + if (match$3 !== 13) { + if (match$3 !== 38) { + exit$1 = 3; + } else { + var _class = Curry._2(declare_class, env$1, start_loc); + match$4 = [ + _class[0], + { + TAG: /* Class */2, + _0: _class + } + ]; + } + } else { + var fn = declare_function(env$1, start_loc); + match$4 = [ + fn[0], + { + TAG: /* Function */1, + _0: fn + } + ]; + } + } else { + exit$1 = 3; + } + if (exit$1 === 3) { + var _type$1 = wrap(_type, env$1); + var loc$4 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); + var end_loc$1 = loc$4 !== undefined ? loc$4 : _type$1[0]; + semicolon(env$1); + match$4 = [ + end_loc$1, + { + TAG: /* DefaultType */3, + _0: _type$1 + } + ]; + } + return [ + btwn(start_loc, match$4[0]), + { + TAG: /* DeclareExportDeclaration */27, + _0: { + default: true, + declaration: match$4[1], + specifiers: undefined, + source: undefined + } + } + ]; + case /* T_IF */14 : + case /* T_IN */15 : + case /* T_INSTANCEOF */16 : + case /* T_RETURN */17 : + case /* T_SWITCH */18 : + case /* T_THIS */19 : + case /* T_THROW */20 : + case /* T_TRY */21 : + case /* T_WHILE */23 : + case /* T_WITH */24 : + case /* T_NULL */27 : + case /* T_FALSE */28 : + case /* T_TRUE */29 : + case /* T_BREAK */30 : + case /* T_CASE */31 : + case /* T_CATCH */32 : + case /* T_CONTINUE */33 : + case /* T_DO */35 : + case /* T_FINALLY */36 : + case /* T_FOR */37 : + exit = 1; + break; + case /* T_FUNCTION */13 : + case /* T_VAR */22 : + case /* T_CONST */25 : + case /* T_LET */26 : + case /* T_CLASS */38 : + exit = 2; + break; + + } + } else { + exit = 1; + } + } else { + exit = 1; + } + switch (exit) { + case 1 : + var match$5 = Curry._2(Parser_env_Peek.token, undefined, env$1); + if (typeof match$5 === "number") { + if (match$5 !== 51) { + if (match$5 !== 59) { + + } else { + error$1(env$1, /* DeclareExportType */52); + } + } else { + error$1(env$1, /* DeclareExportInterface */53); + } + } + token$4(env$1, /* T_LCURLY */1); + var match$6 = export_specifiers_and_errs(env$1, /* [] */0, /* [] */0); + var specifiers$1 = { + TAG: /* ExportSpecifiers */0, + _0: match$6[0] + }; + var end_loc$2 = Curry._2(Parser_env_Peek.loc, undefined, env$1); + token$4(env$1, /* T_RCURLY */2); + var source$2 = Curry._2(Parser_env_Peek.value, undefined, env$1) === "from" ? export_source(env$1) : (Stdlib__List.iter((function (param) { + return error_at(env$1, param); + }), match$6[1]), undefined); + var loc$5 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); + var end_loc$3 = loc$5 !== undefined ? loc$5 : ( + source$2 !== undefined ? source$2[0] : end_loc$2 + ); + semicolon(env$1); + return [ + btwn(start_loc, end_loc$3), + { + TAG: /* DeclareExportDeclaration */27, + _0: { + default: false, + declaration: undefined, + specifiers: specifiers$1, + source: source$2 + } + } + ]; + case 2 : + var token$5 = Curry._2(Parser_env_Peek.token, undefined, env$1); + var match$7; + var exit$2 = 0; + if (typeof token$5 === "number") { + if (token$5 >= 23) { + if (token$5 >= 27) { + if (token$5 !== 38) { + exit$2 = 3; + } else { + var _class$1 = Curry._2(declare_class, env$1, start_loc); + match$7 = [ + _class$1[0], + { + TAG: /* Class */2, + _0: _class$1 } ]; + } + } else { + exit$2 = token$5 >= 25 ? 4 : 3; + } + } else if (token$5 !== 13) { + exit$2 = token$5 >= 22 ? 4 : 3; + } else { + var fn$1 = declare_function(env$1, start_loc); + match$7 = [ + fn$1[0], + { + TAG: /* Function */1, + _0: fn$1 + } + ]; + } + } else { + exit$2 = 3; } - } - - } else { - token$4(env, /* T_DECLARE */58); - return declare_function_statement(env, start_loc); - } + switch (exit$2) { + case 3 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 3480, + 17 + ], + Error: new Error() + }; + case 4 : + if (typeof token$5 === "number") { + if (token$5 !== 25) { + if (token$5 !== 26) { + + } else { + error$1(env$1, /* DeclareExportLet */50); + } + } else { + error$1(env$1, /* DeclareExportConst */51); + } + } + var $$var = declare_var(env$1, start_loc); + match$7 = [ + $$var[0], + { + TAG: /* Variable */0, + _0: $$var + } + ]; + break; + + } + return [ + btwn(start_loc, match$7[0]), + { + TAG: /* DeclareExportDeclaration */27, + _0: { + default: false, + declaration: match$7[1], + specifiers: undefined, + source: undefined + } + } + ]; + } - if (in_module) { - token$4(env, /* T_DECLARE */58); - return declare_var_statement(env, start_loc); - } else { +} + +function $$interface(env) { + if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { + return expression(env); + } + var match = Curry._1(interface_helper, env); + return [ + match[0], + { + TAG: /* InterfaceDeclaration */21, + _0: match[1] + } + ]; +} + +function type_alias(env) { + if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { return Curry._1(Parse.statement, env); } + var match = type_alias_helper(env); + return [ + match[0], + { + TAG: /* TypeAlias */7, + _0: match[1] + } + ]; +} + +function declare_var_statement(env, start_loc) { + var match = declare_var(env, start_loc); + return [ + match[0], + { + TAG: /* DeclareVariable */22, + _0: match[1] + } + ]; } function supers(env, _acc) { @@ -14228,149 +14228,58 @@ function statement(env) { case /* T_SEMICOLON */7 : case /* T_AT */12 : case /* T_FUNCTION */13 : - case /* T_IF */14 : - case /* T_RETURN */17 : - case /* T_SWITCH */18 : - case /* T_THIS */19 : - case /* T_THROW */20 : - case /* T_TRY */21 : - case /* T_VAR */22 : - case /* T_WHILE */23 : - case /* T_WITH */24 : - case /* T_CONST */25 : - case /* T_LET */26 : - case /* T_NULL */27 : - case /* T_FALSE */28 : - case /* T_TRUE */29 : - case /* T_BREAK */30 : - case /* T_CONTINUE */33 : - case /* T_DO */35 : - case /* T_FOR */37 : - case /* T_CLASS */38 : - case /* T_NEW */42 : - case /* T_DELETE */43 : - case /* T_TYPEOF */44 : - case /* T_VOID */45 : - case /* T_ENUM */46 : - return expression(env); - case /* T_RCURLY */2 : - case /* T_RPAREN */4 : - case /* T_RBRACKET */6 : - case /* T_COMMA */8 : - case /* T_PERIOD */9 : - case /* T_ARROW */10 : - case /* T_ELLIPSIS */11 : - case /* T_IN */15 : - case /* T_INSTANCEOF */16 : - case /* T_CASE */31 : - case /* T_CATCH */32 : - case /* T_DEFAULT */34 : - case /* T_FINALLY */36 : - case /* T_EXTENDS */39 : - case /* T_STATIC */40 : - case /* T_EXPORT */47 : - case /* T_IMPORT */48 : - break; - - } - } - - } - error_unexpected(env); - token$3(env); - continue ; - }; -} - -function statement_list_item(decoratorsOpt, env) { - var decorators = decoratorsOpt !== undefined ? decoratorsOpt : /* [] */0; - if (!Curry._2(Parser_env_Peek.is_class, undefined, env)) { - error_on_decorators(env)(decorators); - } - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "number") { - if (match === 25) { - return var_or_const(env); - } - if (match === 26) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_LET */26); - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_LPAREN */3)) { - token$4(env, /* T_LPAREN */3); - var match$1 = helper(with_no_let(true, env), /* [] */0, /* [] */0); - var head = Stdlib__List.map((function (param) { - var match = param[1]; - return { - id: match.id, - init: match.init - }; - }), match$1[1]); - token$4(env, /* T_RPAREN */4); - var body = Curry._1(Parse.statement, env); - var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$1 = end_loc !== undefined ? end_loc : match$1[0]; - semicolon(env); - Stdlib__List.iter((function (param) { - return error_at(env, param); - }), match$1[2]); - return [ - btwn(start_loc, end_loc$1), - { - TAG: /* Let */17, - _0: { - head: head, - body: body - } - } - ]; - } - var match$2 = helper(with_no_let(true, env), /* [] */0, /* [] */0); - var declaration = { - TAG: /* VariableDeclaration */19, - _0: { - declarations: match$2[1], - kind: /* Let */1 + case /* T_IF */14 : + case /* T_RETURN */17 : + case /* T_SWITCH */18 : + case /* T_THIS */19 : + case /* T_THROW */20 : + case /* T_TRY */21 : + case /* T_VAR */22 : + case /* T_WHILE */23 : + case /* T_WITH */24 : + case /* T_CONST */25 : + case /* T_LET */26 : + case /* T_NULL */27 : + case /* T_FALSE */28 : + case /* T_TRUE */29 : + case /* T_BREAK */30 : + case /* T_CONTINUE */33 : + case /* T_DO */35 : + case /* T_FOR */37 : + case /* T_CLASS */38 : + case /* T_NEW */42 : + case /* T_DELETE */43 : + case /* T_TYPEOF */44 : + case /* T_VOID */45 : + case /* T_ENUM */46 : + return expression(env); + case /* T_RCURLY */2 : + case /* T_RPAREN */4 : + case /* T_RBRACKET */6 : + case /* T_COMMA */8 : + case /* T_PERIOD */9 : + case /* T_ARROW */10 : + case /* T_ELLIPSIS */11 : + case /* T_IN */15 : + case /* T_INSTANCEOF */16 : + case /* T_CASE */31 : + case /* T_CATCH */32 : + case /* T_DEFAULT */34 : + case /* T_FINALLY */36 : + case /* T_EXTENDS */39 : + case /* T_STATIC */40 : + case /* T_EXPORT */47 : + case /* T_IMPORT */48 : + break; + } - }; - var end_loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$3 = end_loc$2 !== undefined ? end_loc$2 : match$2[0]; - semicolon(env); - Stdlib__List.iter((function (param) { - return error_at(env, param); - }), match$2[2]); - return [ - btwn(start_loc, end_loc$3), - declaration - ]; + } + } - - } - if (Curry._2(Parser_env_Peek.is_function, undefined, env)) { - return _function(env); - } - if (Curry._2(Parser_env_Peek.is_class, undefined, env)) { - return class_declaration$1(env, decorators); - } - if (typeof match !== "number") { - return statement(env); - } - switch (match) { - case /* T_INTERFACE */51 : - return $$interface(env); - case /* T_PACKAGE */52 : - case /* T_PRIVATE */53 : - case /* T_PROTECTED */54 : - case /* T_PUBLIC */55 : - case /* T_YIELD */56 : - case /* T_DEBUGGER */57 : - return statement(env); - case /* T_DECLARE */58 : - return declare(undefined, env); - case /* T_TYPE */59 : - return type_alias(env); - default: - return statement(env); - } + error_unexpected(env); + token$3(env); + continue ; + }; } function module_item(env) { @@ -14913,7 +14822,115 @@ function module_item(env) { } } -var class_declaration$1 = class_declaration; +function statement_list_item(decoratorsOpt, env) { + var decorators = decoratorsOpt !== undefined ? decoratorsOpt : /* [] */0; + if (!Curry._2(Parser_env_Peek.is_class, undefined, env)) { + error_on_decorators(env)(decorators); + } + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "number") { + if (match === 25) { + return var_or_const(env); + } + if (match === 26) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_LET */26); + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_LPAREN */3)) { + token$4(env, /* T_LPAREN */3); + var match$1 = helper(with_no_let(true, env), /* [] */0, /* [] */0); + var head = Stdlib__List.map((function (param) { + var match = param[1]; + return { + id: match.id, + init: match.init + }; + }), match$1[1]); + token$4(env, /* T_RPAREN */4); + var body = Curry._1(Parse.statement, env); + var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$1 = end_loc !== undefined ? end_loc : match$1[0]; + semicolon(env); + Stdlib__List.iter((function (param) { + return error_at(env, param); + }), match$1[2]); + return [ + btwn(start_loc, end_loc$1), + { + TAG: /* Let */17, + _0: { + head: head, + body: body + } + } + ]; + } + var match$2 = helper(with_no_let(true, env), /* [] */0, /* [] */0); + var declaration = { + TAG: /* VariableDeclaration */19, + _0: { + declarations: match$2[1], + kind: /* Let */1 + } + }; + var end_loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$3 = end_loc$2 !== undefined ? end_loc$2 : match$2[0]; + semicolon(env); + Stdlib__List.iter((function (param) { + return error_at(env, param); + }), match$2[2]); + return [ + btwn(start_loc, end_loc$3), + declaration + ]; + } + + } + if (Curry._2(Parser_env_Peek.is_function, undefined, env)) { + return _function(env); + } + if (Curry._2(Parser_env_Peek.is_class, undefined, env)) { + return class_declaration$1(env, decorators); + } + if (typeof match !== "number") { + return statement(env); + } + switch (match) { + case /* T_INTERFACE */51 : + return $$interface(env); + case /* T_PACKAGE */52 : + case /* T_PRIVATE */53 : + case /* T_PROTECTED */54 : + case /* T_PUBLIC */55 : + case /* T_YIELD */56 : + case /* T_DEBUGGER */57 : + return statement(env); + case /* T_DECLARE */58 : + return declare(undefined, env); + case /* T_TYPE */59 : + return type_alias(env); + default: + return statement(env); + } +} + +function module_body(term_fn, env) { + var _acc = /* [] */0; + while(true) { + var acc = _acc; + var t = Curry._2(Parser_env_Peek.token, undefined, env); + if (t === 105) { + return Stdlib__List.rev(acc); + } + if (Curry._1(term_fn, t)) { + return Stdlib__List.rev(acc); + } + _acc = { + hd: module_item(env), + tl: acc + }; + continue ; + }; +} function statement_list(_env, term_fn, item_fn, _param) { while(true) { @@ -15040,6 +15057,8 @@ function directives(env, term_fn, item_fn) { ]; } +var class_declaration$1 = class_declaration; + function statement_list$1(term_fn, env) { var _acc = /* [] */0; while(true) { @@ -15059,23 +15078,22 @@ function statement_list$1(term_fn, env) { }; } -function module_body(term_fn, env) { - var _acc = /* [] */0; - while(true) { - var acc = _acc; - var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (t === 105) { - return Stdlib__List.rev(acc); - } - if (Curry._1(term_fn, t)) { - return Stdlib__List.rev(acc); - } - _acc = { - hd: module_item(env), - tl: acc - }; - continue ; - }; +function statement_list_with_directives(term_fn, env) { + var match = Curry._3(directives, env, term_fn, (function (eta) { + return statement_list_item(undefined, eta); + })); + var env$1 = match[0]; + var stmts = Curry._2(statement_list$1, term_fn, env$1); + var stmts$1 = Stdlib__List.fold_left((function (acc, stmt) { + return { + hd: stmt, + tl: acc + }; + }), stmts, match[1]); + return [ + stmts$1, + env$1.in_strict_mode + ]; } function identifier$2(restricted_error, env) { @@ -15109,28 +15127,10 @@ function identifier$2(restricted_error, env) { return [ loc, { - name: name, - typeAnnotation: undefined, - optional: false - } - ]; -} - -function statement_list_with_directives(term_fn, env) { - var match = Curry._3(directives, env, term_fn, (function (eta) { - return statement_list_item(undefined, eta); - })); - var env$1 = match[0]; - var stmts = Curry._2(statement_list$1, term_fn, env$1); - var stmts$1 = Stdlib__List.fold_left((function (acc, stmt) { - return { - hd: stmt, - tl: acc - }; - }), stmts, match[1]); - return [ - stmts$1, - env$1.in_strict_mode + name: name, + typeAnnotation: undefined, + optional: false + } ]; } @@ -15547,55 +15547,6 @@ function parse(content, options) { string(param[1].name) ]]); }; - var pattern = function (param) { - var obj = param[1]; - var loc = param[0]; - switch (obj.TAG | 0) { - case /* Object */0 : - var obj$1 = obj._0; - return node("ObjectPattern", loc, [ - [ - "properties", - array_of_list(object_pattern_property, obj$1.properties) - ], - [ - "typeAnnotation", - option(type_annotation, obj$1.typeAnnotation) - ] - ]); - case /* Array */1 : - var arr = obj._0; - return node("ArrayPattern", loc, [ - [ - "elements", - array_of_list((function (param) { - return option(array_pattern_element, param); - }), arr.elements) - ], - [ - "typeAnnotation", - option(type_annotation, arr.typeAnnotation) - ] - ]); - case /* Assignment */2 : - var match = obj._0; - return node("AssignmentPattern", loc, [ - [ - "left", - pattern(match.left) - ], - [ - "right", - expression(match.right) - ] - ]); - case /* Identifier */3 : - return identifier(obj._0); - case /* Expression */4 : - return expression(obj._0); - - } - }; var expression = function (param) { var arr = param[1]; var loc = param[0]; @@ -16039,269 +15990,69 @@ function parse(content, options) { var tagged = param$1[1]; return node("TaggedTemplateExpression", param$1[0], [ [ - "tag", - expression(tagged.tag) - ], - [ - "quasi", - template_literal(tagged.quasi) - ] - ]); - case /* JSXElement */22 : - return jsx_element([ - loc, - arr._0 - ]); - case /* Class */23 : - var param$2 = [ - loc, - arr._0 - ]; - var c = param$2[1]; - return node("ClassExpression", param$2[0], [ - [ - "id", - option(identifier, c.id) - ], - [ - "body", - class_body(c.body) - ], - [ - "superClass", - option(expression, c.superClass) - ], - [ - "typeParameters", - option(type_parameter_declaration, c.typeParameters) - ], - [ - "superTypeParameters", - option(type_parameter_instantiation, c.superTypeParameters) - ], - [ - "implements", - array_of_list(class_implements, c.implements) - ], - [ - "decorators", - array_of_list(expression, c.classDecorators) - ] - ]); - case /* TypeCast */24 : - var typecast = arr._0; - return node("TypeCastExpression", loc, [ - [ - "expression", - expression(typecast.expression) - ], - [ - "typeAnnotation", - type_annotation(typecast.typeAnnotation) - ] - ]); - - } - }; - var identifier = function (param) { - var id = param[1]; - return node("Identifier", param[0], [ - [ - "name", - string(id.name) - ], - [ - "typeAnnotation", - option(type_annotation, id.typeAnnotation) - ], - [ - "optional", - bool(id.optional) - ] - ]); - }; - var class_implements = function (param) { - var $$implements = param[1]; - return node("ClassImplements", param[0], [ - [ - "id", - identifier($$implements.id) - ], - [ - "typeParameters", - option(type_parameter_instantiation, $$implements.typeParameters) - ] - ]); - }; - var class_body = function (param) { - return node("ClassBody", param[0], [[ - "body", - array_of_list(class_element, param[1].body) - ]]); - }; - var type_parameter_declaration = function (param) { - return node("TypeParameterDeclaration", param[0], [[ - "params", - array_of_list(type_param, param[1].params) - ]]); - }; - var type_parameter_instantiation = function (param) { - return node("TypeParameterInstantiation", param[0], [[ - "params", - array_of_list(_type, param[1].params) - ]]); - }; - var template_element = function (param) { - var element = param[1]; - var value = obj([ - [ - "raw", - string(element.value.raw) - ], - [ - "cooked", - string(element.value.cooked) - ] - ]); - return node("TemplateElement", param[0], [ - [ - "value", - value - ], - [ - "tail", - bool(element.tail) - ] - ]); - }; - var literal = function (param) { - var lit = param[1]; - var raw = lit.raw; - var value = lit.value; - var loc = param[0]; - var value_; - if (typeof value === "number") { - value_ = $$null; - } else { - switch (value.TAG | 0) { - case /* String */0 : - value_ = string(value._0); - break; - case /* Boolean */1 : - value_ = bool(value._0); - break; - case /* Number */2 : - value_ = number$1(value._0); - break; - case /* RegExp */3 : - var match = value._0; - value_ = regexp$1(loc, match.pattern, match.flags); - break; - - } - } - var props; - var exit = 0; - if (typeof value === "number" || value.TAG !== /* RegExp */3) { - exit = 1; - } else { - var match$1 = value._0; - var regex = obj([ - [ - "pattern", - string(match$1.pattern) - ], - [ - "flags", - string(match$1.flags) - ] - ]); - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ], - [ - "regex", - regex - ] - ]; - } - if (exit === 1) { - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ] - ]; + "tag", + expression(tagged.tag) + ], + [ + "quasi", + template_literal(tagged.quasi) + ] + ]); + case /* JSXElement */22 : + return jsx_element([ + loc, + arr._0 + ]); + case /* Class */23 : + var param$2 = [ + loc, + arr._0 + ]; + var c = param$2[1]; + return node("ClassExpression", param$2[0], [ + [ + "id", + option(identifier, c.id) + ], + [ + "body", + class_body(c.body) + ], + [ + "superClass", + option(expression, c.superClass) + ], + [ + "typeParameters", + option(type_parameter_declaration, c.typeParameters) + ], + [ + "superTypeParameters", + option(type_parameter_instantiation, c.superTypeParameters) + ], + [ + "implements", + array_of_list(class_implements, c.implements) + ], + [ + "decorators", + array_of_list(expression, c.classDecorators) + ] + ]); + case /* TypeCast */24 : + var typecast = arr._0; + return node("TypeCastExpression", loc, [ + [ + "expression", + expression(typecast.expression) + ], + [ + "typeAnnotation", + type_annotation(typecast.typeAnnotation) + ] + ]); + } - return node("Literal", loc, props); - }; - var type_annotation = function (param) { - return node("TypeAnnotation", param[0], [[ - "typeAnnotation", - _type(param[1]) - ]]); - }; - var jsx_member_expression = function (param) { - var member_expression = param[1]; - var id = member_expression._object; - var _object; - _object = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_member_expression(id._0); - return node("JSXMemberExpression", param[0], [ - [ - "object", - _object - ], - [ - "property", - jsx_identifier(member_expression.property) - ] - ]); - }; - var jsx_namespaced_name = function (param) { - var namespaced_name = param[1]; - return node("JSXNamespacedName", param[0], [ - [ - "namespace", - jsx_identifier(namespaced_name.namespace) - ], - [ - "name", - jsx_identifier(namespaced_name.name) - ] - ]); - }; - var block = function (param) { - return node("BlockStatement", param[0], [[ - "body", - array_of_list(statement, param[1].body) - ]]); - }; - var function_type_param = function (param) { - var param$1 = param[1]; - return node("FunctionTypeParam", param[0], [ - [ - "name", - identifier(param$1.name) - ], - [ - "typeAnnotation", - _type(param$1.typeAnnotation) - ], - [ - "optional", - bool(param$1.optional) - ] - ]); }; var _type = function (param) { var t = param[1]; @@ -16455,57 +16206,6 @@ function parse(content, options) { } } }; - var jsx_opening_attribute = function (param) { - if (param.TAG === /* Attribute */0) { - var param$1 = param._0; - var attribute = param$1[1]; - var id = attribute.name; - var name; - name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); - return node("JSXAttribute", param$1[0], [ - [ - "name", - name - ], - [ - "value", - option(jsx_attribute_value, attribute.value) - ] - ]); - } else { - var param$2 = param._0; - return node("JSXSpreadAttribute", param$2[0], [[ - "argument", - expression(param$2[1].argument) - ]]); - } - }; - var jsx_name = function (param) { - switch (param.TAG | 0) { - case /* Identifier */0 : - return jsx_identifier(param._0); - case /* NamespacedName */1 : - return jsx_namespaced_name(param._0); - case /* MemberExpression */2 : - return jsx_member_expression(param._0); - - } - }; - var jsx_expression_container = function (param) { - var expr = param[1].expression; - var expression$1; - expression$1 = expr.TAG === /* Expression */0 ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); - return node("JSXExpressionContainer", param[0], [[ - "expression", - expression$1 - ]]); - }; - var declare_function = function (param) { - return node("DeclareFunction", param[0], [[ - "id", - identifier(param[1].id) - ]]); - }; var statement = function (param) { var b = param[1]; var loc = param[0]; @@ -17026,84 +16726,357 @@ function parse(content, options) { } }; - var type_alias = function (param) { - var alias = param[1]; - return node("TypeAlias", param[0], [ + var pattern = function (param) { + var obj = param[1]; + var loc = param[0]; + switch (obj.TAG | 0) { + case /* Object */0 : + var obj$1 = obj._0; + return node("ObjectPattern", loc, [ + [ + "properties", + array_of_list(object_pattern_property, obj$1.properties) + ], + [ + "typeAnnotation", + option(type_annotation, obj$1.typeAnnotation) + ] + ]); + case /* Array */1 : + var arr = obj._0; + return node("ArrayPattern", loc, [ + [ + "elements", + array_of_list((function (param) { + return option(array_pattern_element, param); + }), arr.elements) + ], + [ + "typeAnnotation", + option(type_annotation, arr.typeAnnotation) + ] + ]); + case /* Assignment */2 : + var match = obj._0; + return node("AssignmentPattern", loc, [ + [ + "left", + pattern(match.left) + ], + [ + "right", + expression(match.right) + ] + ]); + case /* Identifier */3 : + return identifier(obj._0); + case /* Expression */4 : + return expression(obj._0); + + } + }; + var literal = function (param) { + var lit = param[1]; + var raw = lit.raw; + var value = lit.value; + var loc = param[0]; + var value_; + if (typeof value === "number") { + value_ = $$null; + } else { + switch (value.TAG | 0) { + case /* String */0 : + value_ = string(value._0); + break; + case /* Boolean */1 : + value_ = bool(value._0); + break; + case /* Number */2 : + value_ = number$1(value._0); + break; + case /* RegExp */3 : + var match = value._0; + value_ = regexp$1(loc, match.pattern, match.flags); + break; + + } + } + var props; + var exit = 0; + if (typeof value === "number" || value.TAG !== /* RegExp */3) { + exit = 1; + } else { + var match$1 = value._0; + var regex = obj([ + [ + "pattern", + string(match$1.pattern) + ], + [ + "flags", + string(match$1.flags) + ] + ]); + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ], + [ + "regex", + regex + ] + ]; + } + if (exit === 1) { + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ] + ]; + } + return node("Literal", loc, props); + }; + var jsx_expression_container = function (param) { + var expr = param[1].expression; + var expression$1; + expression$1 = expr.TAG === /* Expression */0 ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); + return node("JSXExpressionContainer", param[0], [[ + "expression", + expression$1 + ]]); + }; + var variable_declarator = function (param) { + var declarator = param[1]; + return node("VariableDeclarator", param[0], [ [ "id", - identifier(alias.id) + pattern(declarator.id) ], [ - "typeParameters", - option(type_parameter_declaration, alias.typeParameters) + "init", + option(expression, declarator.init) + ] + ]); + }; + var identifier = function (param) { + var id = param[1]; + return node("Identifier", param[0], [ + [ + "name", + string(id.name) ], [ - "right", - _type(alias.right) + "typeAnnotation", + option(type_annotation, id.typeAnnotation) + ], + [ + "optional", + bool(id.optional) ] ]); }; - var interface_declaration = function (param) { - var i = param[1]; - return node("InterfaceDeclaration", param[0], [ + var object_type = function (param) { + var o = param[1]; + return node("ObjectTypeAnnotation", param[0], [ + [ + "properties", + array_of_list(object_type_property, o.properties) + ], + [ + "indexers", + array_of_list(object_type_indexer, o.indexers) + ], + [ + "callProperties", + array_of_list(object_type_call_property, o.callProperties) + ] + ]); + }; + var interface_extends = function (param) { + var g = param[1]; + var id = g.id; + var id$1; + id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("InterfaceExtends", param[0], [ [ "id", - identifier(i.id) + id$1 ], [ "typeParameters", - option(type_parameter_declaration, i.typeParameters) + option(type_parameter_instantiation, g.typeParameters) + ] + ]); + }; + var type_parameter_declaration = function (param) { + return node("TypeParameterDeclaration", param[0], [[ + "params", + array_of_list(type_param, param[1].params) + ]]); + }; + var function_expression = function (param) { + var _function = param[1]; + var b = _function.body; + var body; + body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); + return node("FunctionExpression", param[0], [ + [ + "id", + option(identifier, _function.id) + ], + [ + "params", + array_of_list(pattern, _function.params) + ], + [ + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), _function.defaults) + ], + [ + "rest", + option(identifier, _function.rest) ], [ "body", - object_type(i.body) + body ], [ - "extends", - array_of_list(interface_extends, i.extends) + "async", + bool(_function.async) + ], + [ + "generator", + bool(_function.generator) + ], + [ + "expression", + bool(_function.expression) + ], + [ + "returnType", + option(type_annotation, _function.returnType) + ], + [ + "typeParameters", + option(type_parameter_declaration, _function.typeParameters) ] ]); }; - var variable_declaration = function (param) { - var $$var = param[1]; - var match = $$var.kind; - var kind; - switch (match) { - case /* Var */0 : - kind = "var"; - break; - case /* Let */1 : - kind = "let"; - break; - case /* Const */2 : - kind = "const"; - break; - - } - return node("VariableDeclaration", param[0], [ + var function_type = function (param) { + var fn = param[1]; + return node("FunctionTypeAnnotation", param[0], [ [ - "declarations", - array_of_list(variable_declarator, $$var.declarations) + "params", + array_of_list(function_type_param, fn.params) ], [ - "kind", - string(kind) + "returnType", + _type(fn.returnType) + ], + [ + "rest", + option(function_type_param, fn.rest) + ], + [ + "typeParameters", + option(type_parameter_declaration, fn.typeParameters) ] ]); }; - var $$case = function (param) { - var c = param[1]; - return node("SwitchCase", param[0], [ + var jsx_member_expression = function (param) { + var member_expression = param[1]; + var id = member_expression._object; + var _object; + _object = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_member_expression(id._0); + return node("JSXMemberExpression", param[0], [ + [ + "object", + _object + ], + [ + "property", + jsx_identifier(member_expression.property) + ] + ]); + }; + var function_type_param = function (param) { + var param$1 = param[1]; + return node("FunctionTypeParam", param[0], [ + [ + "name", + identifier(param$1.name) + ], + [ + "typeAnnotation", + _type(param$1.typeAnnotation) + ], + [ + "optional", + bool(param$1.optional) + ] + ]); + }; + var generic_type_qualified_identifier = function (param) { + var q = param[1]; + var id = q.qualification; + var qualification; + qualification = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("QualifiedTypeIdentifier", param[0], [ + [ + "qualification", + qualification + ], + [ + "id", + identifier(q.id) + ] + ]); + }; + var declare_class = function (param) { + var d = param[1]; + return node("DeclareClass", param[0], [ + [ + "id", + identifier(d.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, d.typeParameters) + ], [ - "test", - option(expression, c.test) + "body", + object_type(d.body) ], [ - "consequent", - array_of_list(statement, c.consequent) + "extends", + array_of_list(interface_extends, d.extends) ] ]); }; + var declare_function = function (param) { + return node("DeclareFunction", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + var declare_variable = function (param) { + return node("DeclareVariable", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; var $$catch = function (param) { var c = param[1]; return node("CatchClause", param[0], [ @@ -17121,30 +17094,26 @@ function parse(content, options) { ] ]); }; - var declare_variable = function (param) { - return node("DeclareVariable", param[0], [[ - "id", - identifier(param[1].id) + var block = function (param) { + return node("BlockStatement", param[0], [[ + "body", + array_of_list(statement, param[1].body) ]]); }; - var declare_class = function (param) { - var d = param[1]; - return node("DeclareClass", param[0], [ + var type_alias = function (param) { + var alias = param[1]; + return node("TypeAlias", param[0], [ [ "id", - identifier(d.id) + identifier(alias.id) ], [ "typeParameters", - option(type_parameter_declaration, d.typeParameters) - ], - [ - "body", - object_type(d.body) + option(type_parameter_declaration, alias.typeParameters) ], [ - "extends", - array_of_list(interface_extends, d.extends) + "right", + _type(alias.right) ] ]); }; @@ -17162,6 +17131,39 @@ function parse(content, options) { return array([]); } }; + var variable_declaration = function (param) { + var $$var = param[1]; + var match = $$var.kind; + var kind; + switch (match) { + case /* Var */0 : + kind = "var"; + break; + case /* Let */1 : + kind = "let"; + break; + case /* Const */2 : + kind = "const"; + break; + + } + return node("VariableDeclaration", param[0], [ + [ + "declarations", + array_of_list(variable_declarator, $$var.declarations) + ], + [ + "kind", + string(kind) + ] + ]); + }; + var type_annotation = function (param) { + return node("TypeAnnotation", param[0], [[ + "typeAnnotation", + _type(param[1]) + ]]); + }; var let_assignment = function (assignment) { return obj([ [ @@ -17174,178 +17176,149 @@ function parse(content, options) { ] ]); }; - var jsx_attribute_value = function (param) { - if (param.TAG === /* Literal */0) { - return literal([ - param._0, - param._1 - ]); - } else { - return jsx_expression_container([ - param._0, - param._1 - ]); - } - }; - var function_expression = function (param) { - var _function = param[1]; - var b = _function.body; - var body; - body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); - return node("FunctionExpression", param[0], [ + var $$case = function (param) { + var c = param[1]; + return node("SwitchCase", param[0], [ [ - "id", - option(identifier, _function.id) + "test", + option(expression, c.test) ], [ - "params", - array_of_list(pattern, _function.params) - ], + "consequent", + array_of_list(statement, c.consequent) + ] + ]); + }; + var interface_declaration = function (param) { + var i = param[1]; + return node("InterfaceDeclaration", param[0], [ [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), _function.defaults) + "id", + identifier(i.id) ], [ - "rest", - option(identifier, _function.rest) + "typeParameters", + option(type_parameter_declaration, i.typeParameters) ], [ "body", - body - ], - [ - "async", - bool(_function.async) - ], - [ - "generator", - bool(_function.generator) - ], - [ - "expression", - bool(_function.expression) - ], - [ - "returnType", - option(type_annotation, _function.returnType) + object_type(i.body) ], [ - "typeParameters", - option(type_parameter_declaration, _function.typeParameters) + "extends", + array_of_list(interface_extends, i.extends) ] ]); }; - var generic_type_qualified_identifier = function (param) { - var q = param[1]; - var id = q.qualification; - var qualification; - qualification = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("QualifiedTypeIdentifier", param[0], [ - [ - "qualification", - qualification - ], - [ - "id", - identifier(q.id) - ] - ]); + var type_parameter_instantiation = function (param) { + return node("TypeParameterInstantiation", param[0], [[ + "params", + array_of_list(_type, param[1].params) + ]]); }; - var interface_extends = function (param) { - var g = param[1]; - var id = g.id; - var id$1; - id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("InterfaceExtends", param[0], [ + var class_implements = function (param) { + var $$implements = param[1]; + return node("ClassImplements", param[0], [ [ "id", - id$1 + identifier($$implements.id) ], [ "typeParameters", - option(type_parameter_instantiation, g.typeParameters) + option(type_parameter_instantiation, $$implements.typeParameters) ] ]); }; - var object_type = function (param) { - var o = param[1]; - return node("ObjectTypeAnnotation", param[0], [ - [ - "properties", - array_of_list(object_type_property, o.properties) - ], + var class_body = function (param) { + return node("ClassBody", param[0], [[ + "body", + array_of_list(class_element, param[1].body) + ]]); + }; + var jsx_name = function (param) { + switch (param.TAG | 0) { + case /* Identifier */0 : + return jsx_identifier(param._0); + case /* NamespacedName */1 : + return jsx_namespaced_name(param._0); + case /* MemberExpression */2 : + return jsx_member_expression(param._0); + + } + }; + var jsx_opening_attribute = function (param) { + if (param.TAG === /* Attribute */0) { + var param$1 = param._0; + var attribute = param$1[1]; + var id = attribute.name; + var name; + name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); + return node("JSXAttribute", param$1[0], [ + [ + "name", + name + ], + [ + "value", + option(jsx_attribute_value, attribute.value) + ] + ]); + } else { + var param$2 = param._0; + return node("JSXSpreadAttribute", param$2[0], [[ + "argument", + expression(param$2[1].argument) + ]]); + } + }; + var template_literal = function (param) { + var value = param[1]; + return node("TemplateLiteral", param[0], [ [ - "indexers", - array_of_list(object_type_indexer, o.indexers) + "quasis", + array_of_list(template_element, value.quasis) ], [ - "callProperties", - array_of_list(object_type_call_property, o.callProperties) + "expressions", + array_of_list(expression, value.expressions) ] ]); }; - var function_type = function (param) { - var fn = param[1]; - return node("FunctionTypeAnnotation", param[0], [ - [ - "params", - array_of_list(function_type_param, fn.params) - ], + var comprehension_block = function (param) { + var b = param[1]; + return node("ComprehensionBlock", param[0], [ [ - "returnType", - _type(fn.returnType) + "left", + pattern(b.left) ], [ - "rest", - option(function_type_param, fn.rest) + "right", + expression(b.right) ], [ - "typeParameters", - option(type_parameter_declaration, fn.typeParameters) + "each", + bool(b.each) ] ]); }; - var template_literal = function (param) { - var value = param[1]; - return node("TemplateLiteral", param[0], [ + var jsx_element = function (param) { + var element = param[1]; + return node("JSXElement", param[0], [ [ - "quasis", - array_of_list(template_element, value.quasis) + "openingElement", + jsx_opening(element.openingElement) ], [ - "expressions", - array_of_list(expression, value.expressions) + "closingElement", + option(jsx_closing, element.closingElement) + ], + [ + "children", + array_of_list(jsx_child, element.children) ] ]); }; - var comment = function (param) { - var c = param[1]; - var match; - match = c.TAG === /* Block */0 ? [ - "Block", - c._0 - ] : [ - "Line", - c._0 - ]; - return node(match[0], param[0], [[ - "value", - string(match[1]) - ]]); - }; - var array_pattern_element = function (param) { - if (param.TAG === /* Element */0) { - return pattern(param._0); - } - var match = param._0; - return node("SpreadElementPattern", match[0], [[ - "argument", - pattern(match[1].argument) - ]]); - }; - var object_pattern_property = function (param) { + var object_property = function (param) { if (param.TAG === /* Property */0) { var match = param._0; var prop = match[1]; @@ -17372,71 +17345,62 @@ function parse(content, options) { break; } - return node("PropertyPattern", match[0], [ + var match$2 = prop.kind; + var kind; + switch (match$2) { + case /* Init */0 : + kind = "init"; + break; + case /* Get */1 : + kind = "get"; + break; + case /* Set */2 : + kind = "set"; + break; + + } + return node("Property", match[0], [ [ "key", match$1[0] ], [ - "pattern", - pattern(prop.pattern) + "value", + expression(prop.value) ], [ - "computed", - bool(match$1[1]) + "kind", + string(kind) + ], + [ + "method", + bool(prop._method) ], [ "shorthand", bool(prop.shorthand) + ], + [ + "computed", + bool(match$1[1]) ] ]); } - var match$2 = param._0; - return node("SpreadPropertyPattern", match$2[0], [[ + var match$3 = param._0; + return node("SpreadProperty", match$3[0], [[ "argument", - pattern(match$2[1].argument) + expression(match$3[1].argument) ]]); }; - var variable_declarator = function (param) { - var declarator = param[1]; - return node("VariableDeclarator", param[0], [ - [ - "id", - pattern(declarator.id) - ], - [ - "init", - option(expression, declarator.init) - ] - ]); - }; - var type_param = function (param) { - var tp = param[1]; - var variance = function (param) { - if (param) { - return string("minus"); - } else { - return string("plus"); - } - }; - return node("TypeParameter", param[0], [ - [ - "name", - string(tp.name) - ], - [ - "bound", - option(type_annotation, tp.bound) - ], - [ - "variance", - option(variance, tp.variance) - ], - [ - "default", - option(_type, tp.default) - ] - ]); + var expression_or_spread = function (param) { + if (param.TAG === /* Expression */0) { + return expression(param._0); + } + var match = param._0; + return node("SpreadElement", match[0], [[ + "argument", + expression(match[1].argument) + ]]); }; var class_element = function (param) { if (param.TAG === /* Method */0) { @@ -17557,23 +17521,6 @@ function parse(content, options) { ]); } }; - var jsx_element = function (param) { - var element = param[1]; - return node("JSXElement", param[0], [ - [ - "openingElement", - jsx_opening(element.openingElement) - ], - [ - "closingElement", - option(jsx_closing, element.closingElement) - ], - [ - "children", - array_of_list(jsx_child, element.children) - ] - ]); - }; var export_specifier = function (param) { var specifier = param[1]; return node("ExportSpecifier", param[0], [ @@ -17587,96 +17534,91 @@ function parse(content, options) { ] ]); }; - var object_type_call_property = function (param) { - var callProperty = param[1]; - return node("ObjectTypeCallProperty", param[0], [ - [ - "value", - function_type(callProperty.value) - ], - [ - "static", - bool(callProperty.static) - ] - ]); + var jsx_closing = function (param) { + return node("JSXClosingElement", param[0], [[ + "name", + jsx_name(param[1].name) + ]]); }; - var object_type_property = function (param) { - var prop = param[1]; - var lit = prop.key; - var key; - switch (lit.TAG | 0) { - case /* Literal */0 : - key = literal(lit._0); - break; - case /* Identifier */1 : - key = identifier(lit._0); - break; - case /* Computed */2 : - throw { - RE_EXN_ID: "Failure", - _1: "There should not be computed object type property keys", - Error: new Error() - }; + var jsx_child = function (param) { + var element = param[1]; + var loc = param[0]; + switch (element.TAG | 0) { + case /* Element */0 : + return jsx_element([ + loc, + element._0 + ]); + case /* ExpressionContainer */1 : + return jsx_expression_container([ + loc, + element._0 + ]); + case /* Text */2 : + var param$1 = [ + loc, + element._0 + ]; + var text = param$1[1]; + return node("JSXText", param$1[0], [ + [ + "value", + string(text.value) + ], + [ + "raw", + string(text.raw) + ] + ]); } - return node("ObjectTypeProperty", param[0], [ - [ - "key", - key - ], - [ - "value", - _type(prop.value) - ], - [ - "optional", - bool(prop.optional) - ], - [ - "static", - bool(prop.static) - ] - ]); }; - var object_type_indexer = function (param) { - var indexer = param[1]; - return node("ObjectTypeIndexer", param[0], [ - [ - "id", - identifier(indexer.id) - ], + var jsx_opening = function (param) { + var opening = param[1]; + return node("JSXOpeningElement", param[0], [ [ - "key", - _type(indexer.key) + "name", + jsx_name(opening.name) ], [ - "value", - _type(indexer.value) + "attributes", + array_of_list(jsx_opening_attribute, opening.attributes) ], [ - "static", - bool(indexer.static) + "selfClosing", + bool(opening.selfClosing) ] ]); }; - var comprehension_block = function (param) { - var b = param[1]; - return node("ComprehensionBlock", param[0], [ - [ - "left", - pattern(b.left) - ], + var jsx_namespaced_name = function (param) { + var namespaced_name = param[1]; + return node("JSXNamespacedName", param[0], [ [ - "right", - expression(b.right) + "namespace", + jsx_identifier(namespaced_name.namespace) ], [ - "each", - bool(b.each) + "name", + jsx_identifier(namespaced_name.name) ] ]); }; - var object_property = function (param) { + var comment = function (param) { + var c = param[1]; + var match; + match = c.TAG === /* Block */0 ? [ + "Block", + c._0 + ] : [ + "Line", + c._0 + ]; + return node(match[0], param[0], [[ + "value", + string(match[1]) + ]]); + }; + var object_pattern_property = function (param) { if (param.TAG === /* Property */0) { var match = param._0; var prop = match[1]; @@ -17703,116 +17645,174 @@ function parse(content, options) { break; } - var match$2 = prop.kind; - var kind; - switch (match$2) { - case /* Init */0 : - kind = "init"; - break; - case /* Get */1 : - kind = "get"; - break; - case /* Set */2 : - kind = "set"; - break; - - } - return node("Property", match[0], [ + return node("PropertyPattern", match[0], [ [ "key", match$1[0] ], [ - "value", - expression(prop.value) - ], - [ - "kind", - string(kind) + "pattern", + pattern(prop.pattern) ], [ - "method", - bool(prop._method) + "computed", + bool(match$1[1]) ], [ "shorthand", bool(prop.shorthand) - ], - [ - "computed", - bool(match$1[1]) ] ]); } - var match$3 = param._0; - return node("SpreadProperty", match$3[0], [[ + var match$2 = param._0; + return node("SpreadPropertyPattern", match$2[0], [[ "argument", - expression(match$3[1].argument) + pattern(match$2[1].argument) ]]); }; - var expression_or_spread = function (param) { - if (param.TAG === /* Expression */0) { - return expression(param._0); + var array_pattern_element = function (param) { + if (param.TAG === /* Element */0) { + return pattern(param._0); } var match = param._0; - return node("SpreadElement", match[0], [[ + return node("SpreadElementPattern", match[0], [[ "argument", - expression(match[1].argument) + pattern(match[1].argument) ]]); }; - var jsx_child = function (param) { - var element = param[1]; - var loc = param[0]; - switch (element.TAG | 0) { - case /* Element */0 : - return jsx_element([ - loc, - element._0 - ]); - case /* ExpressionContainer */1 : - return jsx_expression_container([ - loc, - element._0 - ]); - case /* Text */2 : - var param$1 = [ - loc, - element._0 - ]; - var text = param$1[1]; - return node("JSXText", param$1[0], [ - [ - "value", - string(text.value) - ], - [ - "raw", - string(text.raw) - ] - ]); - + var jsx_attribute_value = function (param) { + if (param.TAG === /* Literal */0) { + return literal([ + param._0, + param._1 + ]); + } else { + return jsx_expression_container([ + param._0, + param._1 + ]); } }; - var jsx_closing = function (param) { - return node("JSXClosingElement", param[0], [[ + var type_param = function (param) { + var tp = param[1]; + var variance = function (param) { + if (param) { + return string("minus"); + } else { + return string("plus"); + } + }; + return node("TypeParameter", param[0], [ + [ "name", - jsx_name(param[1].name) - ]]); + string(tp.name) + ], + [ + "bound", + option(type_annotation, tp.bound) + ], + [ + "variance", + option(variance, tp.variance) + ], + [ + "default", + option(_type, tp.default) + ] + ]); }; - var jsx_opening = function (param) { - var opening = param[1]; - return node("JSXOpeningElement", param[0], [ + var template_element = function (param) { + var element = param[1]; + var value = obj([ + [ + "raw", + string(element.value.raw) + ], + [ + "cooked", + string(element.value.cooked) + ] + ]); + return node("TemplateElement", param[0], [ [ - "name", - jsx_name(opening.name) + "value", + value ], [ - "attributes", - array_of_list(jsx_opening_attribute, opening.attributes) + "tail", + bool(element.tail) + ] + ]); + }; + var object_type_indexer = function (param) { + var indexer = param[1]; + return node("ObjectTypeIndexer", param[0], [ + [ + "id", + identifier(indexer.id) ], [ - "selfClosing", - bool(opening.selfClosing) + "key", + _type(indexer.key) + ], + [ + "value", + _type(indexer.value) + ], + [ + "static", + bool(indexer.static) + ] + ]); + }; + var object_type_call_property = function (param) { + var callProperty = param[1]; + return node("ObjectTypeCallProperty", param[0], [ + [ + "value", + function_type(callProperty.value) + ], + [ + "static", + bool(callProperty.static) + ] + ]); + }; + var object_type_property = function (param) { + var prop = param[1]; + var lit = prop.key; + var key; + switch (lit.TAG | 0) { + case /* Literal */0 : + key = literal(lit._0); + break; + case /* Identifier */1 : + key = identifier(lit._0); + break; + case /* Computed */2 : + throw { + RE_EXN_ID: "Failure", + _1: "There should not be computed object type property keys", + Error: new Error() + }; + + } + return node("ObjectTypeProperty", param[0], [ + [ + "key", + key + ], + [ + "value", + _type(prop.value) + ], + [ + "optional", + bool(prop.optional) + ], + [ + "static", + bool(prop.static) ] ]); }; diff --git a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js index 475ff5c007..14b63d2ec9 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js @@ -11265,38 +11265,6 @@ function directive_parse(token_with_comments, lexbuf) { } }; - var parse_and_aux = function (calc, v) { - var e = token(undefined); - if (typeof e === "number") { - if (e) { - push(e); - return v; - } - var calc$1 = calc && v; - var b = parse_and_aux(calc$1, parse_relation(calc$1)); - if (v) { - return b; - } else { - return false; - } - } - push(e); - return v; - }; - var parse_or_aux = function (calc, v) { - var e = token(undefined); - if (e === 8) { - var calc$1 = calc && !v; - var b = parse_or_aux(calc$1, parse_and_aux(calc$1, parse_relation(calc$1))); - if (v) { - return true; - } else { - return b; - } - } - push(e); - return v; - }; var parse_relation = function (calc) { var curr_token = token(undefined); var curr_loc = curr(lexbuf); @@ -11441,6 +11409,38 @@ function directive_parse(token_with_comments, lexbuf) { } } }; + var parse_and_aux = function (calc, v) { + var e = token(undefined); + if (typeof e === "number") { + if (e) { + push(e); + return v; + } + var calc$1 = calc && v; + var b = parse_and_aux(calc$1, parse_relation(calc$1)); + if (v) { + return b; + } else { + return false; + } + } + push(e); + return v; + }; + var parse_or_aux = function (calc, v) { + var e = token(undefined); + if (e === 8) { + var calc$1 = calc && !v; + var b = parse_or_aux(calc$1, parse_and_aux(calc$1, parse_relation(calc$1))); + if (v) { + return true; + } else { + return b; + } + } + push(e); + return v; + }; var v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); var match = token(undefined); if (match === 88) { @@ -12796,17 +12796,45 @@ function token(lexbuf) { }; } -function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { +function string(lexbuf) { + lexbuf.lex_mem = Caml_array.make(2, -1); + var ___ocaml_lex_state = 164; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + var __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : + return ; + case 1 : + var space = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + update_loc(lexbuf, undefined, 1, false, space.length); + return string(lexbuf); + case 2 : + store_string_char(char_for_backslash(Stdlib__Lexing.lexeme_char(lexbuf, 1))); + return string(lexbuf); + case 3 : + store_string_char(char_for_decimal_code(lexbuf, 1)); + return string(lexbuf); + case 4 : + store_string_char(char_for_hexadecimal_code(lexbuf, 2)); + return string(lexbuf); + case 5 : + if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { + return string(lexbuf); + } + var loc = curr(lexbuf); + prerr_warning(loc, /* Illegal_backslash */7); + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 1)); + return string(lexbuf); + case 6 : + if (!Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { + prerr_warning(curr(lexbuf), /* Eol_in_string */14); + } update_loc(lexbuf, undefined, 1, false, 0); store_string(Stdlib__Lexing.lexeme(lexbuf)); - ___ocaml_lex_state = 183; - continue ; - case 1 : + return string(lexbuf); + case 7 : is_in_string.contents = false; throw { RE_EXN_ID: $$Error$2, @@ -12814,19 +12842,9 @@ function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { _2: string_start_loc.contents, Error: new Error() }; - case 2 : - var edelim = Stdlib__Lexing.lexeme(lexbuf); - var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); - if (delim === edelim$1) { - return ; - } - store_string(Stdlib__Lexing.lexeme(lexbuf)); - ___ocaml_lex_state = 183; - continue ; - case 3 : + case 8 : store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - ___ocaml_lex_state = 183; - continue ; + return string(lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -13020,45 +13038,21 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { }; } -function string(lexbuf) { - lexbuf.lex_mem = Caml_array.make(2, -1); - var ___ocaml_lex_state = 164; +function comment(lexbuf) { + return __ocaml_lex_comment_rec(lexbuf, 132); +} + +function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - return ; - case 1 : - var space = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - update_loc(lexbuf, undefined, 1, false, space.length); - return string(lexbuf); - case 2 : - store_string_char(char_for_backslash(Stdlib__Lexing.lexeme_char(lexbuf, 1))); - return string(lexbuf); - case 3 : - store_string_char(char_for_decimal_code(lexbuf, 1)); - return string(lexbuf); - case 4 : - store_string_char(char_for_hexadecimal_code(lexbuf, 2)); - return string(lexbuf); - case 5 : - if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { - return string(lexbuf); - } - var loc = curr(lexbuf); - prerr_warning(loc, /* Illegal_backslash */7); - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 1)); - return string(lexbuf); - case 6 : - if (!Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { - prerr_warning(curr(lexbuf), /* Eol_in_string */14); - } update_loc(lexbuf, undefined, 1, false, 0); store_string(Stdlib__Lexing.lexeme(lexbuf)); - return string(lexbuf); - case 7 : + ___ocaml_lex_state = 183; + continue ; + case 1 : is_in_string.contents = false; throw { RE_EXN_ID: $$Error$2, @@ -13066,9 +13060,19 @@ function string(lexbuf) { _2: string_start_loc.contents, Error: new Error() }; - case 8 : + case 2 : + var edelim = Stdlib__Lexing.lexeme(lexbuf); + var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); + if (delim === edelim$1) { + return ; + } + store_string(Stdlib__Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 183; + continue ; + case 3 : store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - return string(lexbuf); + ___ocaml_lex_state = 183; + continue ; default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -13077,10 +13081,6 @@ function string(lexbuf) { }; } -function comment(lexbuf) { - return __ocaml_lex_comment_rec(lexbuf, 132); -} - function at_bol(lexbuf) { var pos = lexbuf.lex_start_p; return pos.pos_cnum === pos.pos_bol; diff --git a/jscomp/test/dist/jscomp/test/ocaml_re_test.js b/jscomp/test/dist/jscomp/test/ocaml_re_test.js index 3a79587666..c425deb11e 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_re_test.js @@ -3373,19 +3373,6 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - var branch$p = function (_left) { - while(true) { - var left = _left; - if (i.contents === l || test(/* '|' */124) || test(/* ')' */41)) { - return seq$2(Stdlib__List.rev(left)); - } - _left = { - hd: piece(undefined), - tl: left - }; - continue ; - }; - }; var regexp$p = function (_left) { while(true) { var left = _left; @@ -3402,39 +3389,18 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue ; }; }; - var piece = function (param) { - var r = atom(undefined); - if (accept(/* '*' */42)) { - return greedy_mod(repn(r, 0, undefined)); - } - if (accept(/* '+' */43)) { - return greedy_mod(repn(r, 1, undefined)); - } - if (accept(/* '?' */63)) { - return greedy_mod(repn(r, 0, 1)); - } - if (!accept(/* '{' */123)) { - return r; - } - var i$1 = integer(undefined); - if (i$1 !== undefined) { - var j = accept(/* ',' */44) ? integer(undefined) : i$1; - if (!accept(/* '}' */125)) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - if (j !== undefined && j < i$1) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; + var branch$p = function (_left) { + while(true) { + var left = _left; + if (i.contents === l || test(/* '|' */124) || test(/* ')' */41)) { + return seq$2(Stdlib__List.rev(left)); } - return greedy_mod(repn(r, i$1, j)); - } - i.contents = i.contents - 1 | 0; - return r; + _left = { + hd: piece(undefined), + tl: left + }; + continue ; + }; }; var bracket = function (_s) { while(true) { @@ -3517,6 +3483,40 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue ; }; }; + var piece = function (param) { + var r = atom(undefined); + if (accept(/* '*' */42)) { + return greedy_mod(repn(r, 0, undefined)); + } + if (accept(/* '+' */43)) { + return greedy_mod(repn(r, 1, undefined)); + } + if (accept(/* '?' */63)) { + return greedy_mod(repn(r, 0, 1)); + } + if (!accept(/* '{' */123)) { + return r; + } + var i$1 = integer(undefined); + if (i$1 !== undefined) { + var j = accept(/* ',' */44) ? integer(undefined) : i$1; + if (!accept(/* '}' */125)) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + if (j !== undefined && j < i$1) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + return greedy_mod(repn(r, i$1, j)); + } + i.contents = i.contents - 1 | 0; + return r; + }; var $$char = function (param) { if (i.contents === l) { throw { diff --git a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js index 8e2902b0b9..c87fa185c6 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js @@ -13881,66 +13881,6 @@ function components_of_module(env, sub, path, mty) { }; } -function check_value_name(name, loc) { - if (bs_only.contents && name === "|.") { - throw { - RE_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_value_name */4, - _0: loc, - _1: name - }, - Error: new Error() - }; - } - if (!(name.length !== 0 && Caml_string.get(name, 0) === /* '#' */35)) { - return ; - } - for(var i = 1 ,i_finish = name.length; i < i_finish; ++i){ - if (Caml_string.get(name, i) === /* '#' */35) { - throw { - RE_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_value_name */4, - _0: loc, - _1: name - }, - Error: new Error() - }; - } - - } -} - -function check_usage(loc, id, warn, tbl) { - if (!(!loc.loc_ghost && is_active(Curry._1(warn, "")))) { - return ; - } - var name = id.name; - var key = [ - name, - loc - ]; - if (Stdlib__Hashtbl.mem(tbl, key)) { - return ; - } - var used = { - contents: false - }; - Stdlib__Hashtbl.add(tbl, key, (function (param) { - used.contents = true; - })); - if (!(name === "" || Caml_string.get(name, 0) === /* '_' */95 || Caml_string.get(name, 0) === /* '#' */35)) { - return Curry._1(add_delayed_check_forward.contents, (function (param) { - if (!used.contents) { - return prerr_warning(loc, Curry._1(warn, name)); - } - - })); - } - -} - function store_module(slot, id, path, md, env, renv) { return { values: env.values, @@ -13971,29 +13911,23 @@ function store_module(slot, id, path, md, env, renv) { }; } -function store_type_infos(slot, id, path, info, env, renv) { +function store_modtype(slot, id, path, info, env, renv) { return { values: env.values, constrs: env.constrs, labels: env.labels, - types: add$6("type", slot, id, [ - path, - [ - info, - [ - /* [] */0, - /* [] */0 - ] - ] - ], env.types, renv.types), + types: env.types, modules: env.modules, - modtypes: env.modtypes, + modtypes: add$6("module type", slot, id, [ + path, + info + ], env.modtypes, renv.modtypes), components: env.components, classes: env.classes, cltypes: env.cltypes, functor_args: env.functor_args, summary: { - TAG: /* Env_type */1, + TAG: /* Env_modtype */4, _0: env.summary, _1: id, _2: info @@ -14004,23 +13938,29 @@ function store_type_infos(slot, id, path, info, env, renv) { }; } -function store_modtype(slot, id, path, info, env, renv) { +function store_type_infos(slot, id, path, info, env, renv) { return { values: env.values, constrs: env.constrs, labels: env.labels, - types: env.types, - modules: env.modules, - modtypes: add$6("module type", slot, id, [ + types: add$6("type", slot, id, [ path, - info - ], env.modtypes, renv.modtypes), + [ + info, + [ + /* [] */0, + /* [] */0 + ] + ] + ], env.types, renv.types), + modules: env.modules, + modtypes: env.modtypes, components: env.components, classes: env.classes, cltypes: env.cltypes, functor_args: env.functor_args, summary: { - TAG: /* Env_modtype */4, + TAG: /* Env_type */1, _0: env.summary, _1: id, _2: info @@ -14031,6 +13971,66 @@ function store_modtype(slot, id, path, info, env, renv) { }; } +function check_usage(loc, id, warn, tbl) { + if (!(!loc.loc_ghost && is_active(Curry._1(warn, "")))) { + return ; + } + var name = id.name; + var key = [ + name, + loc + ]; + if (Stdlib__Hashtbl.mem(tbl, key)) { + return ; + } + var used = { + contents: false + }; + Stdlib__Hashtbl.add(tbl, key, (function (param) { + used.contents = true; + })); + if (!(name === "" || Caml_string.get(name, 0) === /* '_' */95 || Caml_string.get(name, 0) === /* '#' */35)) { + return Curry._1(add_delayed_check_forward.contents, (function (param) { + if (!used.contents) { + return prerr_warning(loc, Curry._1(warn, name)); + } + + })); + } + +} + +function check_value_name(name, loc) { + if (bs_only.contents && name === "|.") { + throw { + RE_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_value_name */4, + _0: loc, + _1: name + }, + Error: new Error() + }; + } + if (!(name.length !== 0 && Caml_string.get(name, 0) === /* '#' */35)) { + return ; + } + for(var i = 1 ,i_finish = name.length; i < i_finish; ++i){ + if (Caml_string.get(name, i) === /* '#' */35) { + throw { + RE_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_value_name */4, + _0: loc, + _1: name + }, + Error: new Error() + }; + } + + } +} + function components_of_module_maker(param) { var sub = param[1]; var env = param[0]; @@ -26170,62 +26170,6 @@ function TypedtreeMap_MakeMap(funarg) { ctyp_attributes: ct$1.ctyp_attributes }); }; - var map_class_type_field = function (ctf) { - var ctf$1 = Curry._1(funarg.enter_class_type_field, ctf); - var ct = ctf$1.ctf_desc; - var ctf_desc; - switch (ct.TAG | 0) { - case /* Tctf_inherit */0 : - ctf_desc = { - TAG: /* Tctf_inherit */0, - _0: map_class_type(ct._0) - }; - break; - case /* Tctf_val */1 : - var match = ct._0; - ctf_desc = { - TAG: /* Tctf_val */1, - _0: [ - match[0], - match[1], - match[2], - map_core_type(match[3]) - ] - }; - break; - case /* Tctf_method */2 : - var match$1 = ct._0; - ctf_desc = { - TAG: /* Tctf_method */2, - _0: [ - match$1[0], - match$1[1], - match$1[2], - map_core_type(match$1[3]) - ] - }; - break; - case /* Tctf_constraint */3 : - var match$2 = ct._0; - ctf_desc = { - TAG: /* Tctf_constraint */3, - _0: [ - map_core_type(match$2[0]), - map_core_type(match$2[1]) - ] - }; - break; - case /* Tctf_attribute */4 : - ctf_desc = ct; - break; - - } - return Curry._1(funarg.leave_class_type_field, { - ctf_desc: ctf_desc, - ctf_loc: ctf$1.ctf_loc, - ctf_attributes: ctf$1.ctf_attributes - }); - }; var map_class_type = function (ct) { var ct$1 = Curry._1(funarg.enter_class_type, ct); var csg = ct$1.cltyp_desc; @@ -26269,136 +26213,105 @@ function TypedtreeMap_MakeMap(funarg) { param[1] ]; }; - var map_binding = function (vb) { - return { - vb_pat: map_pattern(vb.vb_pat), - vb_expr: map_expression(vb.vb_expr), - vb_attributes: vb.vb_attributes, - vb_loc: vb.vb_loc + var map_module_expr = function (mexpr) { + var mexpr$1 = Curry._1(funarg.enter_module_expr, mexpr); + var st = mexpr$1.mod_desc; + var mod_desc; + switch (st.TAG | 0) { + case /* Tmod_ident */0 : + mod_desc = mexpr$1.mod_desc; + break; + case /* Tmod_structure */1 : + mod_desc = { + TAG: /* Tmod_structure */1, + _0: map_structure(st._0) }; - }; - var map_class_signature = function (cs) { - var cs$1 = Curry._1(funarg.enter_class_signature, cs); - var csig_self = map_core_type(cs$1.csig_self); - var csig_fields = Stdlib__List.map(map_class_type_field, cs$1.csig_fields); - return Curry._1(funarg.leave_class_signature, { - csig_self: csig_self, - csig_fields: csig_fields, - csig_type: cs$1.csig_type - }); - }; - var map_extension_constructor = function (ext) { - var ext$1 = Curry._1(funarg.enter_extension_constructor, ext); - var match = ext$1.ext_kind; - var ext_kind; - if (match.TAG === /* Text_decl */0) { - var args = Stdlib__List.map(map_core_type, match._0); - var ret = may_map(map_core_type, match._1); - ext_kind = { - TAG: /* Text_decl */0, - _0: args, - _1: ret - }; - } else { - ext_kind = { - TAG: /* Text_rebind */1, - _0: match._0, - _1: match._1 - }; - } - return Curry._1(funarg.leave_extension_constructor, { - ext_id: ext$1.ext_id, - ext_name: ext$1.ext_name, - ext_type: ext$1.ext_type, - ext_kind: ext_kind, - ext_loc: ext$1.ext_loc, - ext_attributes: ext$1.ext_attributes - }); - }; - var map_module_type_declaration = function (mtd) { - var mtd$1 = Curry._1(funarg.enter_module_type_declaration, mtd); - return Curry._1(funarg.leave_module_type_declaration, { - mtd_id: mtd$1.mtd_id, - mtd_name: mtd$1.mtd_name, - mtd_type: may_map(map_module_type, mtd$1.mtd_type), - mtd_attributes: mtd$1.mtd_attributes, - mtd_loc: mtd$1.mtd_loc + break; + case /* Tmod_functor */2 : + mod_desc = { + TAG: /* Tmod_functor */2, + _0: st._0, + _1: st._1, + _2: may_map(map_module_type, st._2), + _3: map_module_expr(st._3) + }; + break; + case /* Tmod_apply */3 : + mod_desc = { + TAG: /* Tmod_apply */3, + _0: map_module_expr(st._0), + _1: map_module_expr(st._1), + _2: st._2 + }; + break; + case /* Tmod_constraint */4 : + var mtype = st._2; + var mod_type = st._1; + var mexpr$2 = st._0; + mod_desc = mtype ? ({ + TAG: /* Tmod_constraint */4, + _0: map_module_expr(mexpr$2), + _1: mod_type, + _2: /* Tmodtype_explicit */{ + _0: map_module_type(mtype._0) + }, + _3: st._3 + }) : ({ + TAG: /* Tmod_constraint */4, + _0: map_module_expr(mexpr$2), + _1: mod_type, + _2: /* Tmodtype_implicit */0, + _3: st._3 }); - }; - var map_type_extension = function (tyext) { - var tyext$1 = Curry._1(funarg.enter_type_extension, tyext); - var tyext_params = Stdlib__List.map(map_type_parameter, tyext$1.tyext_params); - var tyext_constructors = Stdlib__List.map(map_extension_constructor, tyext$1.tyext_constructors); - return Curry._1(funarg.leave_type_extension, { - tyext_path: tyext$1.tyext_path, - tyext_txt: tyext$1.tyext_txt, - tyext_params: tyext_params, - tyext_constructors: tyext_constructors, - tyext_private: tyext$1.tyext_private, - tyext_attributes: tyext$1.tyext_attributes + break; + case /* Tmod_unpack */5 : + mod_desc = { + TAG: /* Tmod_unpack */5, + _0: map_expression(st._0), + _1: st._1 + }; + break; + + } + return Curry._1(funarg.leave_module_expr, { + mod_desc: mod_desc, + mod_loc: mexpr$1.mod_loc, + mod_type: mexpr$1.mod_type, + mod_env: mexpr$1.mod_env, + mod_attributes: mexpr$1.mod_attributes }); }; - var map_type_declaration = function (decl) { - var decl$1 = Curry._1(funarg.enter_type_declaration, decl); - var typ_params = Stdlib__List.map(map_type_parameter, decl$1.typ_params); - var typ_cstrs = Stdlib__List.map((function (param) { - return [ - map_core_type(param[0]), - map_core_type(param[1]), - param[2] - ]; - }), decl$1.typ_cstrs); - var list = decl$1.typ_kind; - var typ_kind; - if (typeof list === "number") { - typ_kind = list === /* Ttype_abstract */0 ? /* Ttype_abstract */0 : /* Ttype_open */1; - } else if (list.TAG === /* Ttype_variant */0) { - var list$1 = Stdlib__List.map(map_constructor_declaration, list._0); - typ_kind = { - TAG: /* Ttype_variant */0, - _0: list$1 - }; - } else { - var list$2 = Stdlib__List.map((function (ld) { - return { - ld_id: ld.ld_id, - ld_name: ld.ld_name, - ld_mutable: ld.ld_mutable, - ld_type: map_core_type(ld.ld_type), - ld_loc: ld.ld_loc, - ld_attributes: ld.ld_attributes - }; - }), list._0); - typ_kind = { - TAG: /* Ttype_record */1, - _0: list$2 - }; + var map_with_constraint = function (cstr) { + var cstr$1 = Curry._1(funarg.enter_with_constraint, cstr); + var tmp; + switch (cstr$1.TAG | 0) { + case /* Twith_type */0 : + tmp = { + TAG: /* Twith_type */0, + _0: map_type_declaration(cstr$1._0) + }; + break; + case /* Twith_typesubst */2 : + tmp = { + TAG: /* Twith_typesubst */2, + _0: map_type_declaration(cstr$1._0) + }; + break; + case /* Twith_module */1 : + case /* Twith_modsubst */3 : + tmp = cstr$1; + break; + } - var typ_manifest = may_map(map_core_type, decl$1.typ_manifest); - return Curry._1(funarg.leave_type_declaration, { - typ_id: decl$1.typ_id, - typ_name: decl$1.typ_name, - typ_params: typ_params, - typ_type: decl$1.typ_type, - typ_cstrs: typ_cstrs, - typ_kind: typ_kind, - typ_private: decl$1.typ_private, - typ_manifest: typ_manifest, - typ_loc: decl$1.typ_loc, - typ_attributes: decl$1.typ_attributes - }); + return Curry._1(funarg.leave_with_constraint, tmp); }; - var map_value_description = function (v) { - var v$1 = Curry._1(funarg.enter_value_description, v); - var val_desc = map_core_type(v$1.val_desc); - return Curry._1(funarg.leave_value_description, { - val_id: v$1.val_id, - val_name: v$1.val_name, - val_desc: val_desc, - val_val: v$1.val_val, - val_prim: v$1.val_prim, - val_loc: v$1.val_loc, - val_attributes: v$1.val_attributes + var map_signature = function (sg) { + var sg$1 = Curry._1(funarg.enter_signature, sg); + var sig_items = Stdlib__List.map(map_signature_item, sg$1.sig_items); + return Curry._1(funarg.leave_signature, { + sig_items: sig_items, + sig_type: sg$1.sig_type, + sig_final_env: sg$1.sig_final_env }); }; var map_module_type = function (mty) { @@ -26454,128 +26367,44 @@ function TypedtreeMap_MakeMap(funarg) { mty_attributes: mty$1.mty_attributes }); }; - var map_class_type_declaration = function (cd) { - var cd$1 = Curry._1(funarg.enter_class_type_declaration, cd); - var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - var ci_expr = map_class_type(cd$1.ci_expr); - return Curry._1(funarg.leave_class_type_declaration, { - ci_virt: cd$1.ci_virt, - ci_params: ci_params, - ci_id_name: cd$1.ci_id_name, - ci_id_class: cd$1.ci_id_class, - ci_id_class_type: cd$1.ci_id_class_type, - ci_id_object: cd$1.ci_id_object, - ci_id_typesharp: cd$1.ci_id_typesharp, - ci_expr: ci_expr, - ci_decl: cd$1.ci_decl, - ci_type_decl: cd$1.ci_type_decl, - ci_loc: cd$1.ci_loc, - ci_attributes: cd$1.ci_attributes + var map_extension_constructor = function (ext) { + var ext$1 = Curry._1(funarg.enter_extension_constructor, ext); + var match = ext$1.ext_kind; + var ext_kind; + if (match.TAG === /* Text_decl */0) { + var args = Stdlib__List.map(map_core_type, match._0); + var ret = may_map(map_core_type, match._1); + ext_kind = { + TAG: /* Text_decl */0, + _0: args, + _1: ret + }; + } else { + ext_kind = { + TAG: /* Text_rebind */1, + _0: match._0, + _1: match._1 + }; + } + return Curry._1(funarg.leave_extension_constructor, { + ext_id: ext$1.ext_id, + ext_name: ext$1.ext_name, + ext_type: ext$1.ext_type, + ext_kind: ext_kind, + ext_loc: ext$1.ext_loc, + ext_attributes: ext$1.ext_attributes }); }; - var map_class_description = function (cd) { - var cd$1 = Curry._1(funarg.enter_class_description, cd); - var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - var ci_expr = map_class_type(cd$1.ci_expr); - return Curry._1(funarg.leave_class_description, { - ci_virt: cd$1.ci_virt, - ci_params: ci_params, - ci_id_name: cd$1.ci_id_name, - ci_id_class: cd$1.ci_id_class, - ci_id_class_type: cd$1.ci_id_class_type, - ci_id_object: cd$1.ci_id_object, - ci_id_typesharp: cd$1.ci_id_typesharp, - ci_expr: ci_expr, - ci_decl: cd$1.ci_decl, - ci_type_decl: cd$1.ci_type_decl, - ci_loc: cd$1.ci_loc, - ci_attributes: cd$1.ci_attributes + var map_class_signature = function (cs) { + var cs$1 = Curry._1(funarg.enter_class_signature, cs); + var csig_self = map_core_type(cs$1.csig_self); + var csig_fields = Stdlib__List.map(map_class_type_field, cs$1.csig_fields); + return Curry._1(funarg.leave_class_signature, { + csig_self: csig_self, + csig_fields: csig_fields, + csig_type: cs$1.csig_type }); }; - var map_case = function (param) { - return { - c_lhs: map_pattern(param.c_lhs), - c_guard: may_map(map_expression, param.c_guard), - c_rhs: map_expression(param.c_rhs) - }; - }; - var map_module_expr = function (mexpr) { - var mexpr$1 = Curry._1(funarg.enter_module_expr, mexpr); - var st = mexpr$1.mod_desc; - var mod_desc; - switch (st.TAG | 0) { - case /* Tmod_ident */0 : - mod_desc = mexpr$1.mod_desc; - break; - case /* Tmod_structure */1 : - mod_desc = { - TAG: /* Tmod_structure */1, - _0: map_structure(st._0) - }; - break; - case /* Tmod_functor */2 : - mod_desc = { - TAG: /* Tmod_functor */2, - _0: st._0, - _1: st._1, - _2: may_map(map_module_type, st._2), - _3: map_module_expr(st._3) - }; - break; - case /* Tmod_apply */3 : - mod_desc = { - TAG: /* Tmod_apply */3, - _0: map_module_expr(st._0), - _1: map_module_expr(st._1), - _2: st._2 - }; - break; - case /* Tmod_constraint */4 : - var mtype = st._2; - var mod_type = st._1; - var mexpr$2 = st._0; - mod_desc = mtype ? ({ - TAG: /* Tmod_constraint */4, - _0: map_module_expr(mexpr$2), - _1: mod_type, - _2: /* Tmodtype_explicit */{ - _0: map_module_type(mtype._0) - }, - _3: st._3 - }) : ({ - TAG: /* Tmod_constraint */4, - _0: map_module_expr(mexpr$2), - _1: mod_type, - _2: /* Tmodtype_implicit */0, - _3: st._3 - }); - break; - case /* Tmod_unpack */5 : - mod_desc = { - TAG: /* Tmod_unpack */5, - _0: map_expression(st._0), - _1: st._1 - }; - break; - - } - return Curry._1(funarg.leave_module_expr, { - mod_desc: mod_desc, - mod_loc: mexpr$1.mod_loc, - mod_type: mexpr$1.mod_type, - mod_env: mexpr$1.mod_env, - mod_attributes: mexpr$1.mod_attributes - }); - }; - var map_module_binding = function (x) { - return { - mb_id: x.mb_id, - mb_name: x.mb_name, - mb_expr: map_module_expr(x.mb_expr), - mb_attributes: x.mb_attributes, - mb_loc: x.mb_loc - }; - }; var map_expression = function (exp) { var exp$1 = Curry._1(funarg.enter_expression, exp); var list = exp$1.exp_desc; @@ -26807,158 +26636,6 @@ function TypedtreeMap_MakeMap(funarg) { exp_attributes: exp$1.exp_attributes }); }; - var map_class_declaration = function (cd) { - var cd$1 = Curry._1(funarg.enter_class_declaration, cd); - var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - var ci_expr = map_class_expr(cd$1.ci_expr); - return Curry._1(funarg.leave_class_declaration, { - ci_virt: cd$1.ci_virt, - ci_params: ci_params, - ci_id_name: cd$1.ci_id_name, - ci_id_class: cd$1.ci_id_class, - ci_id_class_type: cd$1.ci_id_class_type, - ci_id_object: cd$1.ci_id_object, - ci_id_typesharp: cd$1.ci_id_typesharp, - ci_expr: ci_expr, - ci_decl: cd$1.ci_decl, - ci_type_decl: cd$1.ci_type_decl, - ci_loc: cd$1.ci_loc, - ci_attributes: cd$1.ci_attributes - }); - }; - var map_constructor_declaration = function (cd) { - return { - cd_id: cd.cd_id, - cd_name: cd.cd_name, - cd_args: Stdlib__List.map(map_core_type, cd.cd_args), - cd_res: may_map(map_core_type, cd.cd_res), - cd_loc: cd.cd_loc, - cd_attributes: cd.cd_attributes - }; - }; - var map_signature = function (sg) { - var sg$1 = Curry._1(funarg.enter_signature, sg); - var sig_items = Stdlib__List.map(map_signature_item, sg$1.sig_items); - return Curry._1(funarg.leave_signature, { - sig_items: sig_items, - sig_type: sg$1.sig_type, - sig_final_env: sg$1.sig_final_env - }); - }; - var map_with_constraint = function (cstr) { - var cstr$1 = Curry._1(funarg.enter_with_constraint, cstr); - var tmp; - switch (cstr$1.TAG | 0) { - case /* Twith_type */0 : - tmp = { - TAG: /* Twith_type */0, - _0: map_type_declaration(cstr$1._0) - }; - break; - case /* Twith_typesubst */2 : - tmp = { - TAG: /* Twith_typesubst */2, - _0: map_type_declaration(cstr$1._0) - }; - break; - case /* Twith_module */1 : - case /* Twith_modsubst */3 : - tmp = cstr$1; - break; - - } - return Curry._1(funarg.leave_with_constraint, tmp); - }; - var map_class_field = function (cf) { - var cf$1 = Curry._1(funarg.enter_class_field, cf); - var exp = cf$1.cf_desc; - var cf_desc; - switch (exp.TAG | 0) { - case /* Tcf_inherit */0 : - cf_desc = { - TAG: /* Tcf_inherit */0, - _0: exp._0, - _1: map_class_expr(exp._1), - _2: exp._2, - _3: exp._3, - _4: exp._4 - }; - break; - case /* Tcf_val */1 : - var cty = exp._3; - var ident = exp._2; - var mut = exp._1; - var lab = exp._0; - cf_desc = cty.TAG === /* Tcfk_virtual */0 ? ({ - TAG: /* Tcf_val */1, - _0: lab, - _1: mut, - _2: ident, - _3: { - TAG: /* Tcfk_virtual */0, - _0: map_core_type(cty._0) - }, - _4: exp._4 - }) : ({ - TAG: /* Tcf_val */1, - _0: lab, - _1: mut, - _2: ident, - _3: { - TAG: /* Tcfk_concrete */1, - _0: cty._0, - _1: map_expression(cty._1) - }, - _4: exp._4 - }); - break; - case /* Tcf_method */2 : - var cty$1 = exp._2; - var priv = exp._1; - var lab$1 = exp._0; - cf_desc = cty$1.TAG === /* Tcfk_virtual */0 ? ({ - TAG: /* Tcf_method */2, - _0: lab$1, - _1: priv, - _2: { - TAG: /* Tcfk_virtual */0, - _0: map_core_type(cty$1._0) - } - }) : ({ - TAG: /* Tcf_method */2, - _0: lab$1, - _1: priv, - _2: { - TAG: /* Tcfk_concrete */1, - _0: cty$1._0, - _1: map_expression(cty$1._1) - } - }); - break; - case /* Tcf_constraint */3 : - cf_desc = { - TAG: /* Tcf_constraint */3, - _0: map_core_type(exp._0), - _1: map_core_type(exp._1) - }; - break; - case /* Tcf_initializer */4 : - cf_desc = { - TAG: /* Tcf_initializer */4, - _0: map_expression(exp._0) - }; - break; - case /* Tcf_attribute */5 : - cf_desc = exp; - break; - - } - return Curry._1(funarg.leave_class_field, { - cf_desc: cf_desc, - cf_loc: cf$1.cf_loc, - cf_attributes: cf$1.cf_attributes - }); - }; var map_pattern = function (pat) { var pat$1 = Curry._1(funarg.enter_pattern, pat); var list = pat$1.pat_desc; @@ -27047,37 +26724,212 @@ function TypedtreeMap_MakeMap(funarg) { pat_attributes: pat$1.pat_attributes }); }; - var map_class_expr = function (cexpr) { - var cexpr$1 = Curry._1(funarg.enter_class_expr, cexpr); - var clstr = cexpr$1.cl_desc; - var cl_desc; - switch (clstr.TAG | 0) { - case /* Tcl_ident */0 : - cl_desc = { - TAG: /* Tcl_ident */0, - _0: clstr._0, - _1: clstr._1, - _2: Stdlib__List.map(map_core_type, clstr._2) - }; - break; - case /* Tcl_structure */1 : - cl_desc = { - TAG: /* Tcl_structure */1, - _0: map_class_structure(clstr._0) - }; - break; - case /* Tcl_fun */2 : - cl_desc = { - TAG: /* Tcl_fun */2, - _0: clstr._0, - _1: map_pattern(clstr._1), - _2: Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_expression(param[2]) - ]; - }), clstr._2), + var map_pat_extra = function (pat_extra) { + var ct = pat_extra[0]; + if (typeof ct === "number" || ct.TAG !== /* Tpat_constraint */0) { + return pat_extra; + } else { + return [ + { + TAG: /* Tpat_constraint */0, + _0: map_core_type(ct._0) + }, + pat_extra[1], + pat_extra[2] + ]; + } + }; + var map_type_declaration = function (decl) { + var decl$1 = Curry._1(funarg.enter_type_declaration, decl); + var typ_params = Stdlib__List.map(map_type_parameter, decl$1.typ_params); + var typ_cstrs = Stdlib__List.map((function (param) { + return [ + map_core_type(param[0]), + map_core_type(param[1]), + param[2] + ]; + }), decl$1.typ_cstrs); + var list = decl$1.typ_kind; + var typ_kind; + if (typeof list === "number") { + typ_kind = list === /* Ttype_abstract */0 ? /* Ttype_abstract */0 : /* Ttype_open */1; + } else if (list.TAG === /* Ttype_variant */0) { + var list$1 = Stdlib__List.map(map_constructor_declaration, list._0); + typ_kind = { + TAG: /* Ttype_variant */0, + _0: list$1 + }; + } else { + var list$2 = Stdlib__List.map((function (ld) { + return { + ld_id: ld.ld_id, + ld_name: ld.ld_name, + ld_mutable: ld.ld_mutable, + ld_type: map_core_type(ld.ld_type), + ld_loc: ld.ld_loc, + ld_attributes: ld.ld_attributes + }; + }), list._0); + typ_kind = { + TAG: /* Ttype_record */1, + _0: list$2 + }; + } + var typ_manifest = may_map(map_core_type, decl$1.typ_manifest); + return Curry._1(funarg.leave_type_declaration, { + typ_id: decl$1.typ_id, + typ_name: decl$1.typ_name, + typ_params: typ_params, + typ_type: decl$1.typ_type, + typ_cstrs: typ_cstrs, + typ_kind: typ_kind, + typ_private: decl$1.typ_private, + typ_manifest: typ_manifest, + typ_loc: decl$1.typ_loc, + typ_attributes: decl$1.typ_attributes + }); + }; + var map_type_extension = function (tyext) { + var tyext$1 = Curry._1(funarg.enter_type_extension, tyext); + var tyext_params = Stdlib__List.map(map_type_parameter, tyext$1.tyext_params); + var tyext_constructors = Stdlib__List.map(map_extension_constructor, tyext$1.tyext_constructors); + return Curry._1(funarg.leave_type_extension, { + tyext_path: tyext$1.tyext_path, + tyext_txt: tyext$1.tyext_txt, + tyext_params: tyext_params, + tyext_constructors: tyext_constructors, + tyext_private: tyext$1.tyext_private, + tyext_attributes: tyext$1.tyext_attributes + }); + }; + var map_module_binding = function (x) { + return { + mb_id: x.mb_id, + mb_name: x.mb_name, + mb_expr: map_module_expr(x.mb_expr), + mb_attributes: x.mb_attributes, + mb_loc: x.mb_loc + }; + }; + var map_value_description = function (v) { + var v$1 = Curry._1(funarg.enter_value_description, v); + var val_desc = map_core_type(v$1.val_desc); + return Curry._1(funarg.leave_value_description, { + val_id: v$1.val_id, + val_name: v$1.val_name, + val_desc: val_desc, + val_val: v$1.val_val, + val_prim: v$1.val_prim, + val_loc: v$1.val_loc, + val_attributes: v$1.val_attributes + }); + }; + var map_module_type_declaration = function (mtd) { + var mtd$1 = Curry._1(funarg.enter_module_type_declaration, mtd); + return Curry._1(funarg.leave_module_type_declaration, { + mtd_id: mtd$1.mtd_id, + mtd_name: mtd$1.mtd_name, + mtd_type: may_map(map_module_type, mtd$1.mtd_type), + mtd_attributes: mtd$1.mtd_attributes, + mtd_loc: mtd$1.mtd_loc + }); + }; + var map_binding = function (vb) { + return { + vb_pat: map_pattern(vb.vb_pat), + vb_expr: map_expression(vb.vb_expr), + vb_attributes: vb.vb_attributes, + vb_loc: vb.vb_loc + }; + }; + var map_class_type_declaration = function (cd) { + var cd$1 = Curry._1(funarg.enter_class_type_declaration, cd); + var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); + var ci_expr = map_class_type(cd$1.ci_expr); + return Curry._1(funarg.leave_class_type_declaration, { + ci_virt: cd$1.ci_virt, + ci_params: ci_params, + ci_id_name: cd$1.ci_id_name, + ci_id_class: cd$1.ci_id_class, + ci_id_class_type: cd$1.ci_id_class_type, + ci_id_object: cd$1.ci_id_object, + ci_id_typesharp: cd$1.ci_id_typesharp, + ci_expr: ci_expr, + ci_decl: cd$1.ci_decl, + ci_type_decl: cd$1.ci_type_decl, + ci_loc: cd$1.ci_loc, + ci_attributes: cd$1.ci_attributes + }); + }; + var map_class_declaration = function (cd) { + var cd$1 = Curry._1(funarg.enter_class_declaration, cd); + var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); + var ci_expr = map_class_expr(cd$1.ci_expr); + return Curry._1(funarg.leave_class_declaration, { + ci_virt: cd$1.ci_virt, + ci_params: ci_params, + ci_id_name: cd$1.ci_id_name, + ci_id_class: cd$1.ci_id_class, + ci_id_class_type: cd$1.ci_id_class_type, + ci_id_object: cd$1.ci_id_object, + ci_id_typesharp: cd$1.ci_id_typesharp, + ci_expr: ci_expr, + ci_decl: cd$1.ci_decl, + ci_type_decl: cd$1.ci_type_decl, + ci_loc: cd$1.ci_loc, + ci_attributes: cd$1.ci_attributes + }); + }; + var map_class_description = function (cd) { + var cd$1 = Curry._1(funarg.enter_class_description, cd); + var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); + var ci_expr = map_class_type(cd$1.ci_expr); + return Curry._1(funarg.leave_class_description, { + ci_virt: cd$1.ci_virt, + ci_params: ci_params, + ci_id_name: cd$1.ci_id_name, + ci_id_class: cd$1.ci_id_class, + ci_id_class_type: cd$1.ci_id_class_type, + ci_id_object: cd$1.ci_id_object, + ci_id_typesharp: cd$1.ci_id_typesharp, + ci_expr: ci_expr, + ci_decl: cd$1.ci_decl, + ci_type_decl: cd$1.ci_type_decl, + ci_loc: cd$1.ci_loc, + ci_attributes: cd$1.ci_attributes + }); + }; + var map_class_expr = function (cexpr) { + var cexpr$1 = Curry._1(funarg.enter_class_expr, cexpr); + var clstr = cexpr$1.cl_desc; + var cl_desc; + switch (clstr.TAG | 0) { + case /* Tcl_ident */0 : + cl_desc = { + TAG: /* Tcl_ident */0, + _0: clstr._0, + _1: clstr._1, + _2: Stdlib__List.map(map_core_type, clstr._2) + }; + break; + case /* Tcl_structure */1 : + cl_desc = { + TAG: /* Tcl_structure */1, + _0: map_class_structure(clstr._0) + }; + break; + case /* Tcl_fun */2 : + cl_desc = { + TAG: /* Tcl_fun */2, + _0: clstr._0, + _1: map_pattern(clstr._1), + _2: Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_expression(param[2]) + ]; + }), clstr._2), _3: map_class_expr(clstr._3), _4: clstr._4 }; @@ -27261,45 +27113,173 @@ function TypedtreeMap_MakeMap(funarg) { str_env: item$1.str_env }); }; - var map_signature_item = function (item) { - var item$1 = Curry._1(funarg.enter_signature_item, item); - var vd = item$1.sig_desc; - var sig_desc; - switch (vd.TAG | 0) { - case /* Tsig_value */0 : - sig_desc = { - TAG: /* Tsig_value */0, - _0: map_value_description(vd._0) - }; - break; - case /* Tsig_type */1 : - sig_desc = { - TAG: /* Tsig_type */1, - _0: Stdlib__List.map(map_type_declaration, vd._0) - }; - break; - case /* Tsig_typext */2 : - sig_desc = { - TAG: /* Tsig_typext */2, - _0: map_type_extension(vd._0) - }; - break; - case /* Tsig_exception */3 : - sig_desc = { - TAG: /* Tsig_exception */3, - _0: map_extension_constructor(vd._0) + var map_class_field = function (cf) { + var cf$1 = Curry._1(funarg.enter_class_field, cf); + var exp = cf$1.cf_desc; + var cf_desc; + switch (exp.TAG | 0) { + case /* Tcf_inherit */0 : + cf_desc = { + TAG: /* Tcf_inherit */0, + _0: exp._0, + _1: map_class_expr(exp._1), + _2: exp._2, + _3: exp._3, + _4: exp._4 }; break; - case /* Tsig_module */4 : - var md = vd._0; - sig_desc = { - TAG: /* Tsig_module */4, - _0: { - md_id: md.md_id, - md_name: md.md_name, - md_type: map_module_type(md.md_type), - md_attributes: md.md_attributes, - md_loc: md.md_loc + case /* Tcf_val */1 : + var cty = exp._3; + var ident = exp._2; + var mut = exp._1; + var lab = exp._0; + cf_desc = cty.TAG === /* Tcfk_virtual */0 ? ({ + TAG: /* Tcf_val */1, + _0: lab, + _1: mut, + _2: ident, + _3: { + TAG: /* Tcfk_virtual */0, + _0: map_core_type(cty._0) + }, + _4: exp._4 + }) : ({ + TAG: /* Tcf_val */1, + _0: lab, + _1: mut, + _2: ident, + _3: { + TAG: /* Tcfk_concrete */1, + _0: cty._0, + _1: map_expression(cty._1) + }, + _4: exp._4 + }); + break; + case /* Tcf_method */2 : + var cty$1 = exp._2; + var priv = exp._1; + var lab$1 = exp._0; + cf_desc = cty$1.TAG === /* Tcfk_virtual */0 ? ({ + TAG: /* Tcf_method */2, + _0: lab$1, + _1: priv, + _2: { + TAG: /* Tcfk_virtual */0, + _0: map_core_type(cty$1._0) + } + }) : ({ + TAG: /* Tcf_method */2, + _0: lab$1, + _1: priv, + _2: { + TAG: /* Tcfk_concrete */1, + _0: cty$1._0, + _1: map_expression(cty$1._1) + } + }); + break; + case /* Tcf_constraint */3 : + cf_desc = { + TAG: /* Tcf_constraint */3, + _0: map_core_type(exp._0), + _1: map_core_type(exp._1) + }; + break; + case /* Tcf_initializer */4 : + cf_desc = { + TAG: /* Tcf_initializer */4, + _0: map_expression(exp._0) + }; + break; + case /* Tcf_attribute */5 : + cf_desc = exp; + break; + + } + return Curry._1(funarg.leave_class_field, { + cf_desc: cf_desc, + cf_loc: cf$1.cf_loc, + cf_attributes: cf$1.cf_attributes + }); + }; + var map_case = function (param) { + return { + c_lhs: map_pattern(param.c_lhs), + c_guard: may_map(map_expression, param.c_guard), + c_rhs: map_expression(param.c_rhs) + }; + }; + var map_row_field = function (rf) { + if (rf.TAG === /* Ttag */0) { + return { + TAG: /* Ttag */0, + _0: rf._0, + _1: rf._1, + _2: rf._2, + _3: Stdlib__List.map(map_core_type, rf._3) + }; + } else { + return { + TAG: /* Tinherit */1, + _0: map_core_type(rf._0) + }; + } + }; + var map_package_type = function (pack) { + var pack$1 = Curry._1(funarg.enter_package_type, pack); + var pack_fields = Stdlib__List.map((function (param) { + return [ + param[0], + map_core_type(param[1]) + ]; + }), pack$1.pack_fields); + return Curry._1(funarg.leave_package_type, { + pack_path: pack$1.pack_path, + pack_fields: pack_fields, + pack_type: pack$1.pack_type, + pack_txt: pack$1.pack_txt + }); + }; + var map_signature_item = function (item) { + var item$1 = Curry._1(funarg.enter_signature_item, item); + var vd = item$1.sig_desc; + var sig_desc; + switch (vd.TAG | 0) { + case /* Tsig_value */0 : + sig_desc = { + TAG: /* Tsig_value */0, + _0: map_value_description(vd._0) + }; + break; + case /* Tsig_type */1 : + sig_desc = { + TAG: /* Tsig_type */1, + _0: Stdlib__List.map(map_type_declaration, vd._0) + }; + break; + case /* Tsig_typext */2 : + sig_desc = { + TAG: /* Tsig_typext */2, + _0: map_type_extension(vd._0) + }; + break; + case /* Tsig_exception */3 : + sig_desc = { + TAG: /* Tsig_exception */3, + _0: map_extension_constructor(vd._0) + }; + break; + case /* Tsig_module */4 : + var md = vd._0; + sig_desc = { + TAG: /* Tsig_module */4, + _0: { + md_id: md.md_id, + md_name: md.md_name, + md_type: map_module_type(md.md_type), + md_attributes: md.md_attributes, + md_loc: md.md_loc } }; break; @@ -27361,6 +27341,72 @@ function TypedtreeMap_MakeMap(funarg) { sig_loc: item$1.sig_loc }); }; + var map_constructor_declaration = function (cd) { + return { + cd_id: cd.cd_id, + cd_name: cd.cd_name, + cd_args: Stdlib__List.map(map_core_type, cd.cd_args), + cd_res: may_map(map_core_type, cd.cd_res), + cd_loc: cd.cd_loc, + cd_attributes: cd.cd_attributes + }; + }; + var map_class_type_field = function (ctf) { + var ctf$1 = Curry._1(funarg.enter_class_type_field, ctf); + var ct = ctf$1.ctf_desc; + var ctf_desc; + switch (ct.TAG | 0) { + case /* Tctf_inherit */0 : + ctf_desc = { + TAG: /* Tctf_inherit */0, + _0: map_class_type(ct._0) + }; + break; + case /* Tctf_val */1 : + var match = ct._0; + ctf_desc = { + TAG: /* Tctf_val */1, + _0: [ + match[0], + match[1], + match[2], + map_core_type(match[3]) + ] + }; + break; + case /* Tctf_method */2 : + var match$1 = ct._0; + ctf_desc = { + TAG: /* Tctf_method */2, + _0: [ + match$1[0], + match$1[1], + match$1[2], + map_core_type(match$1[3]) + ] + }; + break; + case /* Tctf_constraint */3 : + var match$2 = ct._0; + ctf_desc = { + TAG: /* Tctf_constraint */3, + _0: [ + map_core_type(match$2[0]), + map_core_type(match$2[1]) + ] + }; + break; + case /* Tctf_attribute */4 : + ctf_desc = ct; + break; + + } + return Curry._1(funarg.leave_class_type_field, { + ctf_desc: ctf_desc, + ctf_loc: ctf$1.ctf_loc, + ctf_attributes: ctf$1.ctf_attributes + }); + }; var map_class_structure = function (cs) { var cs$1 = Curry._1(funarg.enter_class_structure, cs); var cstr_self = map_pattern(cs$1.cstr_self); @@ -27372,69 +27418,23 @@ function TypedtreeMap_MakeMap(funarg) { cstr_meths: cs$1.cstr_meths }); }; - var map_row_field = function (rf) { - if (rf.TAG === /* Ttag */0) { - return { - TAG: /* Ttag */0, - _0: rf._0, - _1: rf._1, - _2: rf._2, - _3: Stdlib__List.map(map_core_type, rf._3) - }; - } else { - return { - TAG: /* Tinherit */1, - _0: map_core_type(rf._0) - }; - } - }; - var map_package_type = function (pack) { - var pack$1 = Curry._1(funarg.enter_package_type, pack); - var pack_fields = Stdlib__List.map((function (param) { - return [ - param[0], - map_core_type(param[1]) - ]; - }), pack$1.pack_fields); - return Curry._1(funarg.leave_package_type, { - pack_path: pack$1.pack_path, - pack_fields: pack_fields, - pack_type: pack$1.pack_type, - pack_txt: pack$1.pack_txt - }); - }; - var map_pat_extra = function (pat_extra) { - var ct = pat_extra[0]; - if (typeof ct === "number" || ct.TAG !== /* Tpat_constraint */0) { - return pat_extra; - } else { - return [ - { - TAG: /* Tpat_constraint */0, - _0: map_core_type(ct._0) - }, - pat_extra[1], - pat_extra[2] - ]; - } - }; - var map_exp_extra = function (exp_extra) { - var attrs = exp_extra[2]; - var loc = exp_extra[1]; - var desc = exp_extra[0]; - switch (desc.TAG | 0) { - case /* Texp_constraint */0 : - return [ - { - TAG: /* Texp_constraint */0, - _0: map_core_type(desc._0) - }, - loc, - attrs - ]; - case /* Texp_coerce */1 : - var ct1 = desc._0; - if (ct1 !== undefined) { + var map_exp_extra = function (exp_extra) { + var attrs = exp_extra[2]; + var loc = exp_extra[1]; + var desc = exp_extra[0]; + switch (desc.TAG | 0) { + case /* Texp_constraint */0 : + return [ + { + TAG: /* Texp_constraint */0, + _0: map_core_type(desc._0) + }, + loc, + attrs + ]; + case /* Texp_coerce */1 : + var ct1 = desc._0; + if (ct1 !== undefined) { return [ { TAG: /* Texp_coerce */1, @@ -33169,97 +33169,6 @@ function unify(env, t1, t2) { } } -function unify2(env, t1, t2) { - var expand_both = function (_t1$p$p, _t2$p$p) { - while(true) { - var t2$p$p = _t2$p$p; - var t1$p$p = _t1$p$p; - var t1$p = expand_head_unif(env.contents, t1); - var t2$p = expand_head_unif(env.contents, t2); - if (unify_eq(env.contents, t1$p, t1$p$p) && unify_eq(env.contents, t2$p, t2$p$p)) { - return [ - t1$p, - t2$p - ]; - } - _t2$p$p = t2$p; - _t1$p$p = t1$p; - continue ; - }; - }; - var match = expand_both(t1, t2); - var t2$p = match[1]; - var t1$p = match[0]; - var lv = t1$p.level < t2$p.level ? t1$p.level : t2$p.level; - update_level(env.contents, lv, t2); - update_level(env.contents, lv, t1); - if (unify_eq(env.contents, t1$p, t2$p)) { - return ; - } - var t1$1 = repr(t1); - var t2$1 = repr(t2); - if (trace_gadt_instances.contents) { - var ilevel = function (t) { - var lv = gadt_instance_level(env.contents, t); - if (lv !== undefined) { - return lv; - } else { - return 0; - } - }; - var lv1 = ilevel(t1$1); - var lv2 = ilevel(t2$1); - if (lv1 > lv2) { - add_gadt_instance_chain(env.contents, lv1, t2$1); - } else if (lv2 > lv1) { - add_gadt_instance_chain(env.contents, lv2, t1$1); - } - - } - var match$1; - if (principal.contents && (find_lowest_level(t1$p) < lv || find_lowest_level(t2$p) < lv)) { - var match$2 = t1$1.desc; - var tmp; - tmp = typeof match$2 === "number" || !(match$2.TAG === /* Tconstr */3 && !match$2._1) ? t1$1 : t1$p; - var match$3 = t2$1.desc; - var tmp$1; - tmp$1 = typeof match$3 === "number" || !(match$3.TAG === /* Tconstr */3 && !match$3._1) ? t2$1 : t2$p; - match$1 = [ - tmp, - tmp$1 - ]; - } else { - match$1 = [ - t1$1, - t2$1 - ]; - } - var t2$2 = match$1[1]; - var t1$2 = match$1[0]; - if (unify_eq(env.contents, t1$2, t1$p) || !unify_eq(env.contents, t2$2, t2$p)) { - return unify3(env, t1$2, t1$p, t2$2, t2$p); - } - try { - return unify3(env, t2$2, t2$p, t1$2, t1$p); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === Unify) { - throw { - RE_EXN_ID: Unify, - _1: Stdlib__List.map((function (param) { - return [ - param[1], - param[0] - ]; - }), exn._1), - Error: new Error() - }; - } - throw exn; - } -} - function make_rowvar(level, use1, rest1, use2, rest2) { var set_name = function (ty, name) { var match = ty.desc; @@ -33370,1227 +33279,1318 @@ function unify_kind(k1, k2) { }; } -function unify_fields(env, ty1, ty2) { - var match = flatten_fields(ty1); - var rest1 = match[1]; - var match$1 = flatten_fields(ty2); - var rest2 = match$1[1]; - var match$2 = associate_fields(match[0], match$1[0]); - var miss2 = match$2[2]; - var miss1 = match$2[1]; - var l1 = repr(ty1).level; - var l2 = repr(ty2).level; - var va = make_rowvar(l1 < l2 ? l1 : l2, Caml_obj.caml_equal(miss2, /* [] */0), rest1, Caml_obj.caml_equal(miss1, /* [] */0), rest2); - var d1 = rest1.desc; - var d2 = rest2.desc; - try { - unify(env, build_fields(l1)(miss1, va), rest2); - unify(env, rest1, build_fields(l2)(miss2, va)); - return Stdlib__List.iter((function (param) { - var t2 = param[4]; - var k2 = param[3]; - var t1 = param[2]; - var k1 = param[1]; - var n = param[0]; - unify_kind(k1, k2); - try { - if (trace_gadt_instances.contents) { - update_level(env.contents, va.level, t1); - } - return unify(env, t1, t2); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === Unify) { - var desc_3 = newty2(current_level.contents, /* Tnil */0); - var desc = { - TAG: /* Tfield */5, - _0: n, - _1: k1, - _2: t1, - _3: desc_3 - }; - var desc_3$1 = newty2(current_level.contents, /* Tnil */0); - var desc$1 = { - TAG: /* Tfield */5, - _0: n, - _1: k2, - _2: t2, - _3: desc_3$1 - }; - throw { - RE_EXN_ID: Unify, - _1: { - hd: [ - newty2(current_level.contents, desc), - newty2(current_level.contents, desc$1) - ], - tl: exn._1 - }, - Error: new Error() - }; - } - throw exn; - } - }), match$2[0]); - } - catch (exn){ - log_type(rest1); - rest1.desc = d1; - log_type(rest2); - rest2.desc = d2; - throw exn; - } -} - -function unify_row(env, row1, row2) { - var row1$1 = row_repr_aux(/* [] */0, row1); - var row2$1 = row_repr_aux(/* [] */0, row2); - var rm1 = row_more(row1$1); - var rm2 = row_more(row2$1); - if (unify_eq(env.contents, rm1, rm2)) { +function unify2(env, t1, t2) { + var expand_both = function (_t1$p$p, _t2$p$p) { + while(true) { + var t2$p$p = _t2$p$p; + var t1$p$p = _t1$p$p; + var t1$p = expand_head_unif(env.contents, t1); + var t2$p = expand_head_unif(env.contents, t2); + if (unify_eq(env.contents, t1$p, t1$p$p) && unify_eq(env.contents, t2$p, t2$p$p)) { + return [ + t1$p, + t2$p + ]; + } + _t2$p$p = t2$p; + _t1$p$p = t1$p; + continue ; + }; + }; + var match = expand_both(t1, t2); + var t2$p = match[1]; + var t1$p = match[0]; + var lv = t1$p.level < t2$p.level ? t1$p.level : t2$p.level; + update_level(env.contents, lv, t2); + update_level(env.contents, lv, t1); + if (unify_eq(env.contents, t1$p, t2$p)) { return ; } - var match = merge_row_fields(row1$1.row_fields, row2$1.row_fields); - var pairs = match[2]; - var r2 = match[1]; - var r1 = match[0]; - if (Caml_obj.caml_notequal(r1, /* [] */0) && Caml_obj.caml_notequal(r2, /* [] */0)) { - var ht = Stdlib__Hashtbl.create(undefined, Stdlib__List.length(r1)); - Stdlib__List.iter((function (param) { - var l = param[0]; - Stdlib__Hashtbl.add(ht, hash_variant(l), l); - }), r1); - Stdlib__List.iter((function (param) { - var l = param[0]; - try { - throw { - RE_EXN_ID: Tags, - _1: l, - _2: Stdlib__Hashtbl.find(ht, hash_variant(l)), - Error: new Error() - }; - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === Stdlib.Not_found) { - return ; - } - throw exn; - } - }), r2); + var t1$1 = repr(t1); + var t2$1 = repr(t2); + if (trace_gadt_instances.contents) { + var ilevel = function (t) { + var lv = gadt_instance_level(env.contents, t); + if (lv !== undefined) { + return lv; + } else { + return 0; + } + }; + var lv1 = ilevel(t1$1); + var lv2 = ilevel(t2$1); + if (lv1 > lv2) { + add_gadt_instance_chain(env.contents, lv1, t2$1); + } else if (lv2 > lv1) { + add_gadt_instance_chain(env.contents, lv2, t1$1); + } + } - var fixed1 = row_fixed(row1$1); - var fixed2 = row_fixed(row2$1); - var more = fixed1 ? rm1 : ( - fixed2 ? rm2 : newty2(rm1.level < rm2.level ? rm1.level : rm2.level, { - TAG: /* Tvar */0, - _0: undefined - }) - ); - var fixed = fixed1 || fixed2; - var closed = row1$1.row_closed || row2$1.row_closed; - var keep = function ($$switch) { - return Stdlib__List.for_all((function (param) { - var match = Curry._2($$switch, param[1], param[2]); - if (Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, match[0]), /* Rabsent */0)) { - return true; - } else { - return Caml_obj.caml_notequal(row_field_repr_aux(/* [] */0, match[1]), /* Rabsent */0); - } - }), pairs); - }; - var empty = function (fields) { - return Stdlib__List.for_all((function (param) { - return Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, param[1]), /* Rabsent */0); - }), fields); - }; - if (closed && (empty(r1) || row2$1.row_closed) && (empty(r2) || row1$1.row_closed) && Stdlib__List.for_all((function (param) { - if (Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, param[1]), /* Rabsent */0)) { - return true; - } else { - return Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, param[2]), /* Rabsent */0); - } - }), pairs)) { - throw { - RE_EXN_ID: Unify, - _1: { - hd: [ - mkvariant(/* [] */0, true), - mkvariant(/* [] */0, true) - ], - tl: /* [] */0 - }, - Error: new Error() - }; + var match$1; + if (principal.contents && (find_lowest_level(t1$p) < lv || find_lowest_level(t2$p) < lv)) { + var match$2 = t1$1.desc; + var tmp; + tmp = typeof match$2 === "number" || !(match$2.TAG === /* Tconstr */3 && !match$2._1) ? t1$1 : t1$p; + var match$3 = t2$1.desc; + var tmp$1; + tmp$1 = typeof match$3 === "number" || !(match$3.TAG === /* Tconstr */3 && !match$3._1) ? t2$1 : t2$p; + match$1 = [ + tmp, + tmp$1 + ]; + } else { + match$1 = [ + t1$1, + t2$1 + ]; } - var name = row1$1.row_name !== undefined && (row1$1.row_closed || empty(r2)) && (!row2$1.row_closed || keep(function (f1, f2) { - return [ - f1, - f2 - ]; - }) && empty(r1)) ? row1$1.row_name : ( - row2$1.row_name !== undefined && (row2$1.row_closed || empty(r1)) && (!row1$1.row_closed || keep(function (f1, f2) { - return [ - f2, - f1 - ]; - }) && empty(r2)) ? row2$1.row_name : undefined - ); - var set_more = function (row, rest) { - var rest$1 = closed ? filter_row_fields(row.row_closed, rest) : rest; - if (Caml_obj.caml_notequal(rest$1, /* [] */0) && (row.row_closed || row_fixed(row)) || closed && row_fixed(row) && !row.row_closed) { - var t1 = mkvariant(/* [] */0, true); - var t2 = mkvariant(rest$1, false); + var t2$2 = match$1[1]; + var t1$2 = match$1[0]; + if (unify_eq(env.contents, t1$2, t1$p) || !unify_eq(env.contents, t2$2, t2$p)) { + return unify3(env, t1$2, t1$p, t2$2, t2$p); + } + try { + return unify3(env, t2$2, t2$p, t1$2, t1$p); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Unify) { throw { RE_EXN_ID: Unify, - _1: { - hd: row === row1$1 ? [ - t1, - t2 - ] : [ - t2, - t1 - ], - tl: /* [] */0 - }, + _1: Stdlib__List.map((function (param) { + return [ + param[1], + param[0] + ]; + }), exn._1), Error: new Error() }; } - var rm = row_more(row); - if (trace_gadt_instances.contents && Caml_obj.caml_equal(rm.desc, /* Tnil */0) || !trace_gadt_instances.contents) { - - } else { - update_level(env.contents, rm.level, newty2(100000000, { - TAG: /* Tvariant */8, - _0: row - })); + throw exn; + } +} + +function unify3(env, t1, t1$p, t2, t2$p) { + var d1 = t1$p.desc; + var d2 = t2$p.desc; + var create_recursion = t2 !== t2$p && deep_occur(t1$p, t2); + var exit = 0; + var exit$1 = 0; + if (typeof d1 === "number") { + exit$1 = 2; + } else { + switch (d1.TAG | 0) { + case /* Tvar */0 : + occur(env.contents, t1$p, t2); + occur_univar(env.contents, t2); + return link_type(t1$p, t2); + case /* Tfield */5 : + if (typeof d2 === "number") { + exit = 1; + } else { + switch (d2.TAG | 0) { + case /* Tvar */0 : + exit$1 = 2; + break; + case /* Tfield */5 : + return unify_fields(env, t1$p, t2$p); + default: + exit = 1; + } + } + break; + case /* Tunivar */9 : + if (typeof d2 === "number") { + exit = 1; + } else { + switch (d2.TAG | 0) { + case /* Tvar */0 : + exit$1 = 2; + break; + case /* Tunivar */9 : + unify_univar(t1$p, t2$p, univar_pairs.contents); + return link_type(t1$p, t2$p); + default: + exit = 1; + } + } + break; + default: + exit$1 = 2; } - if (row_fixed(row)) { - if (more === rm) { - return ; - } else if (is_Tvar(rm)) { - return link_type(rm, more); - } else { - return unify(env, rm, more); + } + if (exit$1 === 2) { + if (typeof d2 === "number") { + exit = 1; + } else { + if (d2.TAG === /* Tvar */0) { + occur(env.contents, t2$p, t1); + occur_univar(env.contents, t1); + return link_type(t2$p, t1); } + exit = 1; } - var ty = newty2(100000000, { - TAG: /* Tvariant */8, - _0: { - row_fields: rest$1, - row_more: more, - row_bound: undefined, - row_closed: closed, - row_fixed: fixed, - row_name: name + } + if (exit === 1) { + var match = umode.contents; + if (match) { + add_type_equality(t1$p, t2$p); + } else { + occur(env.contents, t1$p, t2$p); + link_type(t1$p, t2); + } + try { + var exit$2 = 0; + var f; + var kind; + var rem; + var exit$3 = 0; + var exit$4 = 0; + if (typeof d1 === "number") { + if (typeof d2 !== "number") { + switch (d2.TAG | 0) { + case /* Tconstr */3 : + exit$4 = 5; + break; + case /* Tfield */5 : + f = d2._0; + kind = d2._1; + rem = d2._3; + exit$2 = 3; + break; + default: + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; } - }); - update_level(env.contents, rm.level, ty); - link_type(rm, ty); - }; - var md1 = rm1.desc; - var md2 = rm2.desc; - try { - set_more(row2$1, r1); - set_more(row1$1, r2); - return Stdlib__List.iter((function (param) { - var f2 = param[2]; - var f1 = param[1]; - var l = param[0]; - try { - var _f1 = f1; - var _f2 = f2; - while(true) { - var f2$1 = _f2; - var f1$1 = _f1; - var f1$2 = row_field_repr_aux(/* [] */0, f1$1); - var f2$2 = row_field_repr_aux(/* [] */0, f2$1); - if (f1$2 === f2$2) { - return ; - } - if (typeof f1$2 === "number") { - if (typeof f2$2 === "number") { - return ; - } - if (f2$2.TAG === /* Rpresent */0) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + } + + } else { + switch (d1.TAG | 0) { + case /* Tarrow */1 : + var l1 = d1._0; + if (typeof d2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + switch (d2.TAG | 0) { + case /* Tarrow */1 : + var l2 = d2._0; + if (l1 === l2 || classic.contents && !(is_optional(l1) || is_optional(l2))) { + unify(env, d1._1, d2._1); + unify(env, d1._2, d2._2); + var match$1 = commu_repr(d1._3); + var match$2 = commu_repr(d2._3); + if (typeof match$1 === "number") { + if (typeof match$2 === "number") { + + } else { + set_commu(match$2._0, match$1); } - if (f2$2._2) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + } else { + set_commu(match$1._0, match$2); + } + } else { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + case /* Tconstr */3 : + exit$4 = 5; + break; + default: + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + case /* Ttuple */2 : + if (typeof d2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + switch (d2.TAG | 0) { + case /* Ttuple */2 : + unify_list(env, d1._0, d2._0); + break; + case /* Tconstr */3 : + exit$4 = 5; + break; + default: + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + case /* Tconstr */3 : + var p1 = d1._0; + var exit$5 = 0; + if (typeof d2 === "number" || d2.TAG !== /* Tconstr */3) { + exit$5 = 6; + } else { + var tl2 = d2._1; + var tl1 = d1._1; + if (same(p1, d2._0)) { + if (umode.contents === /* Expression */0 || !generate_equations.contents) { + unify_list(env, tl1, tl2); + } else if (assume_injective.contents) { + set_mode_pattern(true, false, (function (param) { + unify_list(env, tl1, tl2); + })); + } else { + var tmp = true; + if (!in_current_module(p1)) { + var partial_arg = env.contents; + tmp = Stdlib__List.exists((function (param) { + return expands_to_datatype(partial_arg, param); + }), { + hd: t1$p, + tl: { + hd: t1, + tl: { + hd: t2, + tl: /* [] */0 + } + } + }); + } + if (tmp) { + unify_list(env, tl1, tl2); + } else { + var inj; + try { + inj = Stdlib__List.map(Curry._1(Types_Variance.mem, /* Inj */3), find_type_full(p1, env.contents)[0].type_variance); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + inj = Stdlib__List.map((function (param) { + return false; + }), tl1); + } else { + throw exn; } - if (!fixed2) { - return set_row_field(f2$2._3, f1$2); + } + Stdlib__List.iter2((function (i, param) { + var t2 = param[1]; + var t1 = param[0]; + if (i) { + return unify(env, t1, t2); + } else { + return set_mode_pattern(false, false, (function (param) { + var snap = snapshot(undefined); + try { + return unify(env, t1, t2); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Unify) { + backtrack(snap); + reify(env, t1); + return reify(env, t2); + } + throw exn; + } + })); + } + }), inj, Stdlib__List.combine(tl1, tl2)); + } + } + } else { + exit$5 = 6; + } + } + if (exit$5 === 6) { + switch (p1.TAG | 0) { + case /* Pident */0 : + if (d1._1) { + exit$4 = 5; + } else { + var p = p1._0; + var exit$6 = 0; + if (typeof d2 === "number" || d2.TAG !== /* Tconstr */3) { + exit$6 = 7; + } else { + var path$p = d2._0; + switch (path$p.TAG | 0) { + case /* Pident */0 : + if (d2._1 || !(is_newtype(env.contents, p1) && is_newtype(env.contents, path$p) && generate_equations.contents)) { + exit$6 = 7; + } else { + var match$3 = Caml_obj.caml_greaterthan(find_newtype_level(env.contents, p1), find_newtype_level(env.contents, path$p)) ? [ + p, + t2$p + ] : [ + path$p._0, + t1$p + ]; + add_gadt_equation(env, match$3[0], match$3[1]); + } + break; + case /* Pdot */1 : + case /* Papply */2 : + exit$6 = 7; + break; + + } } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } else if (f1$2.TAG === /* Rpresent */0) { - var t1 = f1$2._0; - if (t1 !== undefined) { - if (typeof f2$2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + if (exit$6 === 7) { + if (is_newtype(env.contents, p1) && generate_equations.contents) { + reify(env, t2$p); + add_gadt_equation(env, p, t2$p); + } else { + exit$4 = 5; } - if (f2$2.TAG === /* Rpresent */0) { - var t2 = f2$2._0; - if (t2 !== undefined) { - return unify(env, t1, t2); + } + + } + break; + case /* Pdot */1 : + case /* Papply */2 : + exit$4 = 5; + break; + + } + } + break; + case /* Tobject */4 : + if (typeof d2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + switch (d2.TAG | 0) { + case /* Tconstr */3 : + exit$4 = 5; + break; + case /* Tobject */4 : + unify_fields(env, d1._0, d2._0); + var match$4 = repr(t2$p).desc; + if (typeof match$4 !== "number" && match$4.TAG === /* Tobject */4) { + var exit$7 = 0; + var match$5 = match$4._1.contents; + if (match$5 !== undefined) { + var match$6 = match$5[1]; + if (match$6) { + var match$7 = repr(match$6.hd).desc; + var tmp$1; + if (typeof match$7 === "number") { + tmp$1 = true; + } else { + switch (match$7.TAG | 0) { + case /* Tvar */0 : + case /* Tunivar */9 : + tmp$1 = true; + break; + default: + tmp$1 = false; } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (f2$2._0) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (fixed2) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; } - var e2 = f2$2._3; - set_row_field(e2, f1$2); - update_level(env.contents, repr(more).level, t1); - try { - return Stdlib__List.iter((function(t1){ - return function (param) { - return unify(env, t1, param); - } - }(t1)), f2$2._1); - } - catch (exn){ - e2.contents = undefined; - throw exn; + if (!tmp$1) { + exit$7 = 6; } + } else { - if (typeof f2$2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (f2$2.TAG === /* Rpresent */0) { - if (f2$2._0 === undefined) { - return ; - } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (f2$2._0) { - if (f2$2._1) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (!fixed2) { - return set_row_field(f2$2._3, f1$2); - } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + exit$7 = 6; + } + } else { + exit$7 = 6; + } + if (exit$7 === 6) { + set_name(match$4._1, d1._1.contents); + } + + } + break; + default: + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + case /* Tfield */5 : + if (typeof d2 === "number") { + f = d1._0; + kind = d1._1; + rem = d1._3; + exit$2 = 3; + } else if (d2.TAG === /* Tconstr */3) { + exit$4 = 5; + } else { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + case /* Tvariant */8 : + var row1 = d1._0; + if (typeof d2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + switch (d2.TAG | 0) { + case /* Tconstr */3 : + exit$4 = 5; + break; + case /* Tvariant */8 : + var row2 = d2._0; + if (umode.contents === /* Expression */0) { + unify_row(env, row1, row2); + } else { + var snap = snapshot(undefined); + try { + unify_row(env, row1, row2); + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.RE_EXN_ID === Unify) { + backtrack(snap); + reify(env, t1$p); + reify(env, t2$p); + if (generate_equations.contents) { + mcomp$1(env.contents, t1$p, t2$p); } + + } else { + throw exn$1; + } + } + } + break; + default: + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + case /* Tpoly */10 : + var tl1$1 = d1._1; + var t1$1 = d1._0; + var exit$8 = 0; + if (tl1$1) { + exit$8 = 6; + } else { + if (typeof d2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + switch (d2.TAG | 0) { + case /* Tconstr */3 : + exit$4 = 5; + break; + case /* Tpoly */10 : + if (d2._1) { + exit$8 = 6; + } else { + unify(env, t1$1, d2._0); + } + break; + default: + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + } + if (exit$8 === 6) { + if (typeof d2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + switch (d2.TAG | 0) { + case /* Tconstr */3 : + exit$4 = 5; + break; + case /* Tpoly */10 : + enter_poly(env.contents, univar_pairs, t1$1, tl1$1, d2._0, d2._1, (function (param, param$1) { + return unify(env, param, param$1); + })); + break; + default: + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + } + break; + case /* Tpackage */11 : + var tl1$2 = d1._2; + if (typeof d2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + switch (d2.TAG | 0) { + case /* Tconstr */3 : + exit$4 = 5; + break; + case /* Tpackage */11 : + var tl2$1 = d2._2; + try { + unify_package(env.contents, (function (param, param$1) { + return unify_list(env, param, param$1); + }), t1.level, d1._0, d1._1, tl1$2, t2.level, d2._0, d2._1, tl2$1); + } + catch (raw_exn$2){ + var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); + if (exn$2.RE_EXN_ID === Stdlib.Not_found) { + if (umode.contents === /* Expression */0) { throw { RE_EXN_ID: Unify, _1: /* [] */0, Error: new Error() }; } + Stdlib__List.iter((function (param) { + return reify(env, param); + }), Stdlib.$at(tl1$2, tl2$1)); } else { - var c1 = f1$2._0; - var m1 = f1$2._2; - var tl1 = f1$2._1; - var e1 = f1$2._3; - if (typeof f2$2 === "number") { - if (m1) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (!fixed1) { - return set_row_field(f1$2._3, f2$2); - } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (f2$2.TAG === /* Rpresent */0) { - if (c1) { - if (f1$2._1) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (f2$2._0 !== undefined) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (!fixed1) { - return set_row_field(f1$2._3, f2$2); - } - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - var t2$1 = f2$2._0; - if (t2$1 !== undefined) { - if (fixed1) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - var e1$1 = f1$2._3; - set_row_field(e1$1, f2$2); - update_level(env.contents, repr(more).level, t2$1); - try { - return Stdlib__List.iter((function(t2$1){ - return function (t1) { - unify(env, t1, t2$1); - } - }(t2$1)), f1$2._1); - } - catch (exn$1){ - e1$1.contents = undefined; - throw exn$1; - } - } else { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - } else { - var e2$1 = f2$2._3; - if (e1 === e2$1) { - return ; - } - var m2 = f2$2._2; - var tl2 = f2$2._1; - var c2 = f2$2._0; - var redo = false; - if (m1 || m2 || fixed1 || fixed2 || rigid_variants.contents && (Stdlib__List.length(tl1) === 1 || Stdlib__List.length(tl2) === 1)) { - var match = Stdlib.$at(tl1, tl2); - var tmp; - if (match) { - var t1$1 = match.hd; - if (c1 || c2) { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - Stdlib__List.iter((function(t1$1){ - return function (param) { - return unify(env, t1$1, param); - } - }(t1$1)), match.tl); - tmp = e1.contents !== undefined || e2$1.contents !== undefined; - } else { - tmp = false; - } - redo = tmp; - } - if (redo) { - _f2 = f2$2; - _f1 = f1$2; - continue ; - } - var tl1$1 = Stdlib__List.map(repr, tl1); - var tl2$1 = Stdlib__List.map(repr, tl2); - var remq = function (tl, _param) { - while(true) { - var param = _param; - if (!param) { - return /* [] */0; - } - var tl$p = param.tl; - var ty = param.hd; - if (!Stdlib__List.memq(ty, tl)) { - return { - hd: ty, - tl: remq(tl, tl$p) - }; - } - _param = tl$p; - continue ; - }; - }; - var tl2$p = remq(tl2$1, tl1$1); - var tl1$p = remq(tl1$1, tl2$1); - var partial_arg = repr(more).level; - var partial_arg$1 = env.contents; - Stdlib__List.iter((function(partial_arg,partial_arg$1){ - return function (param) { - return update_level(partial_arg$1, partial_arg, param); - } - }(partial_arg,partial_arg$1)), Stdlib.$at(tl1$p, tl2$p)); - var e = { - contents: undefined - }; - var f1$p_0 = c1 || c2; - var f1$p_2 = m1 || m2; - var f1$p = { - TAG: /* Reither */1, - _0: f1$p_0, - _1: tl1$p, - _2: f1$p_2, - _3: e - }; - var f2$p_0 = c1 || c2; - var f2$p_2 = m1 || m2; - var f2$p = { - TAG: /* Reither */1, - _0: f2$p_0, - _1: tl2$p, - _2: f2$p_2, - _3: e - }; - set_row_field(e1, f1$p); - return set_row_field(e2$1, f2$p); - } + throw exn$2; } - }; - } - catch (raw_exn){ - var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn$2.RE_EXN_ID === Unify) { - throw { - RE_EXN_ID: Unify, - _1: { - hd: [ - mkvariant({ - hd: [ - l, - f1 - ], - tl: /* [] */0 - }, true), - mkvariant({ - hd: [ - l, - f2 - ], - tl: /* [] */0 - }, true) - ], - tl: exn$2._1 - }, - Error: new Error() - }; } - throw exn$2; - } - }), pairs); - } - catch (exn){ - log_type(rm1); - rm1.desc = md1; - log_type(rm2); - rm2.desc = md2; - throw exn; + break; + default: + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + default: + exit$4 = 5; + } + } + if (exit$4 === 5) { + if (typeof d2 === "number" || d2.TAG !== /* Tconstr */3) { + exit$3 = 4; + } else { + var path = d2._0; + switch (path.TAG | 0) { + case /* Pident */0 : + if (d2._1 || !(is_newtype(env.contents, path) && generate_equations.contents)) { + exit$2 = 2; + } else { + reify(env, t1$p); + add_gadt_equation(env, path._0, t1$p); + } + break; + case /* Pdot */1 : + case /* Papply */2 : + exit$2 = 2; + break; + + } + } + } + if (exit$3 === 4) { + if (typeof d1 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (d1.TAG === /* Tconstr */3) { + exit$2 = 2; + } else { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + } + switch (exit$2) { + case 2 : + if (umode.contents === /* Pattern */1) { + reify(env, t1$p); + reify(env, t2$p); + if (generate_equations.contents) { + mcomp$1(env.contents, t1$p, t2$p); + } + + } else { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + case 3 : + var r = field_kind_repr(kind); + if (typeof r === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (f !== dummy_method) { + set_kind(r._0, /* Fabsent */1); + if (Caml_obj.caml_equal(d2, /* Tnil */0)) { + unify(env, rem, t2$p); + } else { + unify(env, newty2(rem.level, /* Tnil */0), rem); + } + } else { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + break; + + } + if (!create_recursion) { + return ; + } + var match$8 = t2.desc; + if (typeof match$8 === "number") { + return ; + } + if (match$8.TAG !== /* Tconstr */3) { + return ; + } + forget_abbrev(match$8._2, match$8._0); + var t2$p$p = expand_head_unif(env.contents, t2); + if (!closed_parameterized_type(match$8._1, t2$p$p)) { + return link_type(repr(t2), repr(t2$p)); + } else { + return ; + } + } + catch (raw_exn$3){ + var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); + if (exn$3.RE_EXN_ID === Unify) { + t1$p.desc = d1; + throw { + RE_EXN_ID: Unify, + _1: exn$3._1, + Error: new Error() + }; + } + throw exn$3; + } } + } -function unify_list(env, tl1, tl2) { - if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { +function unify_row(env, row1, row2) { + var row1$1 = row_repr_aux(/* [] */0, row1); + var row2$1 = row_repr_aux(/* [] */0, row2); + var rm1 = row_more(row1$1); + var rm2 = row_more(row2$1); + if (unify_eq(env.contents, rm1, rm2)) { + return ; + } + var match = merge_row_fields(row1$1.row_fields, row2$1.row_fields); + var pairs = match[2]; + var r2 = match[1]; + var r1 = match[0]; + if (Caml_obj.caml_notequal(r1, /* [] */0) && Caml_obj.caml_notequal(r2, /* [] */0)) { + var ht = Stdlib__Hashtbl.create(undefined, Stdlib__List.length(r1)); + Stdlib__List.iter((function (param) { + var l = param[0]; + Stdlib__Hashtbl.add(ht, hash_variant(l), l); + }), r1); + Stdlib__List.iter((function (param) { + var l = param[0]; + try { + throw { + RE_EXN_ID: Tags, + _1: l, + _2: Stdlib__Hashtbl.find(ht, hash_variant(l)), + Error: new Error() + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + return ; + } + throw exn; + } + }), r2); + } + var fixed1 = row_fixed(row1$1); + var fixed2 = row_fixed(row2$1); + var more = fixed1 ? rm1 : ( + fixed2 ? rm2 : newty2(rm1.level < rm2.level ? rm1.level : rm2.level, { + TAG: /* Tvar */0, + _0: undefined + }) + ); + var fixed = fixed1 || fixed2; + var closed = row1$1.row_closed || row2$1.row_closed; + var keep = function ($$switch) { + return Stdlib__List.for_all((function (param) { + var match = Curry._2($$switch, param[1], param[2]); + if (Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, match[0]), /* Rabsent */0)) { + return true; + } else { + return Caml_obj.caml_notequal(row_field_repr_aux(/* [] */0, match[1]), /* Rabsent */0); + } + }), pairs); + }; + var empty = function (fields) { + return Stdlib__List.for_all((function (param) { + return Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, param[1]), /* Rabsent */0); + }), fields); + }; + if (closed && (empty(r1) || row2$1.row_closed) && (empty(r2) || row1$1.row_closed) && Stdlib__List.for_all((function (param) { + if (Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, param[1]), /* Rabsent */0)) { + return true; + } else { + return Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, param[2]), /* Rabsent */0); + } + }), pairs)) { throw { RE_EXN_ID: Unify, - _1: /* [] */0, + _1: { + hd: [ + mkvariant(/* [] */0, true), + mkvariant(/* [] */0, true) + ], + tl: /* [] */0 + }, Error: new Error() }; } - Stdlib__List.iter2((function (param, param$1) { - return unify(env, param, param$1); - }), tl1, tl2); -} - -function unify3(env, t1, t1$p, t2, t2$p) { - var d1 = t1$p.desc; - var d2 = t2$p.desc; - var create_recursion = t2 !== t2$p && deep_occur(t1$p, t2); - var exit = 0; - var exit$1 = 0; - if (typeof d1 === "number") { - exit$1 = 2; - } else { - switch (d1.TAG | 0) { - case /* Tvar */0 : - occur(env.contents, t1$p, t2); - occur_univar(env.contents, t2); - return link_type(t1$p, t2); - case /* Tfield */5 : - if (typeof d2 === "number") { - exit = 1; - } else { - switch (d2.TAG | 0) { - case /* Tvar */0 : - exit$1 = 2; - break; - case /* Tfield */5 : - return unify_fields(env, t1$p, t2$p); - default: - exit = 1; - } - } - break; - case /* Tunivar */9 : - if (typeof d2 === "number") { - exit = 1; - } else { - switch (d2.TAG | 0) { - case /* Tvar */0 : - exit$1 = 2; - break; - case /* Tunivar */9 : - unify_univar(t1$p, t2$p, univar_pairs.contents); - return link_type(t1$p, t2$p); - default: - exit = 1; - } - } - break; - default: - exit$1 = 2; - } - } - if (exit$1 === 2) { - if (typeof d2 === "number") { - exit = 1; - } else { - if (d2.TAG === /* Tvar */0) { - occur(env.contents, t2$p, t1); - occur_univar(env.contents, t1); - return link_type(t2$p, t1); - } - exit = 1; + var name = row1$1.row_name !== undefined && (row1$1.row_closed || empty(r2)) && (!row2$1.row_closed || keep(function (f1, f2) { + return [ + f1, + f2 + ]; + }) && empty(r1)) ? row1$1.row_name : ( + row2$1.row_name !== undefined && (row2$1.row_closed || empty(r1)) && (!row1$1.row_closed || keep(function (f1, f2) { + return [ + f2, + f1 + ]; + }) && empty(r2)) ? row2$1.row_name : undefined + ); + var set_more = function (row, rest) { + var rest$1 = closed ? filter_row_fields(row.row_closed, rest) : rest; + if (Caml_obj.caml_notequal(rest$1, /* [] */0) && (row.row_closed || row_fixed(row)) || closed && row_fixed(row) && !row.row_closed) { + var t1 = mkvariant(/* [] */0, true); + var t2 = mkvariant(rest$1, false); + throw { + RE_EXN_ID: Unify, + _1: { + hd: row === row1$1 ? [ + t1, + t2 + ] : [ + t2, + t1 + ], + tl: /* [] */0 + }, + Error: new Error() + }; } - } - if (exit === 1) { - var match = umode.contents; - if (match) { - add_type_equality(t1$p, t2$p); + var rm = row_more(row); + if (trace_gadt_instances.contents && Caml_obj.caml_equal(rm.desc, /* Tnil */0) || !trace_gadt_instances.contents) { + } else { - occur(env.contents, t1$p, t2$p); - link_type(t1$p, t2); + update_level(env.contents, rm.level, newty2(100000000, { + TAG: /* Tvariant */8, + _0: row + })); } - try { - var exit$2 = 0; - var f; - var kind; - var rem; - var exit$3 = 0; - var exit$4 = 0; - if (typeof d1 === "number") { - if (typeof d2 !== "number") { - switch (d2.TAG | 0) { - case /* Tconstr */3 : - exit$4 = 5; - break; - case /* Tfield */5 : - f = d2._0; - kind = d2._1; - rem = d2._3; - exit$2 = 3; - break; - default: - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - } - + if (row_fixed(row)) { + if (more === rm) { + return ; + } else if (is_Tvar(rm)) { + return link_type(rm, more); } else { - switch (d1.TAG | 0) { - case /* Tarrow */1 : - var l1 = d1._0; - if (typeof d2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - switch (d2.TAG | 0) { - case /* Tarrow */1 : - var l2 = d2._0; - if (l1 === l2 || classic.contents && !(is_optional(l1) || is_optional(l2))) { - unify(env, d1._1, d2._1); - unify(env, d1._2, d2._2); - var match$1 = commu_repr(d1._3); - var match$2 = commu_repr(d2._3); - if (typeof match$1 === "number") { - if (typeof match$2 === "number") { - - } else { - set_commu(match$2._0, match$1); - } - } else { - set_commu(match$1._0, match$2); - } - } else { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - break; - case /* Tconstr */3 : - exit$4 = 5; - break; - default: - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - break; - case /* Ttuple */2 : - if (typeof d2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - switch (d2.TAG | 0) { - case /* Ttuple */2 : - unify_list(env, d1._0, d2._0); - break; - case /* Tconstr */3 : - exit$4 = 5; - break; - default: - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - break; - case /* Tconstr */3 : - var p1 = d1._0; - var exit$5 = 0; - if (typeof d2 === "number" || d2.TAG !== /* Tconstr */3) { - exit$5 = 6; - } else { - var tl2 = d2._1; - var tl1 = d1._1; - if (same(p1, d2._0)) { - if (umode.contents === /* Expression */0 || !generate_equations.contents) { - unify_list(env, tl1, tl2); - } else if (assume_injective.contents) { - set_mode_pattern(true, false, (function (param) { - unify_list(env, tl1, tl2); - })); - } else { - var tmp = true; - if (!in_current_module(p1)) { - var partial_arg = env.contents; - tmp = Stdlib__List.exists((function (param) { - return expands_to_datatype(partial_arg, param); - }), { - hd: t1$p, - tl: { - hd: t1, - tl: { - hd: t2, - tl: /* [] */0 - } - } - }); - } - if (tmp) { - unify_list(env, tl1, tl2); - } else { - var inj; - try { - inj = Stdlib__List.map(Curry._1(Types_Variance.mem, /* Inj */3), find_type_full(p1, env.contents)[0].type_variance); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === Stdlib.Not_found) { - inj = Stdlib__List.map((function (param) { - return false; - }), tl1); - } else { - throw exn; - } - } - Stdlib__List.iter2((function (i, param) { - var t2 = param[1]; - var t1 = param[0]; - if (i) { - return unify(env, t1, t2); - } else { - return set_mode_pattern(false, false, (function (param) { - var snap = snapshot(undefined); - try { - return unify(env, t1, t2); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === Unify) { - backtrack(snap); - reify(env, t1); - return reify(env, t2); - } - throw exn; - } - })); - } - }), inj, Stdlib__List.combine(tl1, tl2)); - } - } - } else { - exit$5 = 6; - } - } - if (exit$5 === 6) { - switch (p1.TAG | 0) { - case /* Pident */0 : - if (d1._1) { - exit$4 = 5; - } else { - var p = p1._0; - var exit$6 = 0; - if (typeof d2 === "number" || d2.TAG !== /* Tconstr */3) { - exit$6 = 7; - } else { - var path$p = d2._0; - switch (path$p.TAG | 0) { - case /* Pident */0 : - if (d2._1 || !(is_newtype(env.contents, p1) && is_newtype(env.contents, path$p) && generate_equations.contents)) { - exit$6 = 7; - } else { - var match$3 = Caml_obj.caml_greaterthan(find_newtype_level(env.contents, p1), find_newtype_level(env.contents, path$p)) ? [ - p, - t2$p - ] : [ - path$p._0, - t1$p - ]; - add_gadt_equation(env, match$3[0], match$3[1]); - } - break; - case /* Pdot */1 : - case /* Papply */2 : - exit$6 = 7; - break; - - } + return unify(env, rm, more); + } + } + var ty = newty2(100000000, { + TAG: /* Tvariant */8, + _0: { + row_fields: rest$1, + row_more: more, + row_bound: undefined, + row_closed: closed, + row_fixed: fixed, + row_name: name + } + }); + update_level(env.contents, rm.level, ty); + link_type(rm, ty); + }; + var md1 = rm1.desc; + var md2 = rm2.desc; + try { + set_more(row2$1, r1); + set_more(row1$1, r2); + return Stdlib__List.iter((function (param) { + var f2 = param[2]; + var f1 = param[1]; + var l = param[0]; + try { + var _f1 = f1; + var _f2 = f2; + while(true) { + var f2$1 = _f2; + var f1$1 = _f1; + var f1$2 = row_field_repr_aux(/* [] */0, f1$1); + var f2$2 = row_field_repr_aux(/* [] */0, f2$1); + if (f1$2 === f2$2) { + return ; + } + if (typeof f1$2 === "number") { + if (typeof f2$2 === "number") { + return ; } - if (exit$6 === 7) { - if (is_newtype(env.contents, p1) && generate_equations.contents) { - reify(env, t2$p); - add_gadt_equation(env, p, t2$p); - } else { - exit$4 = 5; - } + if (f2$2.TAG === /* Rpresent */0) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; } - - } - break; - case /* Pdot */1 : - case /* Papply */2 : - exit$4 = 5; - break; - - } - } - break; - case /* Tobject */4 : - if (typeof d2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - switch (d2.TAG | 0) { - case /* Tconstr */3 : - exit$4 = 5; - break; - case /* Tobject */4 : - unify_fields(env, d1._0, d2._0); - var match$4 = repr(t2$p).desc; - if (typeof match$4 !== "number" && match$4.TAG === /* Tobject */4) { - var exit$7 = 0; - var match$5 = match$4._1.contents; - if (match$5 !== undefined) { - var match$6 = match$5[1]; - if (match$6) { - var match$7 = repr(match$6.hd).desc; - var tmp$1; - if (typeof match$7 === "number") { - tmp$1 = true; - } else { - switch (match$7.TAG | 0) { - case /* Tvar */0 : - case /* Tunivar */9 : - tmp$1 = true; - break; - default: - tmp$1 = false; + if (f2$2._2) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (!fixed2) { + return set_row_field(f2$2._3, f1$2); + } + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } else if (f1$2.TAG === /* Rpresent */0) { + var t1 = f1$2._0; + if (t1 !== undefined) { + if (typeof f2$2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (f2$2.TAG === /* Rpresent */0) { + var t2 = f2$2._0; + if (t2 !== undefined) { + return unify(env, t1, t2); } + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; } - if (!tmp$1) { - exit$7 = 6; + if (f2$2._0) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (fixed2) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + var e2 = f2$2._3; + set_row_field(e2, f1$2); + update_level(env.contents, repr(more).level, t1); + try { + return Stdlib__List.iter((function(t1){ + return function (param) { + return unify(env, t1, param); + } + }(t1)), f2$2._1); + } + catch (exn){ + e2.contents = undefined; + throw exn; } - } else { - exit$7 = 6; - } - } else { - exit$7 = 6; - } - if (exit$7 === 6) { - set_name(match$4._1, d1._1.contents); - } - - } - break; - default: - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - break; - case /* Tfield */5 : - if (typeof d2 === "number") { - f = d1._0; - kind = d1._1; - rem = d1._3; - exit$2 = 3; - } else if (d2.TAG === /* Tconstr */3) { - exit$4 = 5; - } else { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - break; - case /* Tvariant */8 : - var row1 = d1._0; - if (typeof d2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - switch (d2.TAG | 0) { - case /* Tconstr */3 : - exit$4 = 5; - break; - case /* Tvariant */8 : - var row2 = d2._0; - if (umode.contents === /* Expression */0) { - unify_row(env, row1, row2); - } else { - var snap = snapshot(undefined); - try { - unify_row(env, row1, row2); - } - catch (raw_exn$1){ - var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); - if (exn$1.RE_EXN_ID === Unify) { - backtrack(snap); - reify(env, t1$p); - reify(env, t2$p); - if (generate_equations.contents) { - mcomp$1(env.contents, t1$p, t2$p); + if (typeof f2$2 === "number") { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (f2$2.TAG === /* Rpresent */0) { + if (f2$2._0 === undefined) { + return ; + } + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (f2$2._0) { + if (f2$2._1) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (!fixed2) { + return set_row_field(f2$2._3, f1$2); + } + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; } - - } else { - throw exn$1; + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; } - } - } - break; - default: - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - break; - case /* Tpoly */10 : - var tl1$1 = d1._1; - var t1$1 = d1._0; - var exit$8 = 0; - if (tl1$1) { - exit$8 = 6; - } else { - if (typeof d2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - switch (d2.TAG | 0) { - case /* Tconstr */3 : - exit$4 = 5; - break; - case /* Tpoly */10 : - if (d2._1) { - exit$8 = 6; } else { - unify(env, t1$1, d2._0); - } - break; - default: - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - } - if (exit$8 === 6) { - if (typeof d2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - switch (d2.TAG | 0) { - case /* Tconstr */3 : - exit$4 = 5; - break; - case /* Tpoly */10 : - enter_poly(env.contents, univar_pairs, t1$1, tl1$1, d2._0, d2._1, (function (param, param$1) { - return unify(env, param, param$1); - })); - break; - default: - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - } - break; - case /* Tpackage */11 : - var tl1$2 = d1._2; - if (typeof d2 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - switch (d2.TAG | 0) { - case /* Tconstr */3 : - exit$4 = 5; - break; - case /* Tpackage */11 : - var tl2$1 = d2._2; - try { - unify_package(env.contents, (function (param, param$1) { - return unify_list(env, param, param$1); - }), t1.level, d1._0, d1._1, tl1$2, t2.level, d2._0, d2._1, tl2$1); - } - catch (raw_exn$2){ - var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); - if (exn$2.RE_EXN_ID === Stdlib.Not_found) { - if (umode.contents === /* Expression */0) { + var c1 = f1$2._0; + var m1 = f1$2._2; + var tl1 = f1$2._1; + var e1 = f1$2._3; + if (typeof f2$2 === "number") { + if (m1) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (!fixed1) { + return set_row_field(f1$2._3, f2$2); + } throw { RE_EXN_ID: Unify, _1: /* [] */0, Error: new Error() }; } - Stdlib__List.iter((function (param) { - return reify(env, param); - }), Stdlib.$at(tl1$2, tl2$1)); - } else { - throw exn$2; + if (f2$2.TAG === /* Rpresent */0) { + if (c1) { + if (f1$2._1) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (f2$2._0 !== undefined) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + if (!fixed1) { + return set_row_field(f1$2._3, f2$2); + } + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + var t2$1 = f2$2._0; + if (t2$1 !== undefined) { + if (fixed1) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + var e1$1 = f1$2._3; + set_row_field(e1$1, f2$2); + update_level(env.contents, repr(more).level, t2$1); + try { + return Stdlib__List.iter((function(t2$1){ + return function (t1) { + unify(env, t1, t2$1); + } + }(t2$1)), f1$2._1); + } + catch (exn$1){ + e1$1.contents = undefined; + throw exn$1; + } + } else { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + } else { + var e2$1 = f2$2._3; + if (e1 === e2$1) { + return ; + } + var m2 = f2$2._2; + var tl2 = f2$2._1; + var c2 = f2$2._0; + var redo = false; + if (m1 || m2 || fixed1 || fixed2 || rigid_variants.contents && (Stdlib__List.length(tl1) === 1 || Stdlib__List.length(tl2) === 1)) { + var match = Stdlib.$at(tl1, tl2); + var tmp; + if (match) { + var t1$1 = match.hd; + if (c1 || c2) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + Stdlib__List.iter((function(t1$1){ + return function (param) { + return unify(env, t1$1, param); + } + }(t1$1)), match.tl); + tmp = e1.contents !== undefined || e2$1.contents !== undefined; + } else { + tmp = false; + } + redo = tmp; + } + if (redo) { + _f2 = f2$2; + _f1 = f1$2; + continue ; + } + var tl1$1 = Stdlib__List.map(repr, tl1); + var tl2$1 = Stdlib__List.map(repr, tl2); + var remq = function (tl, _param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + var tl$p = param.tl; + var ty = param.hd; + if (!Stdlib__List.memq(ty, tl)) { + return { + hd: ty, + tl: remq(tl, tl$p) + }; + } + _param = tl$p; + continue ; + }; + }; + var tl2$p = remq(tl2$1, tl1$1); + var tl1$p = remq(tl1$1, tl2$1); + var partial_arg = repr(more).level; + var partial_arg$1 = env.contents; + Stdlib__List.iter((function(partial_arg,partial_arg$1){ + return function (param) { + return update_level(partial_arg$1, partial_arg, param); + } + }(partial_arg,partial_arg$1)), Stdlib.$at(tl1$p, tl2$p)); + var e = { + contents: undefined + }; + var f1$p_0 = c1 || c2; + var f1$p_2 = m1 || m2; + var f1$p = { + TAG: /* Reither */1, + _0: f1$p_0, + _1: tl1$p, + _2: f1$p_2, + _3: e + }; + var f2$p_0 = c1 || c2; + var f2$p_2 = m1 || m2; + var f2$p = { + TAG: /* Reither */1, + _0: f2$p_0, + _1: tl2$p, + _2: f2$p_2, + _3: e + }; + set_row_field(e1, f1$p); + return set_row_field(e2$1, f2$p); + } } + }; + } + catch (raw_exn){ + var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn$2.RE_EXN_ID === Unify) { + throw { + RE_EXN_ID: Unify, + _1: { + hd: [ + mkvariant({ + hd: [ + l, + f1 + ], + tl: /* [] */0 + }, true), + mkvariant({ + hd: [ + l, + f2 + ], + tl: /* [] */0 + }, true) + ], + tl: exn$2._1 + }, + Error: new Error() + }; } - break; - default: - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() + throw exn$2; + } + }), pairs); + } + catch (exn){ + log_type(rm1); + rm1.desc = md1; + log_type(rm2); + rm2.desc = md2; + throw exn; + } +} + +function unify_list(env, tl1, tl2) { + if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { + throw { + RE_EXN_ID: Unify, + _1: /* [] */0, + Error: new Error() + }; + } + Stdlib__List.iter2((function (param, param$1) { + return unify(env, param, param$1); + }), tl1, tl2); +} + +function unify_fields(env, ty1, ty2) { + var match = flatten_fields(ty1); + var rest1 = match[1]; + var match$1 = flatten_fields(ty2); + var rest2 = match$1[1]; + var match$2 = associate_fields(match[0], match$1[0]); + var miss2 = match$2[2]; + var miss1 = match$2[1]; + var l1 = repr(ty1).level; + var l2 = repr(ty2).level; + var va = make_rowvar(l1 < l2 ? l1 : l2, Caml_obj.caml_equal(miss2, /* [] */0), rest1, Caml_obj.caml_equal(miss1, /* [] */0), rest2); + var d1 = rest1.desc; + var d2 = rest2.desc; + try { + unify(env, build_fields(l1)(miss1, va), rest2); + unify(env, rest1, build_fields(l2)(miss2, va)); + return Stdlib__List.iter((function (param) { + var t2 = param[4]; + var k2 = param[3]; + var t1 = param[2]; + var k1 = param[1]; + var n = param[0]; + unify_kind(k1, k2); + try { + if (trace_gadt_instances.contents) { + update_level(env.contents, va.level, t1); + } + return unify(env, t1, t2); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Unify) { + var desc_3 = newty2(current_level.contents, /* Tnil */0); + var desc = { + TAG: /* Tfield */5, + _0: n, + _1: k1, + _2: t1, + _3: desc_3 }; - } - break; - default: - exit$4 = 5; - } - } - if (exit$4 === 5) { - if (typeof d2 === "number" || d2.TAG !== /* Tconstr */3) { - exit$3 = 4; - } else { - var path = d2._0; - switch (path.TAG | 0) { - case /* Pident */0 : - if (d2._1 || !(is_newtype(env.contents, path) && generate_equations.contents)) { - exit$2 = 2; - } else { - reify(env, t1$p); - add_gadt_equation(env, path._0, t1$p); - } - break; - case /* Pdot */1 : - case /* Papply */2 : - exit$2 = 2; - break; - - } - } - } - if (exit$3 === 4) { - if (typeof d1 === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (d1.TAG === /* Tconstr */3) { - exit$2 = 2; - } else { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - } - switch (exit$2) { - case 2 : - if (umode.contents === /* Pattern */1) { - reify(env, t1$p); - reify(env, t2$p); - if (generate_equations.contents) { - mcomp$1(env.contents, t1$p, t2$p); - } - - } else { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - break; - case 3 : - var r = field_kind_repr(kind); - if (typeof r === "number") { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - if (f !== dummy_method) { - set_kind(r._0, /* Fabsent */1); - if (Caml_obj.caml_equal(d2, /* Tnil */0)) { - unify(env, rem, t2$p); - } else { - unify(env, newty2(rem.level, /* Tnil */0), rem); - } - } else { - throw { - RE_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; - } - break; - - } - if (!create_recursion) { - return ; - } - var match$8 = t2.desc; - if (typeof match$8 === "number") { - return ; - } - if (match$8.TAG !== /* Tconstr */3) { - return ; - } - forget_abbrev(match$8._2, match$8._0); - var t2$p$p = expand_head_unif(env.contents, t2); - if (!closed_parameterized_type(match$8._1, t2$p$p)) { - return link_type(repr(t2), repr(t2$p)); - } else { - return ; - } - } - catch (raw_exn$3){ - var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); - if (exn$3.RE_EXN_ID === Unify) { - t1$p.desc = d1; - throw { - RE_EXN_ID: Unify, - _1: exn$3._1, - Error: new Error() - }; - } - throw exn$3; - } + var desc_3$1 = newty2(current_level.contents, /* Tnil */0); + var desc$1 = { + TAG: /* Tfield */5, + _0: n, + _1: k2, + _2: t2, + _3: desc_3$1 + }; + throw { + RE_EXN_ID: Unify, + _1: { + hd: [ + newty2(current_level.contents, desc), + newty2(current_level.contents, desc$1) + ], + tl: exn._1 + }, + Error: new Error() + }; + } + throw exn; + } + }), match$2[0]); + } + catch (exn){ + log_type(rest1); + rest1.desc = d1; + log_type(rest2); + rest2.desc = d2; + throw exn; } - } function unify$1(env, ty1, ty2) { @@ -41667,157 +41667,6 @@ function print_out_functor(ppf, m) { }), print_out_module_type, m); } -function print_out_constr(ppf, param) { - var ret_type_opt = param[2]; - var tyl = param[1]; - var name = param[0]; - if (ret_type_opt !== undefined) { - if (tyl) { - return Curry._5(Stdlib__Format.fprintf(ppf)(/* Format */{ - _0: { - TAG: /* Formatting_gen */18, - _0: { - TAG: /* Open_box */1, - _0: /* Format */{ - _0: { - TAG: /* String_literal */11, - _0: "<2>", - _1: /* End_of_format */0 - }, - _1: "<2>" - } - }, - _1: { - TAG: /* String */2, - _0: /* No_padding */0, - _1: { - TAG: /* String_literal */11, - _0: " :", - _1: { - TAG: /* Formatting_lit */17, - _0: { - TAG: /* Break */0, - _0: "@ ", - _1: 1, - _2: 0 - }, - _1: { - TAG: /* Alpha */15, - _0: { - TAG: /* String_literal */11, - _0: " -> ", - _1: { - TAG: /* Alpha */15, - _0: { - TAG: /* Formatting_lit */17, - _0: /* Close_box */0, - _1: /* End_of_format */0 - } - } - } - } - } - } - } - }, - _1: "@[<2>%s :@ %a -> %a@]" - }), name, (function (param, param$1) { - return print_typlist(print_simple_out_type, " *", param, param$1); - }), tyl, print_simple_out_type, ret_type_opt); - } else { - return Curry._3(Stdlib__Format.fprintf(ppf)(/* Format */{ - _0: { - TAG: /* Formatting_gen */18, - _0: { - TAG: /* Open_box */1, - _0: /* Format */{ - _0: { - TAG: /* String_literal */11, - _0: "<2>", - _1: /* End_of_format */0 - }, - _1: "<2>" - } - }, - _1: { - TAG: /* String */2, - _0: /* No_padding */0, - _1: { - TAG: /* String_literal */11, - _0: " :", - _1: { - TAG: /* Formatting_lit */17, - _0: { - TAG: /* Break */0, - _0: "@ ", - _1: 1, - _2: 0 - }, - _1: { - TAG: /* Alpha */15, - _0: { - TAG: /* Formatting_lit */17, - _0: /* Close_box */0, - _1: /* End_of_format */0 - } - } - } - } - } - }, - _1: "@[<2>%s :@ %a@]" - }), name, print_simple_out_type, ret_type_opt); - } - } else if (tyl) { - return Curry._3(Stdlib__Format.fprintf(ppf)(/* Format */{ - _0: { - TAG: /* Formatting_gen */18, - _0: { - TAG: /* Open_box */1, - _0: /* Format */{ - _0: { - TAG: /* String_literal */11, - _0: "<2>", - _1: /* End_of_format */0 - }, - _1: "<2>" - } - }, - _1: { - TAG: /* String */2, - _0: /* No_padding */0, - _1: { - TAG: /* String_literal */11, - _0: " of", - _1: { - TAG: /* Formatting_lit */17, - _0: { - TAG: /* Break */0, - _0: "@ ", - _1: 1, - _2: 0 - }, - _1: { - TAG: /* Alpha */15, - _0: { - TAG: /* Formatting_lit */17, - _0: /* Close_box */0, - _1: /* End_of_format */0 - } - } - } - } - } - }, - _1: "@[<2>%s of@ %a@]" - }), name, (function (param, param$1) { - return print_typlist(print_simple_out_type, " *", param, param$1); - }), tyl); - } else { - return Stdlib__Format.pp_print_string(ppf, name); - } -} - function print_out_label(ppf, param) { Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ _0: { @@ -41871,109 +41720,155 @@ function print_out_label(ppf, param) { }), param[1] ? "mutable " : "", param[0], out_type.contents, param[2]); } -function print_out_signature(ppf, param) { - if (!param) { - return ; - } - var item = param.hd; - if (!param.tl) { - return Curry._2(out_sig_item.contents, ppf, item); - } - if (item.TAG === /* Osig_typext */2 && !item._1) { - var ext = item._0; - var gather_extensions = function (_acc, _items) { - while(true) { - var items = _items; - var acc = _acc; - if (!items) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - var match = items.hd; - if (match.TAG !== /* Osig_typext */2) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - if (match._1 !== 1) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - var ext = match._0; - _items = items.tl; - _acc = { - hd: [ - ext.oext_name, - ext.oext_args, - ext.oext_ret_type - ], - tl: acc - }; - continue ; - }; - }; - var match = gather_extensions({ - hd: [ - ext.oext_name, - ext.oext_args, - ext.oext_ret_type - ], - tl: /* [] */0 - }, param.tl); - var te_otyext_name = ext.oext_type_name; - var te_otyext_params = ext.oext_type_params; - var te_otyext_constructors = match[0]; - var te_otyext_private = ext.oext_private; - var te = { - otyext_name: te_otyext_name, - otyext_params: te_otyext_params, - otyext_constructors: te_otyext_constructors, - otyext_private: te_otyext_private - }; - return Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ - _0: { - TAG: /* Alpha */15, +function print_out_constr(ppf, param) { + var ret_type_opt = param[2]; + var tyl = param[1]; + var name = param[0]; + if (ret_type_opt !== undefined) { + if (tyl) { + return Curry._5(Stdlib__Format.fprintf(ppf)(/* Format */{ + _0: { + TAG: /* Formatting_gen */18, + _0: { + TAG: /* Open_box */1, + _0: /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "<2>", + _1: /* End_of_format */0 + }, + _1: "<2>" + } + }, + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " :", + _1: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@ ", + _1: 1, + _2: 0 + }, + _1: { + TAG: /* Alpha */15, + _0: { + TAG: /* String_literal */11, + _0: " -> ", + _1: { + TAG: /* Alpha */15, + _0: { + TAG: /* Formatting_lit */17, + _0: /* Close_box */0, + _1: /* End_of_format */0 + } + } + } + } + } + } + } + }, + _1: "@[<2>%s :@ %a -> %a@]" + }), name, (function (param, param$1) { + return print_typlist(print_simple_out_type, " *", param, param$1); + }), tyl, print_simple_out_type, ret_type_opt); + } else { + return Curry._3(Stdlib__Format.fprintf(ppf)(/* Format */{ _0: { - TAG: /* Formatting_lit */17, + TAG: /* Formatting_gen */18, _0: { - TAG: /* Break */0, - _0: "@ ", - _1: 1, - _2: 0 + TAG: /* Open_box */1, + _0: /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "<2>", + _1: /* End_of_format */0 + }, + _1: "<2>" + } }, _1: { - TAG: /* Alpha */15, - _0: /* End_of_format */0 + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " :", + _1: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@ ", + _1: 1, + _2: 0 + }, + _1: { + TAG: /* Alpha */15, + _0: { + TAG: /* Formatting_lit */17, + _0: /* Close_box */0, + _1: /* End_of_format */0 + } + } + } + } + } + }, + _1: "@[<2>%s :@ %a@]" + }), name, print_simple_out_type, ret_type_opt); + } + } else if (tyl) { + return Curry._3(Stdlib__Format.fprintf(ppf)(/* Format */{ + _0: { + TAG: /* Formatting_gen */18, + _0: { + TAG: /* Open_box */1, + _0: /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "<2>", + _1: /* End_of_format */0 + }, + _1: "<2>" + } + }, + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " of", + _1: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@ ", + _1: 1, + _2: 0 + }, + _1: { + TAG: /* Alpha */15, + _0: { + TAG: /* Formatting_lit */17, + _0: /* Close_box */0, + _1: /* End_of_format */0 + } + } + } } } }, - _1: "%a@ %a" - }), out_type_extension.contents, te, print_out_signature, match[1]); + _1: "@[<2>%s of@ %a@]" + }), name, (function (param, param$1) { + return print_typlist(print_simple_out_type, " *", param, param$1); + }), tyl); + } else { + return Stdlib__Format.pp_print_string(ppf, name); } - Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ - _0: { - TAG: /* Alpha */15, - _0: { - TAG: /* Formatting_lit */17, - _0: { - TAG: /* Break */0, - _0: "@ ", - _1: 1, - _2: 0 - }, - _1: { - TAG: /* Alpha */15, - _0: /* End_of_format */0 - } - } - }, - _1: "%a@ %a" - }), out_sig_item.contents, item, print_out_signature, param.tl); } function print_out_module_type(ppf, t) { @@ -42100,6 +41995,111 @@ function print_out_module_type(ppf, t) { } } +function print_out_signature(ppf, param) { + if (!param) { + return ; + } + var item = param.hd; + if (!param.tl) { + return Curry._2(out_sig_item.contents, ppf, item); + } + if (item.TAG === /* Osig_typext */2 && !item._1) { + var ext = item._0; + var gather_extensions = function (_acc, _items) { + while(true) { + var items = _items; + var acc = _acc; + if (!items) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + var match = items.hd; + if (match.TAG !== /* Osig_typext */2) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + if (match._1 !== 1) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + var ext = match._0; + _items = items.tl; + _acc = { + hd: [ + ext.oext_name, + ext.oext_args, + ext.oext_ret_type + ], + tl: acc + }; + continue ; + }; + }; + var match = gather_extensions({ + hd: [ + ext.oext_name, + ext.oext_args, + ext.oext_ret_type + ], + tl: /* [] */0 + }, param.tl); + var te_otyext_name = ext.oext_type_name; + var te_otyext_params = ext.oext_type_params; + var te_otyext_constructors = match[0]; + var te_otyext_private = ext.oext_private; + var te = { + otyext_name: te_otyext_name, + otyext_params: te_otyext_params, + otyext_constructors: te_otyext_constructors, + otyext_private: te_otyext_private + }; + return Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ + _0: { + TAG: /* Alpha */15, + _0: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@ ", + _1: 1, + _2: 0 + }, + _1: { + TAG: /* Alpha */15, + _0: /* End_of_format */0 + } + } + }, + _1: "%a@ %a" + }), out_type_extension.contents, te, print_out_signature, match[1]); + } + Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ + _0: { + TAG: /* Alpha */15, + _0: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@ ", + _1: 1, + _2: 0 + }, + _1: { + TAG: /* Alpha */15, + _0: /* End_of_format */0 + } + } + }, + _1: "%a@ %a" + }), out_sig_item.contents, item, print_out_signature, param.tl); +} + function print_out_sig_item(ppf, param) { switch (param.TAG | 0) { case /* Osig_class */0 : @@ -46547,6 +46547,14 @@ function filter_params(tyl) { }), /* [] */0, tyl)); } +function tree_of_label(l) { + return [ + l.ld_id.name, + l.ld_mutable === /* Mutable */1, + tree_of_typexp(false, l.ld_type) + ]; +} + function tree_of_constructor(cd) { var name = cd.cd_id.name; var res = cd.cd_res; @@ -46573,14 +46581,6 @@ function tree_of_constructor(cd) { ]; } -function tree_of_label(l) { - return [ - l.ld_id.name, - l.ld_mutable === /* Mutable */1, - tree_of_typexp(false, l.ld_type) - ]; -} - function tree_of_type_decl(id, decl) { reset(undefined); var params = filter_params(decl.type_params); diff --git a/jscomp/test/dist/jscomp/test/parser_api.js b/jscomp/test/dist/jscomp/test/parser_api.js index d0c784d417..1c11f688c9 100644 --- a/jscomp/test/dist/jscomp/test/parser_api.js +++ b/jscomp/test/dist/jscomp/test/parser_api.js @@ -14505,6 +14505,24 @@ function directive_parse(token_with_comments, lexbuf) { push(e); return v; }; + var parse_and_aux = function (calc, v) { + var e = token(undefined); + if (typeof e === "number") { + if (e) { + push(e); + return v; + } + var calc$1 = calc && v; + var b = parse_and_aux(calc$1, parse_relation(calc$1)); + if (v) { + return b; + } else { + return false; + } + } + push(e); + return v; + }; var parse_relation = function (calc) { var curr_token = token(undefined); var curr_loc = curr(lexbuf); @@ -14649,24 +14667,6 @@ function directive_parse(token_with_comments, lexbuf) { } } }; - var parse_and_aux = function (calc, v) { - var e = token(undefined); - if (typeof e === "number") { - if (e) { - push(e); - return v; - } - var calc$1 = calc && v; - var b = parse_and_aux(calc$1, parse_relation(calc$1)); - if (v) { - return b; - } else { - return false; - } - } - push(e); - return v; - }; var v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); var match = token(undefined); if (match === 88) { @@ -16034,106 +16034,6 @@ function token(lexbuf) { }; } -function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - update_loc(lexbuf, undefined, 1, false, 0); - store_string(Stdlib__Lexing.lexeme(lexbuf)); - ___ocaml_lex_state = 183; - continue ; - case 1 : - is_in_string.contents = false; - throw { - RE_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; - case 2 : - var edelim = Stdlib__Lexing.lexeme(lexbuf); - var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); - if (delim === edelim$1) { - return ; - } - store_string(Stdlib__Lexing.lexeme(lexbuf)); - ___ocaml_lex_state = 183; - continue ; - case 3 : - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - ___ocaml_lex_state = 183; - continue ; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function string(lexbuf) { - lexbuf.lex_mem = Caml_array.make(2, -1); - var ___ocaml_lex_state = 164; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - return ; - case 1 : - var space = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - update_loc(lexbuf, undefined, 1, false, space.length); - return string(lexbuf); - case 2 : - store_string_char(char_for_backslash(Stdlib__Lexing.lexeme_char(lexbuf, 1))); - return string(lexbuf); - case 3 : - store_string_char(char_for_decimal_code(lexbuf, 1)); - return string(lexbuf); - case 4 : - store_string_char(char_for_hexadecimal_code(lexbuf, 2)); - return string(lexbuf); - case 5 : - if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { - return string(lexbuf); - } - var loc = curr(lexbuf); - prerr_warning(loc, /* Illegal_backslash */7); - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 1)); - return string(lexbuf); - case 6 : - if (!Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { - prerr_warning(curr(lexbuf), /* Eol_in_string */14); - } - update_loc(lexbuf, undefined, 1, false, 0); - store_string(Stdlib__Lexing.lexeme(lexbuf)); - return string(lexbuf); - case 7 : - is_in_string.contents = false; - throw { - RE_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; - case 8 : - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - return string(lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function comment(lexbuf) { - return __ocaml_lex_comment_rec(lexbuf, 132); -} - function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { while(true) { var __ocaml_lex_state = ___ocaml_lex_state; @@ -16319,6 +16219,106 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { }; } +function string(lexbuf) { + lexbuf.lex_mem = Caml_array.make(2, -1); + var ___ocaml_lex_state = 164; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + return ; + case 1 : + var space = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + update_loc(lexbuf, undefined, 1, false, space.length); + return string(lexbuf); + case 2 : + store_string_char(char_for_backslash(Stdlib__Lexing.lexeme_char(lexbuf, 1))); + return string(lexbuf); + case 3 : + store_string_char(char_for_decimal_code(lexbuf, 1)); + return string(lexbuf); + case 4 : + store_string_char(char_for_hexadecimal_code(lexbuf, 2)); + return string(lexbuf); + case 5 : + if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { + return string(lexbuf); + } + var loc = curr(lexbuf); + prerr_warning(loc, /* Illegal_backslash */7); + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 1)); + return string(lexbuf); + case 6 : + if (!Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { + prerr_warning(curr(lexbuf), /* Eol_in_string */14); + } + update_loc(lexbuf, undefined, 1, false, 0); + store_string(Stdlib__Lexing.lexeme(lexbuf)); + return string(lexbuf); + case 7 : + is_in_string.contents = false; + throw { + RE_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents, + Error: new Error() + }; + case 8 : + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); + return string(lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + update_loc(lexbuf, undefined, 1, false, 0); + store_string(Stdlib__Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 183; + continue ; + case 1 : + is_in_string.contents = false; + throw { + RE_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents, + Error: new Error() + }; + case 2 : + var edelim = Stdlib__Lexing.lexeme(lexbuf); + var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); + if (delim === edelim$1) { + return ; + } + store_string(Stdlib__Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 183; + continue ; + case 3 : + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); + ___ocaml_lex_state = 183; + continue ; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function comment(lexbuf) { + return __ocaml_lex_comment_rec(lexbuf, 132); +} + function skip_sharp_bang(lexbuf) { var ___ocaml_lex_state = 192; while(true) {