diff --git a/jscomp/test/dist/jscomp/test/class3_test.js b/jscomp/test/dist/jscomp/test/class3_test.js index d3fda215e..7b24f588d 100644 --- a/jscomp/test/dist/jscomp/test/class3_test.js +++ b/jscomp/test/dist/jscomp/test/class3_test.js @@ -182,13 +182,10 @@ function adjusted_point2_1(table) { const adjusted_point2_2 = point[2]; -const adjusted_point2_3 = point[3]; - const adjusted_point2 = [ adjusted_point2_0, adjusted_point2_1, - adjusted_point2_2, - adjusted_point2_3 + adjusted_point2_2 ]; const tmp$1 = Curry._2(adjusted_point2_0, undefined, 31); @@ -334,7 +331,6 @@ function abstract_point_1($$class) { const abstract_point = [ undefined, abstract_point_1, - undefined, undefined ]; @@ -388,7 +384,6 @@ function abstract_point2_1($$class) { const abstract_point2 = [ undefined, abstract_point2_1, - undefined, undefined ]; diff --git a/jscomp/test/dist/jscomp/test/class4_test.js b/jscomp/test/dist/jscomp/test/class4_test.js index 1f9f2c0bb..616caa205 100644 --- a/jscomp/test/dist/jscomp/test/class4_test.js +++ b/jscomp/test/dist/jscomp/test/class4_test.js @@ -119,7 +119,6 @@ function abstract_point_1($$class) { const abstract_point = [ undefined, abstract_point_1, - undefined, undefined ]; diff --git a/jscomp/test/dist/jscomp/test/class6_test.js b/jscomp/test/dist/jscomp/test/class6_test.js index ef6789804..a0d2aae30 100644 --- a/jscomp/test/dist/jscomp/test/class6_test.js +++ b/jscomp/test/dist/jscomp/test/class6_test.js @@ -177,7 +177,6 @@ const d_0 = Curry._1(env_init, undefined); const d = [ d_0, d_init, - env_init, undefined ]; @@ -191,7 +190,6 @@ function c2$p_1($$class) { const c2$p = [ undefined, c2$p_1, - undefined, undefined ]; @@ -268,7 +266,6 @@ const bad_functional_point_0 = Curry._1(env_init$1, undefined); const bad_functional_point = [ bad_functional_point_0, bad_functional_point_init, - env_init$1, undefined ]; diff --git a/jscomp/test/dist/jscomp/test/class8_test.js b/jscomp/test/dist/jscomp/test/class8_test.js index 019a82584..7ccd1bd41 100644 --- a/jscomp/test/dist/jscomp/test/class8_test.js +++ b/jscomp/test/dist/jscomp/test/class8_test.js @@ -37,7 +37,6 @@ function comparable_1($$class) { const comparable = [ undefined, comparable_1, - undefined, undefined ]; diff --git a/jscomp/test/dist/jscomp/test/exception_alias.js b/jscomp/test/dist/jscomp/test/exception_alias.js index 5059468a4..e422f284c 100644 --- a/jscomp/test/dist/jscomp/test/exception_alias.js +++ b/jscomp/test/dist/jscomp/test/exception_alias.js @@ -62,6 +62,10 @@ const List = { filter: Stdlib__List.filter, find_all: Stdlib__List.find_all, filteri: Stdlib__List.filteri, + take: Stdlib__List.take, + drop: Stdlib__List.drop, + take_while: Stdlib__List.take_while, + drop_while: Stdlib__List.drop_while, partition: Stdlib__List.partition, partition_map: Stdlib__List.partition_map, assoc: Stdlib__List.assoc, 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 dfd5b47f9..2b41f6603 100644 --- a/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js @@ -3392,226 +3392,6 @@ function token(env, lexbuf) { }; } -function line_comment(env, buf, lexbuf) { - let ___ocaml_lex_state = 287; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __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 : - const match = from_lb(env.lex_source, lexbuf); - const match$1 = match._end; - Stdlib__Lexing.new_line(lexbuf); - const _end_line = match$1.line; - const _end_column = match$1.column - 1 | 0; - const _end_offset = match$1.offset - 1 | 0; - const _end = { - line: _end_line, - column: _end_column, - offset: _end_offset - }; - return [ - env, - { - source: match.source, - start: match.start, - _end: _end - } - ]; - case 2 : - const 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) { - let ___ocaml_lex_state = 279; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - const 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) - ]; - case 1 : - Stdlib__Lexing.new_line(lexbuf); - Stdlib__Buffer.add_char(buf, /* '\n' */10); - return comment(env, buf, lexbuf); - case 2 : - const loc = from_lb(env.lex_source, lexbuf); - const env$2 = env.lex_in_comment_syntax ? unexpected_error_w_suggest(env, loc, "*/", "*-/") : env; - return [ - env$2, - loc - ]; - case 3 : - if (env.lex_in_comment_syntax) { - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; - } else { - Stdlib__Buffer.add_string(buf, "*-/"); - return comment(env, buf, lexbuf); - } - case 4 : - const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c); - return comment(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) { - const __ocaml_lex_state = ___ocaml_lex_state; - const env = _env; - const __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 : - const start = from_lb(env.lex_source, lexbuf); - const buf = Stdlib__Buffer.create(127); - const match = line_comment(env, buf, lexbuf); - const env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 291; - _env = env$1; - continue ; - case 4 : - const start$1 = from_lb(env.lex_source, lexbuf); - const buf$1 = Stdlib__Buffer.create(127); - const match$1 = comment(env, buf$1, lexbuf); - const 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 : - const start$2 = from_lb(env.lex_source, lexbuf); - const buf$2 = Stdlib__Buffer.create(127); - const match$2 = regexp_body(env, buf$2, lexbuf); - const env$3 = match$2[0]; - const end_ = from_lb(env$3.lex_source, lexbuf); - const loc = btwn(start$2, end_); - return [ - env$3, - { - TAG: /* T_REGEXP */3, - _0: [ - loc, - Stdlib__Buffer.contents(buf$2), - match$2[1] - ] - } - ]; - case 6 : - const 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 regexp_body(env, buf, lexbuf) { - let ___ocaml_lex_state = 314; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - const loc = from_lb(env.lex_source, lexbuf); - const env$1 = lex_error(env, loc, /* UnterminatedRegExp */13); - return [ - env$1, - "" - ]; - case 1 : - const loc$1 = from_lb(env.lex_source, lexbuf); - const env$2 = lex_error(env, loc$1, /* UnterminatedRegExp */13); - return [ - env$2, - "" - ]; - case 2 : - const 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 : - const flags = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 1 | 0, lexbuf.lex_curr_pos); - return [ - env, - flags - ]; - case 4 : - return [ - env, - "" - ]; - case 5 : - const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c); - const env$3 = regexp_class(env, buf, lexbuf); - return regexp_body(env$3, buf, lexbuf); - case 6 : - const loc$2 = from_lb(env.lex_source, lexbuf); - const env$4 = lex_error(env, loc$2, /* UnterminatedRegExp */13); - return [ - env$4, - "" - ]; - case 7 : - const 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 jsx_text(env, mode, buf, raw, lexbuf) { let ___ocaml_lex_state = 371; while(true) { @@ -4588,418 +4368,487 @@ function __ocaml_lex_jsx_tag_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); - let ___ocaml_lex_state = 133; +function template_part(env, start, cooked, raw, literal, lexbuf) { + let ___ocaml_lex_state = 416; while(true) { const __ocaml_lex_state = ___ocaml_lex_state; - const __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + const __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); + const env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }); + return [ + env$1, + btwn(start, from_lb(env$1.lex_source, lexbuf)), + true + ]; case 1 : - unicode_fix_cols(lexbuf); - return type_token(env, lexbuf); - case 2 : - const start = from_lb(env.lex_source, lexbuf); + Stdlib__Buffer.add_char(literal, /* '`' */96); + return [ + env, + btwn(start, from_lb(env.lex_source, lexbuf)), + true + ]; + case 2 : + Stdlib__Buffer.add_string(literal, "${"); + return [ + env, + btwn(start, from_lb(env.lex_source, lexbuf)), + false + ]; + case 3 : + Stdlib__Buffer.add_char(raw, /* '\\' */92); + Stdlib__Buffer.add_char(literal, /* '\\' */92); + const match = string_escape(env, cooked, lexbuf); + const 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 : + const 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 : + const 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 : + const 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); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function comment(env, buf, lexbuf) { + let ___ocaml_lex_state = 279; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + const 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) + ]; + case 1 : + Stdlib__Lexing.new_line(lexbuf); + Stdlib__Buffer.add_char(buf, /* '\n' */10); + return comment(env, buf, lexbuf); + case 2 : + const loc = from_lb(env.lex_source, lexbuf); + const env$2 = env.lex_in_comment_syntax ? unexpected_error_w_suggest(env, loc, "*/", "*-/") : env; + return [ + env$2, + loc + ]; + case 3 : + if (env.lex_in_comment_syntax) { + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; + } else { + Stdlib__Buffer.add_string(buf, "*-/"); + return comment(env, buf, lexbuf); + } + case 4 : + const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c); + return comment(env, buf, lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function __ocaml_lex_template_tail_rec(_env, lexbuf, ___ocaml_lex_state) { + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const env = _env; + const __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 : + const start = from_lb(env.lex_source, lexbuf); const buf = Stdlib__Buffer.create(127); - const match = comment(env, buf, lexbuf); + const match = line_comment(env, buf, lexbuf); const env$1 = save_comment(match[0], start, match[1], buf, true); - return type_token(env$1, lexbuf); + ___ocaml_lex_state = 393; + _env = env$1; + continue ; case 3 : - const sp = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, Caml_array.get(lexbuf.lex_mem, 0)); - const escape_type = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - const pattern = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - if (env.lex_enable_comment_syntax) { - let env$2; - if (env.lex_in_comment_syntax) { - const loc = from_lb(env.lex_source, lexbuf); - env$2 = unexpected_error(env, loc, pattern); - } else { - env$2 = env; - } - const env$3 = in_comment_syntax(true, env$2); - if (escape_type === ":") { - return [ - env$3, - /* T_COLON */77 - ]; - } else { - return type_token(env$3, lexbuf); - } - } const start$1 = from_lb(env.lex_source, lexbuf); const buf$1 = Stdlib__Buffer.create(127); - Stdlib__Buffer.add_string(buf$1, sp); - Stdlib__Buffer.add_string(buf$1, escape_type); const match$1 = comment(env, buf$1, lexbuf); - const env$4 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - return type_token(env$4, lexbuf); + const 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 : - if (env.lex_in_comment_syntax) { - const env$5 = in_comment_syntax(false, env); - return type_token(env$5, lexbuf); - } - yyback(1, lexbuf); + const start$2 = from_lb(env.lex_source, lexbuf); + const cooked = Stdlib__Buffer.create(127); + const raw = Stdlib__Buffer.create(127); + const literal = Stdlib__Buffer.create(127); + Stdlib__Buffer.add_string(literal, "}"); + const match$2 = template_part(env, start$2, cooked, raw, literal, lexbuf); return [ - env, - /* T_MULT */97 + 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 : - const start$2 = from_lb(env.lex_source, lexbuf); - const buf$2 = Stdlib__Buffer.create(127); - const match$2 = line_comment(env, buf$2, lexbuf); - const env$6 = save_comment(match$2[0], start$2, match$2[1], buf$2, true); - return type_token(env$6, lexbuf); - case 6 : - const quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - const start$3 = from_lb(env.lex_source, lexbuf); - const buf$3 = Stdlib__Buffer.create(127); - const raw = Stdlib__Buffer.create(127); - Stdlib__Buffer.add_char(raw, quote); - const match$3 = string_quote(env, quote, buf$3, raw, false, lexbuf); + const env$3 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }); return [ - match$3[0], + env$3, { - TAG: /* T_STRING */1, + TAG: /* T_TEMPLATE_PART */2, _0: [ - btwn(start$3, match$3[1]), - Stdlib__Buffer.contents(buf$3), - Stdlib__Buffer.contents(raw), - match$3[2] + from_lb(env$3.lex_source, lexbuf), + { + cooked: "", + raw: "", + literal: "" + }, + true ] } ]; - case 7 : - const neg = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - const 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 : - const neg$1 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$1 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function line_comment(env, buf, lexbuf) { + let ___ocaml_lex_state = 287; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __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) + from_lb(env.lex_source, lexbuf) ]; - case 9 : - const neg$2 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$2 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - const 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 : - const neg$3 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$3 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + case 1 : + const match = from_lb(env.lex_source, lexbuf); + const match$1 = match._end; + Stdlib__Lexing.new_line(lexbuf); + const _end_line = match$1.line; + const _end_column = match$1.column - 1 | 0; + const _end_offset = match$1.offset - 1 | 0; + const _end = { + line: _end_line, + column: _end_column, + offset: _end_offset + }; return [ env, - mk_num_singleton(/* OCTAL */2, num$3, neg$3) + { + source: match.source, + start: match.start, + _end: _end + } ]; - case 11 : - const neg$4 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$4 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - const 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 : - const neg$5 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$5 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - return [ - env, - mk_num_singleton(/* LEGACY_OCTAL */1, num$5, neg$5) - ]; - case 13 : - const neg$6 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$6 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - const w$3 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - let match$4; - try { - match$4 = [ - env, - mk_num_singleton(/* NORMAL */3, num$6, neg$6) - ]; - } - catch (exn){ - if (Stdlib__Sys.win32) { - const loc$1 = from_lb(env.lex_source, lexbuf); - const 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 new Caml_js_exceptions.MelangeError(exn.MEL_EXN_ID, exn); - } - } - return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); - case 14 : - const neg$7 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$7 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - try { + case 2 : + const 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 regexp_class(env, buf, lexbuf) { + let ___ocaml_lex_state = 326; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __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 : + const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c); + return env; + case 4 : + const 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 ; + } + const 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 string_quote(env, q, buf, raw, octal, lexbuf) { + let ___ocaml_lex_state = 247; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + const q$p = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(raw, q$p); + if (q === q$p) { return [ env, - mk_num_singleton(/* NORMAL */3, num$7, neg$7) + from_lb(env.lex_source, lexbuf), + octal ]; + } else { + Stdlib__Buffer.add_char(buf, q$p); + return string_quote(env, q, buf, raw, octal, lexbuf); } - catch (exn$1){ - if (Stdlib__Sys.win32) { - const loc$2 = from_lb(env.lex_source, lexbuf); - const 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 new Caml_js_exceptions.MelangeError(exn$1.MEL_EXN_ID, exn$1); - } - case 15 : - const neg$8 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$8 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - const 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 : - const neg$9 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$9 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + case 1 : + const e = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(raw, e); + const match = string_escape(env, buf, lexbuf); + const octal$1 = match[1] || octal; + Stdlib__Buffer.add_string(raw, Stdlib__Lexing.lexeme(lexbuf)); + return string_quote(match[0], q, buf, raw, octal$1, lexbuf); + case 2 : + const x = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + Stdlib__Buffer.add_string(raw, x); + const env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: /* UnexpectedToken */1, + _0: "ILLEGAL" + }); + Stdlib__Buffer.add_string(buf, x); return [ - env, - mk_num_singleton(/* NORMAL */3, num$9, neg$9) + env$1, + from_lb(env$1.lex_source, lexbuf), + octal ]; - case 17 : - const neg$10 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - const num$10 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - const 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 : - const neg$11 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), Caml_array.get(lexbuf.lex_mem, 0)); - const num$11 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 3), Caml_array.get(lexbuf.lex_mem, 2)); + case 3 : + const x$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(raw, x$1); + Stdlib__Buffer.add_char(buf, x$1); + return string_quote(env, q, buf, raw, octal, lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function string_escape(env, buf, lexbuf) { + let ___ocaml_lex_state = 252; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __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(/* NORMAL */3, num$11, neg$11) + false ]; - case 19 : - const 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){ - const exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn$2.MEL_EXN_ID === Stdlib.Not_found) { - return [ - env, - /* T_IDENTIFIER */0 - ]; - } - throw new Caml_js_exceptions.MelangeError(exn$2.MEL_EXN_ID, exn$2); - } - case 22 : + case 1 : + Stdlib__Buffer.add_string(buf, "\\"); return [ env, - /* T_LCURLY */1 + false ]; - case 23 : + case 2 : + const a = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + const b = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + const 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, - /* T_RCURLY */2 + false ]; - case 24 : + case 3 : + const a$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + const b$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + const 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 { + const 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, - /* T_LPAREN */3 + true ]; - case 25 : + case 4 : + const a$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + const b$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + const 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, - /* T_RPAREN */4 + true ]; - case 26 : + case 5 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(0)); return [ env, - /* T_ELLIPSIS */11 + false ]; - case 27 : + case 6 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(8)); return [ env, - /* T_PERIOD */9 + false ]; - case 28 : + case 7 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(12)); return [ env, - /* T_SEMICOLON */7 + false ]; - case 29 : + case 8 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(10)); 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 + false ]; - case 30 : - case 39 : + case 9 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(13)); return [ env, - /* T_COLON */77 + false ]; - case 40 : + case 10 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(9)); return [ env, - /* T_BIT_OR */80 + false ]; - case 41 : + case 11 : + Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(11)); return [ env, - /* T_BIT_AND */82 + false ]; - case 42 : + case 12 : + const a$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + const 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_TYPEOF */44 + true ]; - case 43 : + case 13 : + const a$4 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + const b$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + const c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 3 | 0); + const d = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 4 | 0); + const 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 [ env, - /* T_ARROW */10 + false ]; - case 36 : - case 44 : + case 14 : + const hex_code = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, lexbuf.lex_curr_pos - 1 | 0); + const code$6 = Caml_format.caml_int_of_string("0x" + hex_code); + const 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, - /* T_ASSIGN */75 + env$1, + false ]; - case 45 : + case 15 : + const c$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + const 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, - /* T_PLUS */94 + env$2, + false ]; - case 46 : + case 16 : + Stdlib__Lexing.new_line(lexbuf); return [ env, - /* T_MINUS */95 - ]; - case 47 : - let env$9; - if (env.lex_in_comment_syntax) { - const 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 + false ]; - case 48 : + case 17 : + const c$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c$3); return [ env, - /* T_ERROR */104 - ]; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function string_quote(env, q, buf, raw, octal, lexbuf) { - let ___ocaml_lex_state = 247; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - const q$p = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(raw, q$p); - if (q === q$p) { - return [ - env, - from_lb(env.lex_source, lexbuf), - octal - ]; - } else { - Stdlib__Buffer.add_char(buf, q$p); - return string_quote(env, q, buf, raw, octal, lexbuf); - } - case 1 : - const e = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(raw, e); - const match = string_escape(env, buf, lexbuf); - const octal$1 = match[1] || octal; - Stdlib__Buffer.add_string(raw, Stdlib__Lexing.lexeme(lexbuf)); - return string_quote(match[0], q, buf, raw, octal$1, lexbuf); - case 2 : - const x = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - Stdlib__Buffer.add_string(raw, x); - const env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); - Stdlib__Buffer.add_string(buf, x); - return [ - env$1, - from_lb(env$1.lex_source, lexbuf), - octal + false ]; - case 3 : - const x$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(raw, x$1); - Stdlib__Buffer.add_char(buf, x$1); - return string_quote(env, q, buf, raw, octal, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -5008,409 +4857,365 @@ function string_quote(env, q, buf, raw, octal, 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); + let ___ocaml_lex_state = 133; while(true) { const __ocaml_lex_state = ___ocaml_lex_state; - const env = _env; - const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + const __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 : const start = from_lb(env.lex_source, lexbuf); const buf = Stdlib__Buffer.create(127); - const match = line_comment(env, buf, lexbuf); + const match = comment(env, buf, lexbuf); const 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 : + const sp = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, Caml_array.get(lexbuf.lex_mem, 0)); + const escape_type = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + const pattern = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + if (env.lex_enable_comment_syntax) { + let env$2; + if (env.lex_in_comment_syntax) { + const loc = from_lb(env.lex_source, lexbuf); + env$2 = unexpected_error(env, loc, pattern); + } else { + env$2 = env; + } + const env$3 = in_comment_syntax(true, env$2); + if (escape_type === ":") { + return [ + env$3, + /* T_COLON */77 + ]; + } else { + return type_token(env$3, lexbuf); + } + } const start$1 = from_lb(env.lex_source, lexbuf); const buf$1 = Stdlib__Buffer.create(127); + Stdlib__Buffer.add_string(buf$1, sp); + Stdlib__Buffer.add_string(buf$1, escape_type); const match$1 = comment(env, buf$1, lexbuf); - const env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 393; - _env = env$2; - continue ; + const env$4 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + return type_token(env$4, lexbuf); case 4 : + if (env.lex_in_comment_syntax) { + const env$5 = in_comment_syntax(false, env); + return type_token(env$5, lexbuf); + } + yyback(1, lexbuf); + return [ + env, + /* T_MULT */97 + ]; + case 5 : const start$2 = from_lb(env.lex_source, lexbuf); - const cooked = Stdlib__Buffer.create(127); + const buf$2 = Stdlib__Buffer.create(127); + const match$2 = line_comment(env, buf$2, lexbuf); + const env$6 = save_comment(match$2[0], start$2, match$2[1], buf$2, true); + return type_token(env$6, lexbuf); + case 6 : + const quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + const start$3 = from_lb(env.lex_source, lexbuf); + const buf$3 = Stdlib__Buffer.create(127); const raw = Stdlib__Buffer.create(127); - const literal = Stdlib__Buffer.create(127); - Stdlib__Buffer.add_string(literal, "}"); - const 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 : - const env$3 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); + Stdlib__Buffer.add_char(raw, quote); + const 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 template_part(env, start, cooked, raw, literal, lexbuf) { - let ___ocaml_lex_state = 416; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - const env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); - return [ - env$1, - btwn(start, from_lb(env$1.lex_source, lexbuf)), - true - ]; - case 1 : - Stdlib__Buffer.add_char(literal, /* '`' */96); + case 7 : + const neg = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const num = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + const 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 : + const neg$1 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const num$1 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - btwn(start, from_lb(env.lex_source, lexbuf)), - true + mk_num_singleton(/* BINARY */0, num$1, neg$1) ]; - case 2 : - Stdlib__Buffer.add_string(literal, "${"); + case 9 : + const neg$2 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const num$2 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + const 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 : + const neg$3 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const num$3 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - btwn(start, from_lb(env.lex_source, lexbuf)), - false + mk_num_singleton(/* OCTAL */2, num$3, neg$3) ]; - case 3 : - Stdlib__Buffer.add_char(raw, /* '\\' */92); - Stdlib__Buffer.add_char(literal, /* '\\' */92); - const match = string_escape(env, cooked, lexbuf); - const 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 : - const 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 : - const 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 : - const 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); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function regexp_class(env, buf, lexbuf) { - let ___ocaml_lex_state = 326; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __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 : - const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c); - return env; - case 4 : - const 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 ; - } - const 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 string_escape(env, buf, lexbuf) { - let ___ocaml_lex_state = 252; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : + case 11 : + const neg$4 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const num$4 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + const 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 : + const neg$5 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const 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 1 : - Stdlib__Buffer.add_string(buf, "\\"); + case 13 : + const neg$6 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const num$6 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + const w$3 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + let match$4; + try { + match$4 = [ + env, + mk_num_singleton(/* NORMAL */3, num$6, neg$6) + ]; + } + catch (exn){ + if (Stdlib__Sys.win32) { + const loc$1 = from_lb(env.lex_source, lexbuf); + const 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 new Caml_js_exceptions.MelangeError(exn.MEL_EXN_ID, exn); + } + } + return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); + case 14 : + const neg$7 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const 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) { + const loc$2 = from_lb(env.lex_source, lexbuf); + const 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 new Caml_js_exceptions.MelangeError(exn$1.MEL_EXN_ID, exn$1); + } + case 15 : + const neg$8 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const num$8 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + const 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 : + const neg$9 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const 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 2 : - const a = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - const b = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - const 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 17 : + const neg$10 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + const num$10 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + const 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 : + const neg$11 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), Caml_array.get(lexbuf.lex_mem, 0)); + const num$11 = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 3), Caml_array.get(lexbuf.lex_mem, 2)); return [ env, - false + mk_num_singleton(/* NORMAL */3, num$11, neg$11) ]; - case 3 : - const a$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - const b$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - const 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 { - const 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 19 : + const 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){ + const exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn$2.MEL_EXN_ID === Stdlib.Not_found) { + return [ + env, + /* T_IDENTIFIER */0 + ]; + } + throw new Caml_js_exceptions.MelangeError(exn$2.MEL_EXN_ID, exn$2); } + case 22 : return [ env, - true + /* T_LCURLY */1 ]; - case 4 : - const a$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - const b$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - const 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 23 : return [ env, - true + /* T_RCURLY */2 ]; - case 5 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(0)); + case 24 : return [ env, - false + /* T_LPAREN */3 ]; - case 6 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(8)); + case 25 : return [ env, - false + /* T_RPAREN */4 ]; - case 7 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(12)); + case 26 : return [ env, - false + /* T_ELLIPSIS */11 ]; - case 8 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(10)); + case 27 : return [ env, - false + /* T_PERIOD */9 ]; - case 9 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(13)); + case 28 : return [ env, - false + /* T_SEMICOLON */7 ]; - case 10 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(9)); + case 29 : return [ env, - false + /* T_COMMA */8 ]; - case 11 : - Stdlib__Buffer.add_char(buf, Stdlib__Char.chr(11)); + case 20 : + case 32 : return [ env, - false + /* T_LBRACKET */5 ]; - case 12 : - const a$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - const code$4 = oct_to_int(a$3); - Stdlib__List.iter((function (param) { - return Stdlib__Buffer.add_char(buf, param); - }), utf16to8(code$4)); + case 21 : + case 33 : return [ env, - true + /* T_RBRACKET */6 ]; - case 13 : - const a$4 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - const b$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - const c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 3 | 0); - const d = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 4 | 0); - const 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 34 : return [ env, - false + /* T_LESS_THAN */89 ]; - case 14 : - const hex_code = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, lexbuf.lex_curr_pos - 1 | 0); - const code$6 = Caml_format.caml_int_of_string("0x" + hex_code); - const 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 35 : return [ - env$1, - false + env, + /* T_GREATER_THAN */90 ]; - case 15 : - const c$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - const env$2 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: /* UnexpectedToken */1, - _0: "ILLEGAL" - }); - Stdlib__Buffer.add_char(buf, c$2); + case 31 : + case 37 : return [ - env$2, - false + env, + /* T_PLING */76 ]; - case 16 : - Stdlib__Lexing.new_line(lexbuf); + case 38 : return [ env, - false + /* T_MULT */97 ]; - case 17 : - const c$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(buf, c$3); + case 30 : + case 39 : return [ env, - false + /* T_COLON */77 ]; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function jsx_child(env, start, buf, raw, lexbuf) { - let ___ocaml_lex_state = 364; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - const 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); - const match = jsx_text(env, /* JSX_CHILD_TEXT */2, buf, raw, lexbuf); - const value = Stdlib__Buffer.contents(buf); - const raw$1 = Stdlib__Buffer.contents(raw); + case 40 : return [ - match[0], - { - TAG: /* T_JSX_TEXT */4, - _0: [ - btwn(start, match[1]), - value, - raw$1 - ] - } + env, + /* T_BIT_OR */80 ]; - case 1 : + case 41 : return [ env, - /* T_EOF */105 + /* T_BIT_AND */82 ]; - case 2 : + case 42 : return [ env, - /* T_LESS_THAN */89 + /* T_TYPEOF */44 ]; - case 3 : + case 43 : return [ env, - /* T_LCURLY */1 + /* T_ARROW */10 ]; - case 4 : - const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - Stdlib__Buffer.add_char(raw, c); - Stdlib__Buffer.add_char(buf, c); - const match$1 = jsx_text(env, /* JSX_CHILD_TEXT */2, buf, raw, lexbuf); - const value$1 = Stdlib__Buffer.contents(buf); - const raw$2 = Stdlib__Buffer.contents(raw); + case 36 : + case 44 : return [ - match$1[0], - { - TAG: /* T_JSX_TEXT */4, - _0: [ - btwn(start, match$1[1]), - value$1, - raw$2 - ] - } + env, + /* T_ASSIGN */75 + ]; + case 45 : + return [ + env, + /* T_PLUS */94 + ]; + case 46 : + return [ + env, + /* T_MINUS */95 + ]; + case 47 : + let env$9; + if (env.lex_in_comment_syntax) { + const 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); @@ -5420,27 +5225,222 @@ 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) { - const start = from_curr_lb(env.lex_source, env.lex_lb); - const buf = Stdlib__Buffer.create(127); - const raw = Stdlib__Buffer.create(127); - const 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 __ocaml_lex_regexp_rec(_env, lexbuf, ___ocaml_lex_state) { + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const env = _env; + const __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 : + const start = from_lb(env.lex_source, lexbuf); + const buf = Stdlib__Buffer.create(127); + const match = line_comment(env, buf, lexbuf); + const env$1 = save_comment(match[0], start, match[1], buf, true); + ___ocaml_lex_state = 291; + _env = env$1; + continue ; + case 4 : + const start$1 = from_lb(env.lex_source, lexbuf); + const buf$1 = Stdlib__Buffer.create(127); + const match$1 = comment(env, buf$1, lexbuf); + const 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 : + const start$2 = from_lb(env.lex_source, lexbuf); + const buf$2 = Stdlib__Buffer.create(127); + const match$2 = regexp_body(env, buf$2, lexbuf); + const env$3 = match$2[0]; + const end_ = from_lb(env$3.lex_source, lexbuf); + const loc = btwn(start$2, end_); + return [ + env$3, + { + TAG: /* T_REGEXP */3, + _0: [ + loc, + Stdlib__Buffer.contents(buf$2), + match$2[1] + ] + } + ]; + case 6 : + const 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 regexp_body(env, buf, lexbuf) { + let ___ocaml_lex_state = 314; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + const loc = from_lb(env.lex_source, lexbuf); + const env$1 = lex_error(env, loc, /* UnterminatedRegExp */13); + return [ + env$1, + "" + ]; + case 1 : + const loc$1 = from_lb(env.lex_source, lexbuf); + const env$2 = lex_error(env, loc$1, /* UnterminatedRegExp */13); + return [ + env$2, + "" + ]; + case 2 : + const 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 : + const flags = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 1 | 0, lexbuf.lex_curr_pos); + return [ + env, + flags + ]; + case 4 : + return [ + env, + "" + ]; + case 5 : + const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(buf, c); + const env$3 = regexp_class(env, buf, lexbuf); + return regexp_body(env$3, buf, lexbuf); + case 6 : + const loc$2 = from_lb(env.lex_source, lexbuf); + const env$4 = lex_error(env, loc$2, /* UnterminatedRegExp */13); + return [ + env$4, + "" + ]; + case 7 : + const 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 jsx_child(env, start, buf, raw, lexbuf) { + let ___ocaml_lex_state = 364; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + const 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); + const match = jsx_text(env, /* JSX_CHILD_TEXT */2, buf, raw, lexbuf); + const value = Stdlib__Buffer.contents(buf); + const 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 : + const c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + Stdlib__Buffer.add_char(raw, c); + Stdlib__Buffer.add_char(buf, c); + const match$1 = jsx_text(env, /* JSX_CHILD_TEXT */2, buf, raw, lexbuf); + const value$1 = Stdlib__Buffer.contents(buf); + const 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 ; + } + }; +} + +function regexp(env) { + return get_result_and_clear_state(__ocaml_lex_regexp_rec(env, env.lex_lb, 291)); +} + +function jsx_child$1(env) { + const start = from_curr_lb(env.lex_source, env.lex_lb); + const buf = Stdlib__Buffer.create(127); + const raw = Stdlib__Buffer.create(127); + const 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) { @@ -6907,10 +6907,30 @@ const Parse = Caml_module.init_mod([ ] }); -function intersection(env) { - maybe(env, /* T_BIT_AND */82); - const left = prefix(env); - return Curry._2(intersection_with, env, left); +function union(env) { + maybe(env, /* T_BIT_OR */80); + const left = intersection(env); + return Curry._2(union_with, env, left); +} + +function prefix(env) { + const match = Curry._2(Parser_env_Peek.token, undefined, env); + if (!/* tag */(typeof match === "number" || typeof match === "string")) { + return postfix(env); + } + if (match !== /* T_PLING */76) { + return postfix(env); + } + const loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_PLING */76); + const t = prefix(env); + return [ + btwn(loc, t[0]), + { + TAG: /* Nullable */0, + _0: t + } + ]; } function rev_nonempty_acc(acc) { @@ -6947,22 +6967,25 @@ function rev_nonempty_acc(acc) { ]; } -function prefix(env) { - const match = Curry._2(Parser_env_Peek.token, undefined, env); - if (!/* tag */(typeof match === "number" || typeof match === "string")) { - return postfix(env); - } - if (match !== /* T_PLING */76) { - return postfix(env); - } - const loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_PLING */76); - const t = prefix(env); - return [ - btwn(loc, t[0]), +function intersection(env) { + maybe(env, /* T_BIT_AND */82); + const left = prefix(env); + return Curry._2(intersection_with, env, left); +} + +function function_param_with_id(env, name) { + if (!env.parse_options.types) { + error$1(env, /* UnexpectedTypeAnnotation */6); + } + const optional = maybe(env, /* T_PLING */76); + token$4(env, /* T_COLON */77); + const typeAnnotation = union(env); + return [ + btwn(name[0], typeAnnotation[0]), { - TAG: /* Nullable */0, - _0: t + name: name, + typeAnnotation: typeAnnotation, + optional: optional } ]; } @@ -6989,99 +7012,17 @@ function postfix_with(env, _t) { }; } -function union(env) { - maybe(env, /* T_BIT_OR */80); - const 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); - } - const optional = maybe(env, /* T_PLING */76); - token$4(env, /* T_COLON */77); - const typeAnnotation = union(env); +function generic_type_with_identifier(env, id) { + const match = Curry._2(raw_generic_with_identifier, env, id); return [ - btwn(name[0], typeAnnotation[0]), + match[0], { - name: name, - typeAnnotation: typeAnnotation, - optional: optional + TAG: /* Generic */4, + _0: match[1] } ]; } -function postfix(env) { - const t = primary(env); - return postfix_with(env, t); -} - -function primitive(param) { - if (!/* tag */(typeof param === "number" || typeof param === "string")) { - return ; - } - switch (param) { - case /* T_NULL */27 : - return /* Null */2; - 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; - default: - return ; - } -} - -function function_param_or_generic_type(env) { - const id = Curry._2(Parse.identifier, undefined, env); - const match = Curry._2(Parser_env_Peek.token, undefined, env); - let exit = 0; - if (/* tag */typeof match === "number" || typeof match === "string") { - switch (match) { - case /* T_PLING */76 : - case /* T_COLON */77 : - exit = 2; - break; - default: - exit = 1; - } - } else { - exit = 1; - } - switch (exit) { - case 1 : - return { - TAG: /* Type */1, - _0: Curry._2(union_with, env, Curry._2(intersection_with, env, postfix_with(env, generic_type_with_identifier(env, id)))) - }; - case 2 : - const 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 - }) - }; - - } -} - -function function_param_list(env) { - token$4(env, /* T_LPAREN */3); - const ret = Curry._2(function_param_list_without_parens, env, /* [] */0); - token$4(env, /* T_RPAREN */4); - return ret; -} - function param_list_or_type(env) { token$4(env, /* T_LPAREN */3); const token$5 = Curry._2(Parser_env_Peek.token, undefined, env); @@ -7179,15 +7120,11 @@ function param_list_or_type(env) { return ret; } -function generic_type_with_identifier(env, id) { - const match = Curry._2(raw_generic_with_identifier, env, id); - return [ - match[0], - { - TAG: /* Generic */4, - _0: match[1] - } - ]; +function function_param_list(env) { + token$4(env, /* T_LPAREN */3); + const ret = Curry._2(function_param_list_without_parens, env, /* [] */0); + token$4(env, /* T_RPAREN */4); + return ret; } function primary(env) { @@ -7382,10 +7319,73 @@ function primary(env) { } } +function primitive(param) { + if (!/* tag */(typeof param === "number" || typeof param === "string")) { + return ; + } + switch (param) { + case /* T_NULL */27 : + return /* Null */2; + 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; + default: + return ; + } +} + +function function_param_or_generic_type(env) { + const id = Curry._2(Parse.identifier, undefined, env); + const match = Curry._2(Parser_env_Peek.token, undefined, env); + let exit = 0; + if (/* tag */typeof match === "number" || typeof match === "string") { + switch (match) { + case /* T_PLING */76 : + case /* T_COLON */77 : + exit = 2; + break; + default: + exit = 1; + } + } else { + exit = 1; + } + switch (exit) { + case 1 : + return { + TAG: /* Type */1, + _0: Curry._2(union_with, env, Curry._2(intersection_with, env, postfix_with(env, generic_type_with_identifier(env, id)))) + }; + case 2 : + const 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 + }) + }; + + } +} + function generic(env) { return Curry._2(raw_generic_with_identifier, env, Curry._2(Parse.identifier, undefined, env)); } +function postfix(env) { + const t = primary(env); + return postfix_with(env, t); +} + function union_with(env, left) { if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_BIT_OR */80)) { let _acc = { @@ -7417,61 +7417,6 @@ function union_with(env, left) { } } -function identifier(env, _param) { - while(true) { - const param = _param; - const qualification = param[1]; - const 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); - const id = Curry._2(Parse.identifier, undefined, env); - const loc = btwn(q_loc, id[0]); - const qualification$1 = { - TAG: /* Qualified */1, - _0: [ - loc, - { - qualification: qualification, - id: id - } - ] - }; - _param = [ - loc, - qualification$1 - ]; - continue ; - }; -} - -function raw_generic_with_identifier(env, id) { - const id_0 = id[0]; - const id_1 = { - TAG: /* Unqualified */0, - _0: id - }; - const id$1 = [ - id_0, - id_1 - ]; - const match = identifier(env, id$1); - const id_loc = match[0]; - const typeParameters = Curry._1(type_parameter_instantiation, env); - const loc = typeParameters !== undefined ? btwn(id_loc, typeParameters[0]) : id_loc; - return [ - loc, - { - id: match[1], - typeParameters: typeParameters - } - ]; -} - function intersection_with(env, left) { if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_BIT_AND */82)) { let _acc = { @@ -7552,17 +7497,72 @@ function function_param_list_without_parens(env) { }; } -function params(env, _acc) { +function identifier(env, _param) { while(true) { - const acc = _acc; - const match = Curry._2(Parser_env_Peek.token, undefined, env); - if (/* tag */typeof match === "number" || typeof match === "string") { - switch (match) { - case /* T_GREATER_THAN */90 : - case /* T_EOF */105 : - return Stdlib__List.rev(acc); - default: - + const param = _param; + const qualification = param[1]; + const 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); + const id = Curry._2(Parse.identifier, undefined, env); + const loc = btwn(q_loc, id[0]); + const qualification$1 = { + TAG: /* Qualified */1, + _0: [ + loc, + { + qualification: qualification, + id: id + } + ] + }; + _param = [ + loc, + qualification$1 + ]; + continue ; + }; +} + +function raw_generic_with_identifier(env, id) { + const id_0 = id[0]; + const id_1 = { + TAG: /* Unqualified */0, + _0: id + }; + const id$1 = [ + id_0, + id_1 + ]; + const match = identifier(env, id$1); + const id_loc = match[0]; + const typeParameters = Curry._1(type_parameter_instantiation, env); + const loc = typeParameters !== undefined ? btwn(id_loc, typeParameters[0]) : id_loc; + return [ + loc, + { + id: match[1], + typeParameters: typeParameters + } + ]; +} + +function params(env, _acc) { + while(true) { + const acc = _acc; + const match = Curry._2(Parser_env_Peek.token, undefined, env); + if (/* tag */typeof match === "number" || typeof match === "string") { + switch (match) { + case /* T_GREATER_THAN */90 : + case /* T_EOF */105 : + return Stdlib__List.rev(acc); + default: + } } const acc_0 = union(env); @@ -11507,37 +11507,6 @@ function class_expression(env) { ]; } -function expression(env) { - const expression$1 = Curry._1(Parse.expression, env); - const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc = loc !== undefined ? loc : expression$1[0]; - semicolon(env); - return [ - btwn(expression$1[0], end_loc), - { - TAG: /* Expression */1, - _0: { - expression: expression$1 - } - } - ]; -} - -function declare_var(env, start_loc) { - token$4(env, /* T_VAR */22); - const id = Curry._2(Parse.identifier_with_type, env, /* StrictVarName */27); - const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc = loc !== undefined ? loc : id[0]; - const loc$1 = btwn(start_loc, end_loc); - semicolon(env); - return [ - loc$1, - { - id: id - } - ]; -} - function declare_function(env, start_loc) { token$4(env, /* T_FUNCTION */13); const id = Curry._2(Parse.identifier, undefined, env); @@ -11590,75 +11559,348 @@ function declare_function(env, start_loc) { ]; } -function declare_export_declaration(allow_export_typeOpt, env) { - const allow_export_type = allow_export_typeOpt !== undefined ? allow_export_typeOpt : false; +function expression(env) { + const expression$1 = Curry._1(Parse.expression, env); + const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc = loc !== undefined ? loc : expression$1[0]; + semicolon(env); + return [ + btwn(expression$1[0], end_loc), + { + TAG: /* Expression */1, + _0: { + expression: expression$1 + } + } + ]; +} + +function type_alias_helper(env) { + const 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); + const id = Curry._2(Parse.identifier, undefined, env); + const typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); + token$4(env, /* T_ASSIGN */75); + const right = wrap(_type, env); + const end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc$1 = end_loc !== undefined ? end_loc : right[0]; + semicolon(env); + pop_lex_mode(env); + return [ + btwn(start_loc, end_loc$1), + { + id: id, + typeParameters: typeParameters, + right: right + } + ]; +} + +function declare(in_moduleOpt, env) { + const in_module = in_moduleOpt !== undefined ? in_moduleOpt : false; if (!env.parse_options.types) { error$1(env, /* UnexpectedTypeDeclaration */7); } const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_DECLARE */58); - const env$1 = with_in_export(true, with_strict(true, env)); - token$4(env$1, /* T_EXPORT */47); - const match = Curry._2(Parser_env_Peek.token, undefined, env$1); - let exit = 0; + const match = Curry._2(Parser_env_Peek.token, 1, env); if (/* tag */typeof match === "number" || typeof match === "string") { switch (match) { - case /* T_DEFAULT */34 : - token$4(env$1, /* T_DEFAULT */34); - const match$1 = Curry._2(Parser_env_Peek.token, undefined, env$1); - let match$2; - let exit$1 = 0; - if (/* tag */typeof match$1 === "number" || typeof match$1 === "string") { - switch (match$1) { - case /* T_FUNCTION */13 : - const fn = declare_function(env$1, start_loc); - match$2 = [ - fn[0], - { - TAG: /* Function */1, - _0: fn - } - ]; - break; - case /* T_CLASS */38 : - const _class = Curry._2(declare_class, env$1, start_loc); - match$2 = [ - _class[0], + case /* T_IDENTIFIER */0 : + if (Curry._2(Parser_env_Peek.value, 1, env) === "module") { + token$4(env, /* T_DECLARE */58); + contextual(env, "module"); + if (in_module || Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_PERIOD */9)) { + token$4(env, /* T_PERIOD */9); + contextual(env, "exports"); + const type_annot = wrap(annotation, env); + const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc = loc !== undefined ? loc : type_annot[0]; + semicolon(env); + const loc$1 = btwn(start_loc, end_loc); + return [ + loc$1, + { + TAG: /* DeclareModuleExports */26, + _0: type_annot + } + ]; + } else { + const match$1 = Curry._2(Parser_env_Peek.token, undefined, env); + let id; + if (/* tag */typeof match$1 === "number" || typeof match$1 === "string" || match$1.TAG !== /* T_STRING */1) { + id = { + TAG: /* Identifier */0, + _0: Curry._2(Parse.identifier, undefined, env) + }; + } else { + const match$2 = match$1._0; + const octal = match$2[3]; + const raw = match$2[2]; + const value = match$2[1]; + const loc$2 = match$2[0]; + if (octal) { + strict_error(env, /* StrictOctalLiteral */31); + } + token$4(env, { + TAG: /* T_STRING */1, + _0: [ + loc$2, + value, + raw, + octal + ] + }); + const value$1 = { + TAG: /* String */0, + _0: value + }; + id = { + TAG: /* Literal */1, + _0: [ + loc$2, { - TAG: /* Class */2, - _0: _class + value: value$1, + raw: raw } - ]; - break; - default: - exit$1 = 3; - } - } else { - exit$1 = 3; - } - if (exit$1 === 3) { - const _type$1 = wrap(_type, env$1); - const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); - const end_loc = loc !== undefined ? loc : _type$1[0]; - semicolon(env$1); - match$2 = [ - end_loc, - { - TAG: /* DefaultType */3, - _0: _type$1 + ] + }; } - ]; - } - return [ - btwn(start_loc, match$2[0]), - { - TAG: /* DeclareExportDeclaration */27, - _0: { - default: true, - declaration: match$2[1], - specifiers: undefined, - source: undefined - } + const body_start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_LCURLY */1); + const match$3 = module_items(env, undefined, /* [] */0); + const module_kind = match$3[0]; + token$4(env, /* T_RCURLY */2); + const body_end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + const body_loc = btwn(body_start_loc, body_end_loc); + const body_1 = { + body: match$3[1] + }; + const body = [ + body_loc, + body_1 + ]; + const loc$3 = btwn(start_loc, body_loc); + const kind = module_kind !== undefined ? module_kind : ({ + TAG: /* CommonJS */0, + _0: loc$3 + }); + return [ + loc$3, + { + TAG: /* DeclareModule */25, + _0: { + id: id, + body: body, + kind: kind + } + } + ]; + } + } + break; + case /* T_FUNCTION */13 : + token$4(env, /* T_DECLARE */58); + return declare_function_statement(env, start_loc); + case /* T_VAR */22 : + token$4(env, /* T_DECLARE */58); + return declare_var_statement(env, start_loc); + case /* T_CLASS */38 : + token$4(env, /* T_DECLARE */58); + const match$4 = Curry._2(declare_class, env, start_loc); + return [ + match$4[0], + { + TAG: /* DeclareClass */24, + _0: match$4[1] + } + ]; + case /* T_EXPORT */47 : + if (in_module) { + return declare_export_declaration(in_module, env); + } + break; + case /* T_INTERFACE */51 : + token$4(env, /* T_DECLARE */58); + return $$interface(env); + case /* T_TYPE */59 : + token$4(env, /* T_DECLARE */58); + return type_alias(env); + case /* T_ASYNC */61 : + token$4(env, /* T_DECLARE */58); + error$1(env, /* DeclareAsync */49); + token$4(env, /* T_ASYNC */61); + return declare_function_statement(env, start_loc); + default: + + } + } + if (in_module) { + token$4(env, /* T_DECLARE */58); + return declare_var_statement(env, start_loc); + } else { + return Curry._1(Parse.statement, env); + } +} + +function extract_ident_name(param) { + return param[1].name; +} + +function export_specifiers_and_errs(env, _specifiers, _errs) { + while(true) { + const errs = _errs; + const specifiers = _specifiers; + const match = Curry._2(Parser_env_Peek.token, undefined, env); + if (/* tag */typeof match === "number" || typeof match === "string") { + switch (match) { + case /* T_RCURLY */2 : + case /* T_EOF */105 : + return [ + Stdlib__List.rev(specifiers), + Stdlib__List.rev(errs) + ]; + default: + + } + } + const match$1 = Curry._1(Parse.identifier_or_reserved_keyword, env); + const id = match$1[0]; + let match$2; + if (Curry._2(Parser_env_Peek.value, undefined, env) === "as") { + contextual(env, "as"); + const match$3 = Curry._1(Parse.identifier_or_reserved_keyword, env); + const name = match$3[0]; + record_export(env, [ + name[0], + extract_ident_name(name) + ]); + match$2 = [ + name, + undefined, + name[0] + ]; + } else { + const loc = id[0]; + record_export(env, [ + loc, + extract_ident_name(id) + ]); + match$2 = [ + undefined, + match$1[1], + loc + ]; + } + const err = match$2[1]; + const loc$1 = btwn(id[0], match$2[2]); + const specifier_1 = { + id: id, + name: match$2[0] + }; + const 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); + } + const errs$1 = err !== undefined ? ({ + hd: err, + tl: errs + }) : errs; + _errs = errs$1; + _specifiers = { + hd: specifier, + tl: specifiers + }; + continue ; + }; +} + +function declare_var_statement(env, start_loc) { + const match = declare_var(env, start_loc); + return [ + match[0], + { + TAG: /* DeclareVariable */22, + _0: match[1] + } + ]; +} + +function declare_export_declaration(allow_export_typeOpt, env) { + const allow_export_type = allow_export_typeOpt !== undefined ? allow_export_typeOpt : false; + if (!env.parse_options.types) { + error$1(env, /* UnexpectedTypeDeclaration */7); + } + const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_DECLARE */58); + const env$1 = with_in_export(true, with_strict(true, env)); + token$4(env$1, /* T_EXPORT */47); + const match = Curry._2(Parser_env_Peek.token, undefined, env$1); + let exit = 0; + if (/* tag */typeof match === "number" || typeof match === "string") { + switch (match) { + case /* T_DEFAULT */34 : + token$4(env$1, /* T_DEFAULT */34); + const match$1 = Curry._2(Parser_env_Peek.token, undefined, env$1); + let match$2; + let exit$1 = 0; + if (/* tag */typeof match$1 === "number" || typeof match$1 === "string") { + switch (match$1) { + case /* T_FUNCTION */13 : + const fn = declare_function(env$1, start_loc); + match$2 = [ + fn[0], + { + TAG: /* Function */1, + _0: fn + } + ]; + break; + case /* T_CLASS */38 : + const _class = Curry._2(declare_class, env$1, start_loc); + match$2 = [ + _class[0], + { + TAG: /* Class */2, + _0: _class + } + ]; + break; + default: + exit$1 = 3; + } + } else { + exit$1 = 3; + } + if (exit$1 === 3) { + const _type$1 = wrap(_type, env$1); + const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); + const end_loc = loc !== undefined ? loc : _type$1[0]; + semicolon(env$1); + match$2 = [ + end_loc, + { + TAG: /* DefaultType */3, + _0: _type$1 + } + ]; + } + return [ + btwn(start_loc, match$2[0]), + { + TAG: /* DeclareExportDeclaration */27, + _0: { + default: true, + declaration: match$2[1], + specifiers: undefined, + source: undefined + } } ]; case /* T_FUNCTION */13 : @@ -11899,20 +12141,6 @@ function type_alias(env) { ]; } -function $$interface(env) { - if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { - return expression(env); - } - const match = Curry._1(interface_helper, env); - return [ - match[0], - { - TAG: /* InterfaceDeclaration */21, - _0: match[1] - } - ]; -} - function declare_function_statement(env, start_loc) { const match = declare_function(env, start_loc); return [ @@ -11924,161 +12152,33 @@ function declare_function_statement(env, start_loc) { ]; } -function declare_var_statement(env, start_loc) { - const match = declare_var(env, start_loc); +function $$interface(env) { + if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { + return expression(env); + } + const match = Curry._1(interface_helper, env); return [ match[0], { - TAG: /* DeclareVariable */22, + TAG: /* InterfaceDeclaration */21, _0: match[1] } ]; } -function declare(in_moduleOpt, env) { - const in_module = in_moduleOpt !== undefined ? in_moduleOpt : false; - if (!env.parse_options.types) { - error$1(env, /* UnexpectedTypeDeclaration */7); - } - const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - const match = Curry._2(Parser_env_Peek.token, 1, env); - if (/* tag */typeof match === "number" || typeof match === "string") { - switch (match) { - case /* T_IDENTIFIER */0 : - if (Curry._2(Parser_env_Peek.value, 1, env) === "module") { - token$4(env, /* T_DECLARE */58); - contextual(env, "module"); - if (in_module || Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_PERIOD */9)) { - token$4(env, /* T_PERIOD */9); - contextual(env, "exports"); - const type_annot = wrap(annotation, env); - const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc = loc !== undefined ? loc : type_annot[0]; - semicolon(env); - const loc$1 = btwn(start_loc, end_loc); - return [ - loc$1, - { - TAG: /* DeclareModuleExports */26, - _0: type_annot - } - ]; - } else { - const match$1 = Curry._2(Parser_env_Peek.token, undefined, env); - let id; - if (/* tag */typeof match$1 === "number" || typeof match$1 === "string" || match$1.TAG !== /* T_STRING */1) { - id = { - TAG: /* Identifier */0, - _0: Curry._2(Parse.identifier, undefined, env) - }; - } else { - const match$2 = match$1._0; - const octal = match$2[3]; - const raw = match$2[2]; - const value = match$2[1]; - const loc$2 = match$2[0]; - if (octal) { - strict_error(env, /* StrictOctalLiteral */31); - } - token$4(env, { - TAG: /* T_STRING */1, - _0: [ - loc$2, - value, - raw, - octal - ] - }); - const value$1 = { - TAG: /* String */0, - _0: value - }; - id = { - TAG: /* Literal */1, - _0: [ - loc$2, - { - value: value$1, - raw: raw - } - ] - }; - } - const body_start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_LCURLY */1); - const match$3 = module_items(env, undefined, /* [] */0); - const module_kind = match$3[0]; - token$4(env, /* T_RCURLY */2); - const body_end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - const body_loc = btwn(body_start_loc, body_end_loc); - const body_1 = { - body: match$3[1] - }; - const body = [ - body_loc, - body_1 - ]; - const loc$3 = btwn(start_loc, body_loc); - const kind = module_kind !== undefined ? module_kind : ({ - TAG: /* CommonJS */0, - _0: loc$3 - }); - return [ - loc$3, - { - TAG: /* DeclareModule */25, - _0: { - id: id, - body: body, - kind: kind - } - } - ]; - } - } - break; - case /* T_FUNCTION */13 : - token$4(env, /* T_DECLARE */58); - return declare_function_statement(env, start_loc); - case /* T_VAR */22 : - token$4(env, /* T_DECLARE */58); - return declare_var_statement(env, start_loc); - case /* T_CLASS */38 : - token$4(env, /* T_DECLARE */58); - const match$4 = Curry._2(declare_class, env, start_loc); - return [ - match$4[0], - { - TAG: /* DeclareClass */24, - _0: match$4[1] - } - ]; - case /* T_EXPORT */47 : - if (in_module) { - return declare_export_declaration(in_module, env); +function declare_var(env, start_loc) { + token$4(env, /* T_VAR */22); + const id = Curry._2(Parse.identifier_with_type, env, /* StrictVarName */27); + const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc = loc !== undefined ? loc : id[0]; + const loc$1 = btwn(start_loc, end_loc); + semicolon(env); + return [ + loc$1, + { + id: id } - break; - case /* T_INTERFACE */51 : - token$4(env, /* T_DECLARE */58); - return $$interface(env); - case /* T_TYPE */59 : - token$4(env, /* T_DECLARE */58); - return type_alias(env); - case /* T_ASYNC */61 : - token$4(env, /* T_DECLARE */58); - error$1(env, /* DeclareAsync */49); - token$4(env, /* T_ASYNC */61); - return declare_function_statement(env, start_loc); - default: - - } - } - if (in_module) { - token$4(env, /* T_DECLARE */58); - return declare_var_statement(env, start_loc); - } else { - return Curry._1(Parse.statement, env); - } + ]; } function export_source(env) { @@ -12132,204 +12232,104 @@ function export_source(env) { return ret; } -function type_alias_helper(env) { +function supers(env, _acc) { + while(true) { + const acc = _acc; + const $$super = wrap(generic, env); + const acc$1 = { + hd: $$super, + tl: acc + }; + const match = Curry._2(Parser_env_Peek.token, undefined, env); + if (!/* tag */(typeof match === "number" || typeof match === "string")) { + return Stdlib__List.rev(acc$1); + } + if (match !== /* T_COMMA */8) { + return Stdlib__List.rev(acc$1); + } + token$4(env, /* T_COMMA */8); + _acc = acc$1; + continue ; + }; +} + +function interface_helper(env) { const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); if (!env.parse_options.types) { - error$1(env, /* UnexpectedTypeAlias */5); + error$1(env, /* UnexpectedTypeInterface */10); } - token$4(env, /* T_TYPE */59); - push_lex_mode(env, /* TYPE */1); + token$4(env, /* T_INTERFACE */51); const id = Curry._2(Parse.identifier, undefined, env); const typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); - token$4(env, /* T_ASSIGN */75); - const right = wrap(_type, env); - const end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc$1 = end_loc !== undefined ? end_loc : right[0]; - semicolon(env); - pop_lex_mode(env); + const $$extends = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_EXTENDS */39) ? (token$4(env, /* T_EXTENDS */39), supers(env, /* [] */0)) : /* [] */0; + const body = _object$1(true, env); + const loc = btwn(start_loc, body[0]); return [ - btwn(start_loc, end_loc$1), + loc, { id: id, typeParameters: typeParameters, - right: right + body: body, + extends: $$extends, + mixins: /* [] */0 } ]; } -function export_specifiers_and_errs(env, _specifiers, _errs) { +function supers$1(env, _acc) { while(true) { - const errs = _errs; - const specifiers = _specifiers; + const acc = _acc; + const $$super = wrap(generic, env); + const acc$1 = { + hd: $$super, + tl: acc + }; + const match = Curry._2(Parser_env_Peek.token, undefined, env); + if (!/* tag */(typeof match === "number" || typeof match === "string")) { + return Stdlib__List.rev(acc$1); + } + if (match !== /* T_COMMA */8) { + return Stdlib__List.rev(acc$1); + } + token$4(env, /* T_COMMA */8); + _acc = acc$1; + continue ; + }; +} + +function declare_class(env, start_loc) { + const env$1 = with_strict(true, env); + token$4(env$1, /* T_CLASS */38); + const id = Curry._2(Parse.identifier, undefined, env$1); + const typeParameters = Curry._1(type_parameter_declaration_with_defaults, env$1); + const $$extends = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env$1), /* T_EXTENDS */39) ? (token$4(env$1, /* T_EXTENDS */39), supers$1(env$1, /* [] */0)) : /* [] */0; + const mixins = Curry._2(Parser_env_Peek.value, undefined, env$1) === "mixins" ? (contextual(env$1, "mixins"), supers$1(env$1, /* [] */0)) : /* [] */0; + const body = _object$1(true, env$1); + const loc = btwn(start_loc, body[0]); + return [ + loc, + { + id: id, + typeParameters: typeParameters, + body: body, + extends: $$extends, + mixins: mixins + } + ]; +} + +function module_items(env, _module_kind, _acc) { + while(true) { + const acc = _acc; + const module_kind = _module_kind; const match = Curry._2(Parser_env_Peek.token, undefined, env); if (/* tag */typeof match === "number" || typeof match === "string") { switch (match) { case /* T_RCURLY */2 : case /* T_EOF */105 : return [ - Stdlib__List.rev(specifiers), - Stdlib__List.rev(errs) - ]; - default: - - } - } - const match$1 = Curry._1(Parse.identifier_or_reserved_keyword, env); - const id = match$1[0]; - let match$2; - if (Curry._2(Parser_env_Peek.value, undefined, env) === "as") { - contextual(env, "as"); - const match$3 = Curry._1(Parse.identifier_or_reserved_keyword, env); - const name = match$3[0]; - record_export(env, [ - name[0], - extract_ident_name(name) - ]); - match$2 = [ - name, - undefined, - name[0] - ]; - } else { - const loc = id[0]; - record_export(env, [ - loc, - extract_ident_name(id) - ]); - match$2 = [ - undefined, - match$1[1], - loc - ]; - } - const err = match$2[1]; - const loc$1 = btwn(id[0], match$2[2]); - const specifier_1 = { - id: id, - name: match$2[0] - }; - const 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); - } - const errs$1 = err !== undefined ? ({ - hd: err, - tl: errs - }) : errs; - _errs = errs$1; - _specifiers = { - hd: specifier, - tl: specifiers - }; - continue ; - }; -} - -function extract_ident_name(param) { - return param[1].name; -} - -function supers(env, _acc) { - while(true) { - const acc = _acc; - const $$super = wrap(generic, env); - const acc$1 = { - hd: $$super, - tl: acc - }; - const match = Curry._2(Parser_env_Peek.token, undefined, env); - if (!/* tag */(typeof match === "number" || typeof match === "string")) { - return Stdlib__List.rev(acc$1); - } - if (match !== /* T_COMMA */8) { - return Stdlib__List.rev(acc$1); - } - token$4(env, /* T_COMMA */8); - _acc = acc$1; - continue ; - }; -} - -function declare_class(env, start_loc) { - const env$1 = with_strict(true, env); - token$4(env$1, /* T_CLASS */38); - const id = Curry._2(Parse.identifier, undefined, env$1); - const typeParameters = Curry._1(type_parameter_declaration_with_defaults, env$1); - const $$extends = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env$1), /* T_EXTENDS */39) ? (token$4(env$1, /* T_EXTENDS */39), supers(env$1, /* [] */0)) : /* [] */0; - const mixins = Curry._2(Parser_env_Peek.value, undefined, env$1) === "mixins" ? (contextual(env$1, "mixins"), supers(env$1, /* [] */0)) : /* [] */0; - const body = _object$1(true, env$1); - const loc = btwn(start_loc, body[0]); - return [ - loc, - { - id: id, - typeParameters: typeParameters, - body: body, - extends: $$extends, - mixins: mixins - } - ]; -} - -function supers$1(env, _acc) { - while(true) { - const acc = _acc; - const $$super = wrap(generic, env); - const acc$1 = { - hd: $$super, - tl: acc - }; - const match = Curry._2(Parser_env_Peek.token, undefined, env); - if (!/* tag */(typeof match === "number" || typeof match === "string")) { - return Stdlib__List.rev(acc$1); - } - if (match !== /* T_COMMA */8) { - return Stdlib__List.rev(acc$1); - } - token$4(env, /* T_COMMA */8); - _acc = acc$1; - continue ; - }; -} - -function interface_helper(env) { - const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (!env.parse_options.types) { - error$1(env, /* UnexpectedTypeInterface */10); - } - token$4(env, /* T_INTERFACE */51); - const id = Curry._2(Parse.identifier, undefined, env); - const typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); - const $$extends = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_EXTENDS */39) ? (token$4(env, /* T_EXTENDS */39), supers$1(env, /* [] */0)) : /* [] */0; - const body = _object$1(true, env); - const loc = btwn(start_loc, body[0]); - return [ - loc, - { - id: id, - typeParameters: typeParameters, - body: body, - extends: $$extends, - mixins: /* [] */0 - } - ]; -} - -function module_items(env, _module_kind, _acc) { - while(true) { - const acc = _acc; - const module_kind = _module_kind; - const match = Curry._2(Parser_env_Peek.token, undefined, env); - if (/* tag */typeof match === "number" || typeof match === "string") { - switch (match) { - case /* T_RCURLY */2 : - case /* T_EOF */105 : - return [ - module_kind, - Stdlib__List.rev(acc) + module_kind, + Stdlib__List.rev(acc) ]; default: @@ -13674,1184 +13674,1184 @@ function element_without_lt(env, start_loc) { ]; } -function statement(env) { - while(true) { - const match = Curry._2(Parser_env_Peek.token, undefined, env); - let exit = 0; - if (/* tag */typeof match === "number" || typeof match === "string") { - switch (match) { - case /* T_LCURLY */1 : - const match$1 = Curry._1(Parse.block_body, env); - return [ - match$1[0], - { - TAG: /* Block */0, - _0: match$1[1] - } - ]; - case /* T_SEMICOLON */7 : - const loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_SEMICOLON */7); - return [ - loc, - /* Empty */0 - ]; - case /* T_IF */14 : - return _if(env); - case /* T_RETURN */17 : - if (!env.in_function) { - error$1(env, /* IllegalReturn */23); - } - const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_RETURN */17); - const argument = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_SEMICOLON */7) || Curry._1(Parser_env_Peek.is_implicit_semicolon, env) ? undefined : Curry._1(Parse.expression, env); - const loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc = loc$1 !== undefined ? loc$1 : ( - argument !== undefined ? argument[0] : start_loc - ); - semicolon(env); - return [ - btwn(start_loc, end_loc), +function module_item(env) { + const decorators = decorator_list(env); + const match = Curry._2(Parser_env_Peek.token, undefined, env); + if (!/* tag */(typeof match === "number" || typeof match === "string")) { + return statement_list_item(decorators, env); + } + switch (match) { + case /* T_EXPORT */47 : + const env$1 = with_in_export(true, with_strict(true, env)); + const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env$1); + token$4(env$1, /* T_EXPORT */47); + const match$1 = Curry._2(Parser_env_Peek.token, undefined, env$1); + let exit = 0; + if (/* tag */typeof match$1 === "number" || typeof match$1 === "string") { + switch (match$1) { + case /* T_DEFAULT */34 : + token$4(env$1, /* T_DEFAULT */34); + record_export(env$1, [ + btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env$1)), + "default" + ]); + const match$2 = Curry._2(Parser_env_Peek.token, undefined, env$1); + let match$3; + let exit$1 = 0; + if (/* tag */(typeof match$2 === "number" || typeof match$2 === "string") && match$2 === /* T_FUNCTION */13) { + const fn = _function(env$1); + match$3 = [ + fn[0], { - TAG: /* Return */9, - _0: { - argument: argument - } + TAG: /* Declaration */0, + _0: fn } ]; - case /* T_SWITCH */18 : - const start_loc$1 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_SWITCH */18); - token$4(env, /* T_LPAREN */3); - const discriminant = Curry._1(Parse.expression, env); - token$4(env, /* T_RPAREN */4); - token$4(env, /* T_LCURLY */1); - const cases = case_list(env, [ - false, - /* [] */0 - ]); - const end_loc$1 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_RCURLY */2); - return [ - btwn(start_loc$1, end_loc$1), - { - TAG: /* Switch */8, - _0: { - discriminant: discriminant, - cases: cases, - lexical: false + } else { + exit$1 = 3; + } + if (exit$1 === 3) { + if (Curry._2(Parser_env_Peek.is_class, undefined, env$1)) { + const _class = class_declaration(env$1, decorators); + match$3 = [ + _class[0], + { + TAG: /* Declaration */0, + _0: _class } - } - ]; - case /* T_THROW */20 : - const start_loc$2 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_THROW */20); - if (Curry._1(Parser_env_Peek.is_line_terminator, env)) { - error_at(env, [ - start_loc$2, - /* NewlineAfterThrow */11 - ]); - } - const argument$1 = Curry._1(Parse.expression, env); - const loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc$2 = loc$2 !== undefined ? loc$2 : argument$1[0]; - semicolon(env); - return [ - btwn(start_loc$2, end_loc$2), - { - TAG: /* Throw */10, - _0: { - argument: argument$1 - } - } - ]; - case /* T_TRY */21 : - const start_loc$3 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_TRY */21); - const block = Curry._1(Parse.block_body, env); - const match$2 = Curry._2(Parser_env_Peek.token, undefined, env); - let handler; - if (/* tag */(typeof match$2 === "number" || typeof match$2 === "string") && match$2 === /* T_CATCH */32) { - const start_loc$4 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_CATCH */32); - token$4(env, /* T_LPAREN */3); - const id = Curry._2(Parse.identifier, /* StrictCatchVariable */26, env); - const param_0 = id[0]; - const param_1 = { - TAG: /* Identifier */3, - _0: id - }; - const param = [ - param_0, - param_1 - ]; - token$4(env, /* T_RPAREN */4); - const body = Curry._1(Parse.block_body, env); - const loc$3 = btwn(start_loc$4, body[0]); - handler = [ - loc$3, - { - param: param, - guard: undefined, - body: body - } - ]; - } else { - handler = undefined; - } - const match$3 = Curry._2(Parser_env_Peek.token, undefined, env); - let finalizer; - if (/* tag */(typeof match$3 === "number" || typeof match$3 === "string") && match$3 === /* T_FINALLY */36) { - token$4(env, /* T_FINALLY */36); - finalizer = Curry._1(Parse.block_body, env); - } else { - finalizer = undefined; - } - const end_loc$3 = finalizer !== undefined ? finalizer[0] : ( - handler !== undefined ? handler[0] : (error_at(env, [ - block[0], - /* NoCatchOrFinally */20 - ]), block[0]) - ); - return [ - btwn(start_loc$3, end_loc$3), - { - TAG: /* Try */11, - _0: { - block: block, - handler: handler, - guardedHandlers: /* [] */0, - finalizer: finalizer - } - } - ]; - case /* T_VAR */22 : - return var_or_const(env); - case /* T_WHILE */23 : - const start_loc$5 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_WHILE */23); - token$4(env, /* T_LPAREN */3); - const test = Curry._1(Parse.expression, env); - token$4(env, /* T_RPAREN */4); - const body$1 = Curry._1(Parse.statement, with_in_loop(true, env)); - return [ - btwn(start_loc$5, body$1[0]), - { - TAG: /* While */12, - _0: { - test: test, - body: body$1 - } - } - ]; - case /* T_WITH */24 : - const start_loc$6 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_WITH */24); - token$4(env, /* T_LPAREN */3); - const _object = Curry._1(Parse.expression, env); - token$4(env, /* T_RPAREN */4); - const body$2 = Curry._1(Parse.statement, env); - const loc$4 = btwn(start_loc$6, body$2[0]); - strict_error_at(env, [ - loc$4, - /* StrictModeWith */25 - ]); - return [ - loc$4, - { - TAG: /* With */6, - _0: { - _object: _object, - body: body$2 - } - } - ]; - case /* T_BREAK */30 : - const start_loc$7 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_BREAK */30); - let label; - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_SEMICOLON */7) || Curry._1(Parser_env_Peek.is_implicit_semicolon, env)) { - label = undefined; - } else { - const label$1 = Curry._2(Parse.identifier, undefined, env); - const name = label$1[1].name; - if (!Curry._2(mem$1, name, env.labels)) { - error$1(env, { - TAG: /* UnknownLabel */4, - _0: name - }); - } - label = label$1; - } - const loc$5 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc$4 = loc$5 !== undefined ? loc$5 : ( - label !== undefined ? label[0] : start_loc$7 - ); - const loc$6 = btwn(start_loc$7, end_loc$4); - if (label === undefined && !(env.in_loop || env.in_switch)) { - error_at(env, [ - loc$6, - /* IllegalBreak */22 - ]); - } - semicolon(env); - return [ - loc$6, - { - TAG: /* Break */4, - _0: { - label: label - } - } - ]; - case /* T_CONTINUE */33 : - const start_loc$8 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_CONTINUE */33); - let label$2; - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_SEMICOLON */7) || Curry._1(Parser_env_Peek.is_implicit_semicolon, env)) { - label$2 = undefined; - } else { - const label$3 = Curry._2(Parse.identifier, undefined, env); - const name$1 = label$3[1].name; - if (!Curry._2(mem$1, name$1, env.labels)) { - error$1(env, { - TAG: /* UnknownLabel */4, - _0: name$1 - }); - } - label$2 = label$3; - } - const loc$7 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc$5 = loc$7 !== undefined ? loc$7 : ( - label$2 !== undefined ? label$2[0] : start_loc$8 - ); - const loc$8 = btwn(start_loc$8, end_loc$5); - if (!env.in_loop) { - error_at(env, [ - loc$8, - /* IllegalContinue */21 - ]); - } - semicolon(env); - return [ - loc$8, - { - TAG: /* Continue */5, - _0: { - label: label$2 - } - } - ]; - case /* T_DO */35 : - const start_loc$9 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_DO */35); - const body$3 = Curry._1(Parse.statement, with_in_loop(true, env)); - token$4(env, /* T_WHILE */23); - token$4(env, /* T_LPAREN */3); - const test$1 = Curry._1(Parse.expression, env); - const end_loc$6 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_RPAREN */4); - const loc$9 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc$7 = loc$9 !== undefined ? loc$9 : end_loc$6; - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_SEMICOLON */7)) { - semicolon(env); - } - return [ - btwn(start_loc$9, end_loc$7), - { - TAG: /* DoWhile */13, - _0: { - body: body$3, - test: test$1 - } - } - ]; - case /* T_FOR */37 : - const start_loc$10 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_FOR */37); - token$4(env, /* T_LPAREN */3); - const match$4 = Curry._2(Parser_env_Peek.token, undefined, env); - let match$5; - let exit$1 = 0; - if (/* tag */typeof match$4 === "number" || typeof match$4 === "string") { - switch (match$4) { - case /* T_SEMICOLON */7 : - match$5 = [ - undefined, - /* [] */0 ]; - break; - case /* T_VAR */22 : - const match$6 = declarations(/* T_VAR */22, /* Var */0, with_no_in(true, env)); - match$5 = [ - { - TAG: /* InitDeclaration */0, - _0: match$6[0] - }, - match$6[1] - ]; - break; - case /* T_CONST */25 : - const match$7 = $$const(with_no_in(true, env)); - match$5 = [ + } else { + const expr = Curry._1(Parse.assignment, env$1); + const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); + const end_loc = loc !== undefined ? loc : expr[0]; + semicolon(env$1); + match$3 = [ + end_loc, { - TAG: /* InitDeclaration */0, - _0: match$7[0] - }, - match$7[1] + TAG: /* Expression */1, + _0: expr + } ]; - break; - case /* T_LET */26 : - const match$8 = _let(with_no_in(true, env)); - match$5 = [ + } + } + return [ + btwn(start_loc, match$3[0]), + { + TAG: /* ExportDeclaration */28, + _0: { + default: true, + declaration: match$3[1], + specifiers: undefined, + source: undefined, + exportKind: /* ExportValue */1 + } + } + ]; + case /* T_INTERFACE */51 : + if (!env$1.parse_options.types) { + error$1(env$1, /* UnexpectedTypeExport */9); + } + const $$interface$1 = $$interface(env$1); + const match$4 = $$interface$1[1]; + if (/* tag */typeof match$4 === "number" || typeof match$4 === "string") { + throw new Caml_js_exceptions.MelangeError("Failure", { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!" + }); + } + if (match$4.TAG === /* InterfaceDeclaration */21) { + record_export(env$1, [ + $$interface$1[0], + extract_ident_name(match$4._0.id) + ]); + } else { + throw new Caml_js_exceptions.MelangeError("Failure", { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!" + }); + } + const end_loc$1 = $$interface$1[0]; + return [ + btwn(start_loc, end_loc$1), + { + TAG: /* ExportDeclaration */28, + _0: { + default: false, + declaration: { + TAG: /* Declaration */0, + _0: $$interface$1 + }, + specifiers: undefined, + source: undefined, + exportKind: /* ExportType */0 + } + } + ]; + case /* T_TYPE */59 : + if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, 1, env$1), /* T_LCURLY */1)) { + if (!env$1.parse_options.types) { + error$1(env$1, /* UnexpectedTypeExport */9); + } + const type_alias$1 = type_alias(env$1); + const match$5 = type_alias$1[1]; + if (/* tag */typeof match$5 === "number" || typeof match$5 === "string") { + throw new Caml_js_exceptions.MelangeError("Failure", { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!" + }); + } + if (match$5.TAG === /* TypeAlias */7) { + record_export(env$1, [ + type_alias$1[0], + extract_ident_name(match$5._0.id) + ]); + } else { + throw new Caml_js_exceptions.MelangeError("Failure", { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!" + }); + } + const end_loc$2 = type_alias$1[0]; + return [ + btwn(start_loc, end_loc$2), + { + TAG: /* ExportDeclaration */28, + _0: { + default: false, + declaration: { + TAG: /* Declaration */0, + _0: type_alias$1 + }, + specifiers: undefined, + source: undefined, + exportKind: /* ExportType */0 + } + } + ]; + } + exit = 1; + break; + case /* T_AT */12 : + case /* T_FUNCTION */13 : + case /* T_VAR */22 : + case /* T_CONST */25 : + case /* T_LET */26 : + case /* T_CLASS */38 : + case /* T_ASYNC */61 : + exit = 2; + break; + case /* T_MULT */97 : + const loc$1 = Curry._2(Parser_env_Peek.loc, undefined, env$1); + token$4(env$1, /* T_MULT */97); + const parse_export_star_as = env$1.parse_options.esproposal_export_star_as; + const 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; + const specifiers = { + TAG: /* ExportBatchSpecifier */1, + _0: loc$1, + _1: local_name + }; + const source$1 = export_source(env$1); + const loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); + const end_loc$3 = loc$2 !== undefined ? loc$2 : source$1[0]; + const source$2 = source$1; + semicolon(env$1); + return [ + btwn(start_loc, end_loc$3), + { + TAG: /* ExportDeclaration */28, + _0: { + default: false, + declaration: undefined, + specifiers: specifiers, + source: source$2, + exportKind: /* ExportValue */1 + } + } + ]; + default: + exit = 1; + } + } else { + exit = 1; + } + switch (exit) { + case 1 : + const match$6 = Curry._2(Parser_env_Peek.token, undefined, env$1); + let exportKind; + if (/* tag */(typeof match$6 === "number" || typeof match$6 === "string") && match$6 === /* T_TYPE */59) { + token$3(env$1); + exportKind = /* ExportType */0; + } else { + exportKind = /* ExportValue */1; + } + token$4(env$1, /* T_LCURLY */1); + const match$7 = export_specifiers_and_errs(env$1, /* [] */0, /* [] */0); + const specifiers$1 = { + TAG: /* ExportSpecifiers */0, + _0: match$7[0] + }; + const end_loc$4 = Curry._2(Parser_env_Peek.loc, undefined, env$1); + token$4(env$1, /* T_RCURLY */2); + const source$3 = 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$7[1]), undefined); + const loc$3 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); + const end_loc$5 = loc$3 !== undefined ? loc$3 : ( + source$3 !== undefined ? source$3[0] : end_loc$4 + ); + semicolon(env$1); + return [ + btwn(start_loc, end_loc$5), { - TAG: /* InitDeclaration */0, - _0: match$8[0] - }, - match$8[1] + TAG: /* ExportDeclaration */28, + _0: { + default: false, + declaration: undefined, + specifiers: specifiers$1, + source: source$3, + exportKind: exportKind + } + } ]; - break; - default: - exit$1 = 1; + case 2 : + const stmt = Curry._2(Parse.statement_list_item, decorators, env$1); + const match$8 = stmt[1]; + const loc$4 = stmt[0]; + let names; + if (/* tag */typeof match$8 === "number" || typeof match$8 === "string") { + throw new Caml_js_exceptions.MelangeError("Failure", { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Unexpected export statement declaration!" + }); } - } else { - exit$1 = 1; - } - if (exit$1 === 1) { - const expr = Curry._1(Parse.expression, with_no_let(true, with_no_in(true, env))); - match$5 = [ - { - TAG: /* InitExpression */1, - _0: expr - }, - /* [] */0 - ]; - } - const init = match$5[0]; - const match$9 = Curry._2(Parser_env_Peek.token, undefined, env); - if (/* tag */typeof match$9 === "number" || typeof match$9 === "string") { - switch (match$9) { - case /* T_IN */15 : - assert_can_be_forin_or_forof(env, /* InvalidLHSInForIn */16)(init); - let left; - if (init !== undefined) { - left = init.TAG === /* InitDeclaration */0 ? ({ - TAG: /* LeftDeclaration */0, - _0: init._0 - }) : ({ - TAG: /* LeftExpression */1, - _0: init._0 - }); + switch (match$8.TAG) { + case /* FunctionDeclaration */18 : + const id = match$8._0.id; + if (id !== undefined) { + names = { + hd: [ + loc$4, + extract_ident_name(id) + ], + tl: /* [] */0 + }; } else { - throw new Caml_js_exceptions.MelangeError("Assert_failure", { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 2556, - 22 - ] - }); + error_at(env$1, [ + loc$4, + /* ExportNamelessFunction */56 + ]); + names = /* [] */0; } - token$4(env, /* T_IN */15); - const right = Curry._1(Parse.expression, env); - token$4(env, /* T_RPAREN */4); - const body$4 = Curry._1(Parse.statement, with_in_loop(true, env)); - return [ - btwn(start_loc$10, body$4[0]), - { - TAG: /* ForIn */15, - _0: { - left: left, - right: right, - body: body$4, - each: false - } - } - ]; - case /* T_OF */60 : - assert_can_be_forin_or_forof(env, /* InvalidLHSInForOf */17)(init); - let left$1; - if (init !== undefined) { - left$1 = init.TAG === /* InitDeclaration */0 ? ({ - TAG: /* LeftDeclaration */0, - _0: init._0 - }) : ({ - TAG: /* LeftExpression */1, - _0: init._0 - }); + break; + case /* VariableDeclaration */19 : + names = Stdlib__List.fold_left((function (names, param) { + const id = param[1].id; + let param$1 = { + hd: id, + tl: /* [] */0 + }; + return Stdlib__List.fold_left(fold, names, param$1); + }), /* [] */0, match$8._0.declarations); + break; + case /* ClassDeclaration */20 : + const id$1 = match$8._0.id; + if (id$1 !== undefined) { + names = { + hd: [ + loc$4, + extract_ident_name(id$1) + ], + tl: /* [] */0 + }; } else { - throw new Caml_js_exceptions.MelangeError("Assert_failure", { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 2573, - 22 - ] - }); + error_at(env$1, [ + loc$4, + /* ExportNamelessClass */55 + ]); + names = /* [] */0; } - token$4(env, /* T_OF */60); - const right$1 = Curry._1(Parse.assignment, env); - token$4(env, /* T_RPAREN */4); - const body$5 = Curry._1(Parse.statement, with_in_loop(true, env)); - return [ - btwn(start_loc$10, body$5[0]), - { - TAG: /* ForOf */16, - _0: { - left: left$1, - right: right$1, - body: body$5 - } - } - ]; + break; default: - + throw new Caml_js_exceptions.MelangeError("Failure", { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Unexpected export statement declaration!" + }); } + Stdlib__List.iter((function (param) { + return record_export(env$1, param); + }), names); + const declaration = { + TAG: /* Declaration */0, + _0: stmt + }; + return [ + btwn(start_loc, stmt[0]), + { + TAG: /* ExportDeclaration */28, + _0: { + default: false, + declaration: declaration, + specifiers: undefined, + source: undefined, + exportKind: /* ExportValue */1 + } + } + ]; + + } + case /* T_IMPORT */48 : + error_on_decorators(env)(decorators); + const env$2 = with_strict(true, env); + const start_loc$1 = Curry._2(Parser_env_Peek.loc, undefined, env$2); + token$4(env$2, /* T_IMPORT */48); + const match$9 = Curry._2(Parser_env_Peek.token, undefined, env$2); + let match$10; + if (/* tag */typeof match$9 === "number" || typeof match$9 === "string") { + switch (match$9) { + case /* T_TYPEOF */44 : + if (!env$2.parse_options.types) { + error$1(env$2, /* UnexpectedTypeImport */8); + } + token$4(env$2, /* T_TYPEOF */44); + match$10 = [ + /* ImportTypeof */1, + undefined + ]; + break; + case /* T_TYPE */59 : + if (!env$2.parse_options.types) { + error$1(env$2, /* UnexpectedTypeImport */8); + } + match$10 = [ + /* ImportType */0, + Curry._2(Parse.identifier, undefined, env$2) + ]; + break; + default: + match$10 = [ + /* ImportValue */2, + undefined + ]; + } + } else { + match$10 = [ + /* ImportValue */2, + undefined + ]; + } + const type_ident = match$10[1]; + const importKind = match$10[0]; + const match$11 = Curry._2(Parser_env_Peek.token, undefined, env$2); + const match$12 = Curry._2(Parser_env_Peek.is_identifier, undefined, env$2); + let exit$2 = 0; + let exit$3 = 0; + if (/* tag */typeof match$11 === "number" || typeof match$11 === "string") { + if (match$11 === /* T_COMMA */8) { + exit$2 = 1; + } else { + exit$3 = 2; + } + } else if (match$11.TAG === /* T_STRING */1) { + if (importKind === /* ImportValue */2) { + const match$13 = match$11._0; + const octal = match$13[3]; + const raw = match$13[2]; + const value = match$13[1]; + const str_loc = match$13[0]; + if (octal) { + strict_error(env$2, /* StrictOctalLiteral */31); } - Stdlib__List.iter((function (param) { - return error_at(env, param); - }), match$5[1]); - token$4(env, /* T_SEMICOLON */7); - const match$10 = Curry._2(Parser_env_Peek.token, undefined, env); - let test$2; - test$2 = /* tag */(typeof match$10 === "number" || typeof match$10 === "string") && match$10 === /* T_SEMICOLON */7 ? undefined : Curry._1(Parse.expression, env); - token$4(env, /* T_SEMICOLON */7); - const match$11 = Curry._2(Parser_env_Peek.token, undefined, env); - let update; - update = /* tag */(typeof match$11 === "number" || typeof match$11 === "string") && match$11 === /* T_RPAREN */4 ? undefined : Curry._1(Parse.expression, env); - token$4(env, /* T_RPAREN */4); - const body$6 = Curry._1(Parse.statement, with_in_loop(true, env)); + token$4(env$2, { + TAG: /* T_STRING */1, + _0: [ + str_loc, + value, + raw, + octal + ] + }); + const value$1 = { + TAG: /* String */0, + _0: value + }; + const source_1 = { + value: value$1, + raw: raw + }; + const source$4 = [ + str_loc, + source_1 + ]; + const loc$5 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$2); + const end_loc$6 = loc$5 !== undefined ? loc$5 : str_loc; + semicolon(env$2); return [ - btwn(start_loc$10, body$6[0]), + btwn(start_loc$1, end_loc$6), { - TAG: /* For */14, + TAG: /* ImportDeclaration */29, _0: { - init: init, - test: test$2, - update: update, - body: body$6 + importKind: importKind, + source: source$4, + specifiers: /* [] */0 } } ]; - case /* T_DEBUGGER */57 : - const start_loc$11 = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, /* T_DEBUGGER */57); - const loc$10 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc$8 = loc$10 !== undefined ? loc$10 : start_loc$11; - semicolon(env); - return [ - btwn(start_loc$11, end_loc$8), - /* Debugger */1 - ]; - case /* T_EOF */105 : - error_unexpected(env); + } + exit$3 = 2; + } else { + exit$3 = 2; + } + if (exit$3 === 2) { + if (match$12) { + exit$2 = 1; + } else { + const specifiers$2 = named_or_namespace_specifier(env$2); + const source$5 = source(env$2); + const loc$6 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$2); + const end_loc$7 = loc$6 !== undefined ? loc$6 : source$5[0]; + semicolon(env$2); return [ - Curry._2(Parser_env_Peek.loc, undefined, env), - /* Empty */0 + btwn(start_loc$1, end_loc$7), + { + TAG: /* ImportDeclaration */29, + _0: { + importKind: importKind, + source: source$5, + specifiers: specifiers$2 + } + } ]; - default: - exit = 2; - } - } else { - exit = 2; - } - if (exit === 2) { - if (Curry._2(Parser_env_Peek.is_identifier, undefined, env)) { - const expr$1 = Curry._1(Parse.expression, env); - const match$12 = Curry._2(Parser_env_Peek.token, undefined, env); - const label$4 = expr$1[1]; - if (!/* tag */(typeof label$4 === "number" || typeof label$4 === "string") && label$4.TAG === /* Identifier */18 && /* tag */(typeof match$12 === "number" || typeof match$12 === "string") && match$12 === /* T_COLON */77) { - const label$5 = label$4._0; - const loc$11 = expr$1[0]; - const match$13 = label$5[1]; - const name$2 = match$13.name; - token$4(env, /* T_COLON */77); - if (Curry._2(mem$1, name$2, env.labels)) { - error_at(env, [ - loc$11, - { - TAG: /* Redeclaration */5, - _0: "Label", - _1: name$2 + } + } + if (exit$2 === 1) { + const match$14 = Curry._2(Parser_env_Peek.token, undefined, env$2); + const match$15 = Curry._2(Parser_env_Peek.value, undefined, env$2); + let match$16; + let exit$4 = 0; + if (type_ident !== undefined && /* tag */(typeof match$14 === "number" || typeof match$14 === "string")) { + switch (match$14) { + case /* T_IDENTIFIER */0 : + if (match$15 === "from") { + match$16 = [ + /* ImportValue */2, + { + TAG: /* ImportDefaultSpecifier */1, + _0: type_ident + } + ]; + } else { + exit$4 = 2; } - ]); + break; + case /* T_COMMA */8 : + match$16 = [ + /* ImportValue */2, + { + TAG: /* ImportDefaultSpecifier */1, + _0: type_ident + } + ]; + break; + default: + exit$4 = 2; + } + } else { + exit$4 = 2; } - const env$1 = add_label(env, name$2); - const labeled_stmt = Curry._1(Parse.statement, env$1); + if (exit$4 === 2) { + match$16 = [ + importKind, + { + TAG: /* ImportDefaultSpecifier */1, + _0: Curry._2(Parse.identifier, undefined, env$2) + } + ]; + } + const match$17 = Curry._2(Parser_env_Peek.token, undefined, env$2); + let additional_specifiers; + if (/* tag */(typeof match$17 === "number" || typeof match$17 === "string") && match$17 === /* T_COMMA */8) { + token$4(env$2, /* T_COMMA */8); + additional_specifiers = named_or_namespace_specifier(env$2); + } else { + additional_specifiers = /* [] */0; + } + const source$6 = source(env$2); + const loc$7 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$2); + const end_loc$8 = loc$7 !== undefined ? loc$7 : source$6[0]; + semicolon(env$2); return [ - btwn(loc$11, labeled_stmt[0]), + btwn(start_loc$1, end_loc$8), { - TAG: /* Labeled */3, + TAG: /* ImportDeclaration */29, _0: { - label: label$5, - body: labeled_stmt + importKind: match$16[0], + source: source$6, + specifiers: { + hd: match$16[1], + tl: additional_specifiers + } } } ]; } - const loc$12 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc$9 = loc$12 !== undefined ? loc$12 : expr$1[0]; - semicolon(env); - return [ - btwn(expr$1[0], end_loc$9), - { - TAG: /* Expression */1, - _0: { - expression: expr$1 - } - } - ]; - } - if (!/* tag */(typeof match === "number" || typeof match === "string")) { - return expression(env); - } - switch (match) { - case /* T_ELSE */41 : - return _if(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 : - case /* T_COLON */77 : - break; - default: - return expression(env); - } - } - error_unexpected(env); - token$3(env); - continue ; - }; + case /* T_DECLARE */58 : + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, 1, env), /* T_EXPORT */47)) { + error_on_decorators(env)(decorators); + return declare_export_declaration(undefined, env); + } else { + return statement_list_item(decorators, env); + } + default: + return statement_list_item(decorators, env); + } } -function module_item(env) { - const decorators = decorator_list(env); +function statement_list_item(decoratorsOpt, env) { + const decorators = decoratorsOpt !== undefined ? decoratorsOpt : /* [] */0; + if (!Curry._2(Parser_env_Peek.is_class, undefined, env)) { + error_on_decorators(env)(decorators); + } const match = Curry._2(Parser_env_Peek.token, undefined, env); + if (/* tag */typeof match === "number" || typeof match === "string") { + switch (match) { + case /* T_CONST */25 : + return var_or_const(env); + case /* T_LET */26 : + const 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); + const match$1 = helper(with_no_let(true, env), /* [] */0, /* [] */0); + const head = Stdlib__List.map((function (param) { + const match = param[1]; + return { + id: match.id, + init: match.init + }; + }), match$1[1]); + token$4(env, /* T_RPAREN */4); + const body = Curry._1(Parse.statement, env); + const end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const 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 + } + } + ]; + } + const match$2 = helper(with_no_let(true, env), /* [] */0, /* [] */0); + const declaration = { + TAG: /* VariableDeclaration */19, + _0: { + declarations: match$2[1], + kind: /* Let */1 + } + }; + const end_loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const 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 + ]; + default: + + } + } + 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 (!/* tag */(typeof match === "number" || typeof match === "string")) { - return statement_list_item(decorators, env); + return statement(env); } switch (match) { - case /* T_EXPORT */47 : - const env$1 = with_in_export(true, with_strict(true, env)); - const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env$1); - token$4(env$1, /* T_EXPORT */47); - const match$1 = Curry._2(Parser_env_Peek.token, undefined, env$1); - let exit = 0; - if (/* tag */typeof match$1 === "number" || typeof match$1 === "string") { - switch (match$1) { - case /* T_DEFAULT */34 : - token$4(env$1, /* T_DEFAULT */34); - record_export(env$1, [ - btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env$1)), - "default" - ]); - const match$2 = Curry._2(Parser_env_Peek.token, undefined, env$1); - let match$3; - let exit$1 = 0; - if (/* tag */(typeof match$2 === "number" || typeof match$2 === "string") && match$2 === /* T_FUNCTION */13) { - const fn = _function(env$1); - match$3 = [ - fn[0], + case /* T_INTERFACE */51 : + return $$interface(env); + case /* T_DECLARE */58 : + return declare(undefined, env); + case /* T_TYPE */59 : + return type_alias(env); + default: + return statement(env); + } +} + +function statement(env) { + while(true) { + const match = Curry._2(Parser_env_Peek.token, undefined, env); + let exit = 0; + if (/* tag */typeof match === "number" || typeof match === "string") { + switch (match) { + case /* T_LCURLY */1 : + const match$1 = Curry._1(Parse.block_body, env); + return [ + match$1[0], + { + TAG: /* Block */0, + _0: match$1[1] + } + ]; + case /* T_SEMICOLON */7 : + const loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_SEMICOLON */7); + return [ + loc, + /* Empty */0 + ]; + case /* T_IF */14 : + return _if(env); + case /* T_RETURN */17 : + if (!env.in_function) { + error$1(env, /* IllegalReturn */23); + } + const start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_RETURN */17); + const argument = Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_SEMICOLON */7) || Curry._1(Parser_env_Peek.is_implicit_semicolon, env) ? undefined : Curry._1(Parse.expression, env); + const loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc = loc$1 !== undefined ? loc$1 : ( + argument !== undefined ? argument[0] : start_loc + ); + semicolon(env); + return [ + btwn(start_loc, end_loc), + { + TAG: /* Return */9, + _0: { + argument: argument + } + } + ]; + case /* T_SWITCH */18 : + const start_loc$1 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_SWITCH */18); + token$4(env, /* T_LPAREN */3); + const discriminant = Curry._1(Parse.expression, env); + token$4(env, /* T_RPAREN */4); + token$4(env, /* T_LCURLY */1); + const cases = case_list(env, [ + false, + /* [] */0 + ]); + const end_loc$1 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_RCURLY */2); + return [ + btwn(start_loc$1, end_loc$1), + { + TAG: /* Switch */8, + _0: { + discriminant: discriminant, + cases: cases, + lexical: false + } + } + ]; + case /* T_THROW */20 : + const start_loc$2 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_THROW */20); + if (Curry._1(Parser_env_Peek.is_line_terminator, env)) { + error_at(env, [ + start_loc$2, + /* NewlineAfterThrow */11 + ]); + } + const argument$1 = Curry._1(Parse.expression, env); + const loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc$2 = loc$2 !== undefined ? loc$2 : argument$1[0]; + semicolon(env); + return [ + btwn(start_loc$2, end_loc$2), { - TAG: /* Declaration */0, - _0: fn + TAG: /* Throw */10, + _0: { + argument: argument$1 + } } ]; - } else { - exit$1 = 3; - } - if (exit$1 === 3) { - if (Curry._2(Parser_env_Peek.is_class, undefined, env$1)) { - const _class = class_declaration(env$1, decorators); - match$3 = [ - _class[0], - { - TAG: /* Declaration */0, - _0: _class - } - ]; - } else { - const expr = Curry._1(Parse.assignment, env$1); - const loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); - const end_loc = loc !== undefined ? loc : expr[0]; - semicolon(env$1); - match$3 = [ - end_loc, - { - TAG: /* Expression */1, - _0: expr - } - ]; - } - } - return [ - btwn(start_loc, match$3[0]), - { - TAG: /* ExportDeclaration */28, - _0: { - default: true, - declaration: match$3[1], - specifiers: undefined, - source: undefined, - exportKind: /* ExportValue */1 - } - } - ]; - case /* T_INTERFACE */51 : - if (!env$1.parse_options.types) { - error$1(env$1, /* UnexpectedTypeExport */9); - } - const $$interface$1 = $$interface(env$1); - const match$4 = $$interface$1[1]; - if (/* tag */typeof match$4 === "number" || typeof match$4 === "string") { - throw new Caml_js_exceptions.MelangeError("Failure", { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!" - }); - } - if (match$4.TAG === /* InterfaceDeclaration */21) { - record_export(env$1, [ - $$interface$1[0], - extract_ident_name(match$4._0.id) - ]); - } else { - throw new Caml_js_exceptions.MelangeError("Failure", { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!" - }); - } - const end_loc$1 = $$interface$1[0]; - return [ - btwn(start_loc, end_loc$1), - { - TAG: /* ExportDeclaration */28, - _0: { - default: false, - declaration: { - TAG: /* Declaration */0, - _0: $$interface$1 - }, - specifiers: undefined, - source: undefined, - exportKind: /* ExportType */0 - } - } - ]; - case /* T_TYPE */59 : - if (Caml_obj.caml_notequal(Curry._2(Parser_env_Peek.token, 1, env$1), /* T_LCURLY */1)) { - if (!env$1.parse_options.types) { - error$1(env$1, /* UnexpectedTypeExport */9); - } - const type_alias$1 = type_alias(env$1); - const match$5 = type_alias$1[1]; - if (/* tag */typeof match$5 === "number" || typeof match$5 === "string") { - throw new Caml_js_exceptions.MelangeError("Failure", { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!" - }); - } - if (match$5.TAG === /* TypeAlias */7) { - record_export(env$1, [ - type_alias$1[0], - extract_ident_name(match$5._0.id) - ]); - } else { - throw new Caml_js_exceptions.MelangeError("Failure", { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!" - }); - } - const end_loc$2 = type_alias$1[0]; - return [ - btwn(start_loc, end_loc$2), - { - TAG: /* ExportDeclaration */28, - _0: { - default: false, - declaration: { - TAG: /* Declaration */0, - _0: type_alias$1 - }, - specifiers: undefined, - source: undefined, - exportKind: /* ExportType */0 - } - } - ]; - } - exit = 1; - break; - case /* T_AT */12 : - case /* T_FUNCTION */13 : - case /* T_VAR */22 : - case /* T_CONST */25 : - case /* T_LET */26 : - case /* T_CLASS */38 : - case /* T_ASYNC */61 : - exit = 2; - break; - case /* T_MULT */97 : - const loc$1 = Curry._2(Parser_env_Peek.loc, undefined, env$1); - token$4(env$1, /* T_MULT */97); - const parse_export_star_as = env$1.parse_options.esproposal_export_star_as; - const 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; - const specifiers = { - TAG: /* ExportBatchSpecifier */1, - _0: loc$1, - _1: local_name - }; - const source$1 = export_source(env$1); - const loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); - const end_loc$3 = loc$2 !== undefined ? loc$2 : source$1[0]; - const source$2 = source$1; - semicolon(env$1); - return [ - btwn(start_loc, end_loc$3), - { - TAG: /* ExportDeclaration */28, - _0: { - default: false, - declaration: undefined, - specifiers: specifiers, - source: source$2, - exportKind: /* ExportValue */1 - } - } - ]; - default: - exit = 1; - } - } else { - exit = 1; - } - switch (exit) { - case 1 : - const match$6 = Curry._2(Parser_env_Peek.token, undefined, env$1); - let exportKind; - if (/* tag */(typeof match$6 === "number" || typeof match$6 === "string") && match$6 === /* T_TYPE */59) { - token$3(env$1); - exportKind = /* ExportType */0; - } else { - exportKind = /* ExportValue */1; - } - token$4(env$1, /* T_LCURLY */1); - const match$7 = export_specifiers_and_errs(env$1, /* [] */0, /* [] */0); - const specifiers$1 = { - TAG: /* ExportSpecifiers */0, - _0: match$7[0] + case /* T_TRY */21 : + const start_loc$3 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_TRY */21); + const block = Curry._1(Parse.block_body, env); + const match$2 = Curry._2(Parser_env_Peek.token, undefined, env); + let handler; + if (/* tag */(typeof match$2 === "number" || typeof match$2 === "string") && match$2 === /* T_CATCH */32) { + const start_loc$4 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_CATCH */32); + token$4(env, /* T_LPAREN */3); + const id = Curry._2(Parse.identifier, /* StrictCatchVariable */26, env); + const param_0 = id[0]; + const param_1 = { + TAG: /* Identifier */3, + _0: id }; - const end_loc$4 = Curry._2(Parser_env_Peek.loc, undefined, env$1); - token$4(env$1, /* T_RCURLY */2); - const source$3 = 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$7[1]), undefined); - const loc$3 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$1); - const end_loc$5 = loc$3 !== undefined ? loc$3 : ( - source$3 !== undefined ? source$3[0] : end_loc$4 - ); - semicolon(env$1); - return [ - btwn(start_loc, end_loc$5), - { - TAG: /* ExportDeclaration */28, - _0: { - default: false, - declaration: undefined, - specifiers: specifiers$1, - source: source$3, - exportKind: exportKind - } + const param = [ + param_0, + param_1 + ]; + token$4(env, /* T_RPAREN */4); + const body = Curry._1(Parse.block_body, env); + const loc$3 = btwn(start_loc$4, body[0]); + handler = [ + loc$3, + { + param: param, + guard: undefined, + body: body + } + ]; + } else { + handler = undefined; + } + const match$3 = Curry._2(Parser_env_Peek.token, undefined, env); + let finalizer; + if (/* tag */(typeof match$3 === "number" || typeof match$3 === "string") && match$3 === /* T_FINALLY */36) { + token$4(env, /* T_FINALLY */36); + finalizer = Curry._1(Parse.block_body, env); + } else { + finalizer = undefined; + } + const end_loc$3 = finalizer !== undefined ? finalizer[0] : ( + handler !== undefined ? handler[0] : (error_at(env, [ + block[0], + /* NoCatchOrFinally */20 + ]), block[0]) + ); + return [ + btwn(start_loc$3, end_loc$3), + { + TAG: /* Try */11, + _0: { + block: block, + handler: handler, + guardedHandlers: /* [] */0, + finalizer: finalizer } - ]; - case 2 : - const stmt = Curry._2(Parse.statement_list_item, decorators, env$1); - const match$8 = stmt[1]; - const loc$4 = stmt[0]; - let names; - if (/* tag */typeof match$8 === "number" || typeof match$8 === "string") { - throw new Caml_js_exceptions.MelangeError("Failure", { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Unexpected export statement declaration!" - }); - } - switch (match$8.TAG) { - case /* FunctionDeclaration */18 : - const id = match$8._0.id; - if (id !== undefined) { - names = { - hd: [ - loc$4, - extract_ident_name(id) - ], - tl: /* [] */0 - }; - } else { - error_at(env$1, [ - loc$4, - /* ExportNamelessFunction */56 - ]); - names = /* [] */0; } - break; - case /* VariableDeclaration */19 : - names = Stdlib__List.fold_left((function (names, param) { - const id = param[1].id; - let param$1 = { - hd: id, - tl: /* [] */0 - }; - return Stdlib__List.fold_left(fold, names, param$1); - }), /* [] */0, match$8._0.declarations); - break; - case /* ClassDeclaration */20 : - const id$1 = match$8._0.id; - if (id$1 !== undefined) { - names = { - hd: [ - loc$4, - extract_ident_name(id$1) - ], - tl: /* [] */0 - }; - } else { - error_at(env$1, [ - loc$4, - /* ExportNamelessClass */55 - ]); - names = /* [] */0; + ]; + case /* T_VAR */22 : + return var_or_const(env); + case /* T_WHILE */23 : + const start_loc$5 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_WHILE */23); + token$4(env, /* T_LPAREN */3); + const test = Curry._1(Parse.expression, env); + token$4(env, /* T_RPAREN */4); + const body$1 = Curry._1(Parse.statement, with_in_loop(true, env)); + return [ + btwn(start_loc$5, body$1[0]), + { + TAG: /* While */12, + _0: { + test: test, + body: body$1 + } } - break; - default: - throw new Caml_js_exceptions.MelangeError("Failure", { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Unexpected export statement declaration!" - }); + ]; + case /* T_WITH */24 : + const start_loc$6 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_WITH */24); + token$4(env, /* T_LPAREN */3); + const _object = Curry._1(Parse.expression, env); + token$4(env, /* T_RPAREN */4); + const body$2 = Curry._1(Parse.statement, env); + const loc$4 = btwn(start_loc$6, body$2[0]); + strict_error_at(env, [ + loc$4, + /* StrictModeWith */25 + ]); + return [ + loc$4, + { + TAG: /* With */6, + _0: { + _object: _object, + body: body$2 + } + } + ]; + case /* T_BREAK */30 : + const start_loc$7 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_BREAK */30); + let label; + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_SEMICOLON */7) || Curry._1(Parser_env_Peek.is_implicit_semicolon, env)) { + label = undefined; + } else { + const label$1 = Curry._2(Parse.identifier, undefined, env); + const name = label$1[1].name; + if (!Curry._2(mem$1, name, env.labels)) { + error$1(env, { + TAG: /* UnknownLabel */4, + _0: name + }); } - Stdlib__List.iter((function (param) { - return record_export(env$1, param); - }), names); - const declaration = { - TAG: /* Declaration */0, - _0: stmt - }; - return [ - btwn(start_loc, stmt[0]), - { - TAG: /* ExportDeclaration */28, - _0: { - default: false, - declaration: declaration, - specifiers: undefined, - source: undefined, - exportKind: /* ExportValue */1 - } + label = label$1; + } + const loc$5 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc$4 = loc$5 !== undefined ? loc$5 : ( + label !== undefined ? label[0] : start_loc$7 + ); + const loc$6 = btwn(start_loc$7, end_loc$4); + if (label === undefined && !(env.in_loop || env.in_switch)) { + error_at(env, [ + loc$6, + /* IllegalBreak */22 + ]); + } + semicolon(env); + return [ + loc$6, + { + TAG: /* Break */4, + _0: { + label: label } - ]; - - } - case /* T_IMPORT */48 : - error_on_decorators(env)(decorators); - const env$2 = with_strict(true, env); - const start_loc$1 = Curry._2(Parser_env_Peek.loc, undefined, env$2); - token$4(env$2, /* T_IMPORT */48); - const match$9 = Curry._2(Parser_env_Peek.token, undefined, env$2); - let match$10; - if (/* tag */typeof match$9 === "number" || typeof match$9 === "string") { - switch (match$9) { - case /* T_TYPEOF */44 : - if (!env$2.parse_options.types) { - error$1(env$2, /* UnexpectedTypeImport */8); - } - token$4(env$2, /* T_TYPEOF */44); - match$10 = [ - /* ImportTypeof */1, - undefined - ]; - break; - case /* T_TYPE */59 : - if (!env$2.parse_options.types) { - error$1(env$2, /* UnexpectedTypeImport */8); - } - match$10 = [ - /* ImportType */0, - Curry._2(Parse.identifier, undefined, env$2) - ]; - break; - default: - match$10 = [ - /* ImportValue */2, - undefined - ]; - } - } else { - match$10 = [ - /* ImportValue */2, - undefined - ]; - } - const type_ident = match$10[1]; - const importKind = match$10[0]; - const match$11 = Curry._2(Parser_env_Peek.token, undefined, env$2); - const match$12 = Curry._2(Parser_env_Peek.is_identifier, undefined, env$2); - let exit$2 = 0; - let exit$3 = 0; - if (/* tag */typeof match$11 === "number" || typeof match$11 === "string") { - if (match$11 === /* T_COMMA */8) { - exit$2 = 1; - } else { - exit$3 = 2; - } - } else if (match$11.TAG === /* T_STRING */1) { - if (importKind === /* ImportValue */2) { - const match$13 = match$11._0; - const octal = match$13[3]; - const raw = match$13[2]; - const value = match$13[1]; - const str_loc = match$13[0]; - if (octal) { - strict_error(env$2, /* StrictOctalLiteral */31); + } + ]; + case /* T_CONTINUE */33 : + const start_loc$8 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_CONTINUE */33); + let label$2; + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_SEMICOLON */7) || Curry._1(Parser_env_Peek.is_implicit_semicolon, env)) { + label$2 = undefined; + } else { + const label$3 = Curry._2(Parse.identifier, undefined, env); + const name$1 = label$3[1].name; + if (!Curry._2(mem$1, name$1, env.labels)) { + error$1(env, { + TAG: /* UnknownLabel */4, + _0: name$1 + }); + } + label$2 = label$3; + } + const loc$7 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc$5 = loc$7 !== undefined ? loc$7 : ( + label$2 !== undefined ? label$2[0] : start_loc$8 + ); + const loc$8 = btwn(start_loc$8, end_loc$5); + if (!env.in_loop) { + error_at(env, [ + loc$8, + /* IllegalContinue */21 + ]); } - token$4(env$2, { - TAG: /* T_STRING */1, - _0: [ - str_loc, - value, - raw, - octal - ] - }); - const value$1 = { - TAG: /* String */0, - _0: value - }; - const source_1 = { - value: value$1, - raw: raw - }; - const source$4 = [ - str_loc, - source_1 - ]; - const loc$5 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$2); - const end_loc$6 = loc$5 !== undefined ? loc$5 : str_loc; - semicolon(env$2); + semicolon(env); return [ - btwn(start_loc$1, end_loc$6), + loc$8, { - TAG: /* ImportDeclaration */29, + TAG: /* Continue */5, _0: { - importKind: importKind, - source: source$4, - specifiers: /* [] */0 + label: label$2 } } ]; - } - exit$3 = 2; - } else { - exit$3 = 2; - } - if (exit$3 === 2) { - if (match$12) { - exit$2 = 1; - } else { - const specifiers$2 = named_or_namespace_specifier(env$2); - const source$5 = source(env$2); - const loc$6 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$2); - const end_loc$7 = loc$6 !== undefined ? loc$6 : source$5[0]; - semicolon(env$2); + case /* T_DO */35 : + const start_loc$9 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_DO */35); + const body$3 = Curry._1(Parse.statement, with_in_loop(true, env)); + token$4(env, /* T_WHILE */23); + token$4(env, /* T_LPAREN */3); + const test$1 = Curry._1(Parse.expression, env); + const end_loc$6 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_RPAREN */4); + const loc$9 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc$7 = loc$9 !== undefined ? loc$9 : end_loc$6; + if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, undefined, env), /* T_SEMICOLON */7)) { + semicolon(env); + } return [ - btwn(start_loc$1, end_loc$7), + btwn(start_loc$9, end_loc$7), { - TAG: /* ImportDeclaration */29, + TAG: /* DoWhile */13, _0: { - importKind: importKind, - source: source$5, - specifiers: specifiers$2 + body: body$3, + test: test$1 } } ]; - } - } - if (exit$2 === 1) { - const match$14 = Curry._2(Parser_env_Peek.token, undefined, env$2); - const match$15 = Curry._2(Parser_env_Peek.value, undefined, env$2); - let match$16; - let exit$4 = 0; - if (type_ident !== undefined && /* tag */(typeof match$14 === "number" || typeof match$14 === "string")) { - switch (match$14) { - case /* T_IDENTIFIER */0 : - if (match$15 === "from") { - match$16 = [ - /* ImportValue */2, + case /* T_FOR */37 : + const start_loc$10 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_FOR */37); + token$4(env, /* T_LPAREN */3); + const match$4 = Curry._2(Parser_env_Peek.token, undefined, env); + let match$5; + let exit$1 = 0; + if (/* tag */typeof match$4 === "number" || typeof match$4 === "string") { + switch (match$4) { + case /* T_SEMICOLON */7 : + match$5 = [ + undefined, + /* [] */0 + ]; + break; + case /* T_VAR */22 : + const match$6 = declarations(/* T_VAR */22, /* Var */0, with_no_in(true, env)); + match$5 = [ { - TAG: /* ImportDefaultSpecifier */1, - _0: type_ident - } + TAG: /* InitDeclaration */0, + _0: match$6[0] + }, + match$6[1] ]; - } else { - exit$4 = 2; - } - break; - case /* T_COMMA */8 : - match$16 = [ - /* ImportValue */2, - { - TAG: /* ImportDefaultSpecifier */1, - _0: type_ident - } - ]; - break; - default: - exit$4 = 2; - } - } else { - exit$4 = 2; - } - if (exit$4 === 2) { - match$16 = [ - importKind, - { - TAG: /* ImportDefaultSpecifier */1, - _0: Curry._2(Parse.identifier, undefined, env$2) + break; + case /* T_CONST */25 : + const match$7 = $$const(with_no_in(true, env)); + match$5 = [ + { + TAG: /* InitDeclaration */0, + _0: match$7[0] + }, + match$7[1] + ]; + break; + case /* T_LET */26 : + const match$8 = _let(with_no_in(true, env)); + match$5 = [ + { + TAG: /* InitDeclaration */0, + _0: match$8[0] + }, + match$8[1] + ]; + break; + default: + exit$1 = 1; } - ]; - } - const match$17 = Curry._2(Parser_env_Peek.token, undefined, env$2); - let additional_specifiers; - if (/* tag */(typeof match$17 === "number" || typeof match$17 === "string") && match$17 === /* T_COMMA */8) { - token$4(env$2, /* T_COMMA */8); - additional_specifiers = named_or_namespace_specifier(env$2); - } else { - additional_specifiers = /* [] */0; - } - const source$6 = source(env$2); - const loc$7 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env$2); - const end_loc$8 = loc$7 !== undefined ? loc$7 : source$6[0]; - semicolon(env$2); - return [ - btwn(start_loc$1, end_loc$8), - { - TAG: /* ImportDeclaration */29, - _0: { - importKind: match$16[0], - source: source$6, - specifiers: { - hd: match$16[1], - tl: additional_specifiers - } + } else { + exit$1 = 1; + } + if (exit$1 === 1) { + const expr = Curry._1(Parse.expression, with_no_let(true, with_no_in(true, env))); + match$5 = [ + { + TAG: /* InitExpression */1, + _0: expr + }, + /* [] */0 + ]; + } + const init = match$5[0]; + const match$9 = Curry._2(Parser_env_Peek.token, undefined, env); + if (/* tag */typeof match$9 === "number" || typeof match$9 === "string") { + switch (match$9) { + case /* T_IN */15 : + assert_can_be_forin_or_forof(env, /* InvalidLHSInForIn */16)(init); + let left; + if (init !== undefined) { + left = init.TAG === /* InitDeclaration */0 ? ({ + TAG: /* LeftDeclaration */0, + _0: init._0 + }) : ({ + TAG: /* LeftExpression */1, + _0: init._0 + }); + } else { + throw new Caml_js_exceptions.MelangeError("Assert_failure", { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 2556, + 22 + ] + }); + } + token$4(env, /* T_IN */15); + const right = Curry._1(Parse.expression, env); + token$4(env, /* T_RPAREN */4); + const body$4 = Curry._1(Parse.statement, with_in_loop(true, env)); + return [ + btwn(start_loc$10, body$4[0]), + { + TAG: /* ForIn */15, + _0: { + left: left, + right: right, + body: body$4, + each: false + } + } + ]; + case /* T_OF */60 : + assert_can_be_forin_or_forof(env, /* InvalidLHSInForOf */17)(init); + let left$1; + if (init !== undefined) { + left$1 = init.TAG === /* InitDeclaration */0 ? ({ + TAG: /* LeftDeclaration */0, + _0: init._0 + }) : ({ + TAG: /* LeftExpression */1, + _0: init._0 + }); + } else { + throw new Caml_js_exceptions.MelangeError("Assert_failure", { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 2573, + 22 + ] + }); } - } - ]; - } - case /* T_DECLARE */58 : - if (Caml_obj.caml_equal(Curry._2(Parser_env_Peek.token, 1, env), /* T_EXPORT */47)) { - error_on_decorators(env)(decorators); - return declare_export_declaration(undefined, env); - } else { - return statement_list_item(decorators, env); - } - default: - return statement_list_item(decorators, env); - } -} - -function statement_list_item(decoratorsOpt, env) { - const decorators = decoratorsOpt !== undefined ? decoratorsOpt : /* [] */0; - if (!Curry._2(Parser_env_Peek.is_class, undefined, env)) { - error_on_decorators(env)(decorators); - } - const match = Curry._2(Parser_env_Peek.token, undefined, env); - if (/* tag */typeof match === "number" || typeof match === "string") { - switch (match) { - case /* T_CONST */25 : - return var_or_const(env); - case /* T_LET */26 : - const 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); - const match$1 = helper(with_no_let(true, env), /* [] */0, /* [] */0); - const head = Stdlib__List.map((function (param) { - const match = param[1]; - return { - id: match.id, - init: match.init - }; - }), match$1[1]); - token$4(env, /* T_RPAREN */4); - const body = Curry._1(Parse.statement, env); - const end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const end_loc$1 = end_loc !== undefined ? end_loc : match$1[0]; - semicolon(env); + token$4(env, /* T_OF */60); + const right$1 = Curry._1(Parse.assignment, env); + token$4(env, /* T_RPAREN */4); + const body$5 = Curry._1(Parse.statement, with_in_loop(true, env)); + return [ + btwn(start_loc$10, body$5[0]), + { + TAG: /* ForOf */16, + _0: { + left: left$1, + right: right$1, + body: body$5 + } + } + ]; + default: + + } + } Stdlib__List.iter((function (param) { return error_at(env, param); - }), match$1[2]); + }), match$5[1]); + token$4(env, /* T_SEMICOLON */7); + const match$10 = Curry._2(Parser_env_Peek.token, undefined, env); + let test$2; + test$2 = /* tag */(typeof match$10 === "number" || typeof match$10 === "string") && match$10 === /* T_SEMICOLON */7 ? undefined : Curry._1(Parse.expression, env); + token$4(env, /* T_SEMICOLON */7); + const match$11 = Curry._2(Parser_env_Peek.token, undefined, env); + let update; + update = /* tag */(typeof match$11 === "number" || typeof match$11 === "string") && match$11 === /* T_RPAREN */4 ? undefined : Curry._1(Parse.expression, env); + token$4(env, /* T_RPAREN */4); + const body$6 = Curry._1(Parse.statement, with_in_loop(true, env)); return [ - btwn(start_loc, end_loc$1), + btwn(start_loc$10, body$6[0]), { - TAG: /* Let */17, + TAG: /* For */14, _0: { - head: head, - body: body + init: init, + test: test$2, + update: update, + body: body$6 } } ]; + case /* T_DEBUGGER */57 : + const start_loc$11 = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, /* T_DEBUGGER */57); + const loc$10 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc$8 = loc$10 !== undefined ? loc$10 : start_loc$11; + semicolon(env); + return [ + btwn(start_loc$11, end_loc$8), + /* Debugger */1 + ]; + case /* T_EOF */105 : + error_unexpected(env); + return [ + Curry._2(Parser_env_Peek.loc, undefined, env), + /* Empty */0 + ]; + default: + exit = 2; + } + } else { + exit = 2; + } + if (exit === 2) { + if (Curry._2(Parser_env_Peek.is_identifier, undefined, env)) { + const expr$1 = Curry._1(Parse.expression, env); + const match$12 = Curry._2(Parser_env_Peek.token, undefined, env); + const label$4 = expr$1[1]; + if (!/* tag */(typeof label$4 === "number" || typeof label$4 === "string") && label$4.TAG === /* Identifier */18 && /* tag */(typeof match$12 === "number" || typeof match$12 === "string") && match$12 === /* T_COLON */77) { + const label$5 = label$4._0; + const loc$11 = expr$1[0]; + const match$13 = label$5[1]; + const name$2 = match$13.name; + token$4(env, /* T_COLON */77); + if (Curry._2(mem$1, name$2, env.labels)) { + error_at(env, [ + loc$11, + { + TAG: /* Redeclaration */5, + _0: "Label", + _1: name$2 + } + ]); } - const match$2 = helper(with_no_let(true, env), /* [] */0, /* [] */0); - const declaration = { - TAG: /* VariableDeclaration */19, - _0: { - declarations: match$2[1], - kind: /* Let */1 - } - }; - const end_loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - const 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]); + const env$1 = add_label(env, name$2); + const labeled_stmt = Curry._1(Parse.statement, env$1); return [ - btwn(start_loc, end_loc$3), - declaration + btwn(loc$11, labeled_stmt[0]), + { + TAG: /* Labeled */3, + _0: { + label: label$5, + body: labeled_stmt + } + } ]; - default: - + } + const loc$12 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + const end_loc$9 = loc$12 !== undefined ? loc$12 : expr$1[0]; + semicolon(env); + return [ + btwn(expr$1[0], end_loc$9), + { + TAG: /* Expression */1, + _0: { + expression: expr$1 + } + } + ]; + } + if (!/* tag */(typeof match === "number" || typeof match === "string")) { + return expression(env); + } + switch (match) { + case /* T_ELSE */41 : + return _if(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 : + case /* T_COLON */77 : + break; + default: + return expression(env); + } } - } - 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 (!/* tag */(typeof match === "number" || typeof match === "string")) { - return statement(env); - } - switch (match) { - case /* T_INTERFACE */51 : - return $$interface(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_body(term_fn, env) { @@ -14997,8 +14997,6 @@ function directives(env, term_fn, item_fn) { ]; } -const class_declaration$1 = class_declaration; - function statement_list$1(term_fn, env) { let _acc = /* [] */0; while(true) { @@ -15018,6 +15016,8 @@ function statement_list$1(term_fn, env) { }; } +const class_declaration$1 = class_declaration; + function statement_list_with_directives(term_fn, env) { const match = Curry._3(directives, env, term_fn, (function (eta) { return statement_list_item(undefined, eta); @@ -15654,6 +15654,77 @@ function parse(content, options) { } } }; + const literal = function (param) { + const lit = param[1]; + const raw = lit.raw; + const value = lit.value; + const loc = param[0]; + let value_; + if (/* tag */typeof value === "number" || typeof value === "string") { + value_ = $$null; + } else { + switch (value.TAG) { + 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 : + const match = value._0; + value_ = regexp$1(loc, match.pattern, match.flags); + break; + + } + } + let props; + let exit = 0; + if (/* tag */typeof value === "number" || typeof value === "string" || value.TAG !== /* RegExp */3) { + exit = 1; + } else { + const match$1 = value._0; + const 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); + }; const expression = function (param) { const arr = param[1]; const loc = param[0]; @@ -16162,10 +16233,61 @@ function parse(content, options) { } }; - const block = function (param) { - return node("BlockStatement", param[0], [[ - "body", - array_of_list(statement, param[1].body) + const type_annotation = function (param) { + return node("TypeAnnotation", param[0], [[ + "typeAnnotation", + _type(param[1]) + ]]); + }; + const identifier = function (param) { + const id = param[1]; + return node("Identifier", param[0], [ + [ + "name", + string(id.name) + ], + [ + "typeAnnotation", + option(type_annotation, id.typeAnnotation) + ], + [ + "optional", + bool(id.optional) + ] + ]); + }; + const type_param = function (param) { + const tp = param[1]; + const variance = function (param) { + if (param === /* Plus */0) { + return string("plus"); + } else { + return string("minus"); + } + }; + 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) + ] + ]); + }; + const type_parameter_instantiation = function (param) { + return node("TypeParameterInstantiation", param[0], [[ + "params", + array_of_list(_type, param[1].params) ]]); }; const pattern = function (param) { @@ -16217,135 +16339,117 @@ function parse(content, options) { } }; - const object_pattern_property = function (param) { - if (param.TAG === /* Property */0) { - const match = param._0; - const prop = match[1]; - const lit = prop.key; - let match$1; - switch (lit.TAG) { - case /* Literal */0 : - match$1 = [ - literal(lit._0), - false - ]; - break; - case /* Identifier */1 : - match$1 = [ - identifier(lit._0), - false - ]; - break; - case /* Computed */2 : - match$1 = [ - expression(lit._0), - true - ]; - break; - - } - return node("PropertyPattern", match[0], [ - [ - "key", - match$1[0] - ], - [ - "pattern", - pattern(prop.pattern) - ], - [ - "computed", - bool(match$1[1]) - ], - [ - "shorthand", - bool(prop.shorthand) - ] - ]); - } - const match$2 = param._0; - return node("SpreadPropertyPattern", match$2[0], [[ - "argument", - pattern(match$2[1].argument) - ]]); + const object_type = function (param) { + const 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) + ] + ]); }; - const identifier = function (param) { - const id = param[1]; - return node("Identifier", param[0], [ + const function_type = function (param) { + const fn = param[1]; + return node("FunctionTypeAnnotation", param[0], [ [ - "name", - string(id.name) + "params", + array_of_list(function_type_param, fn.params) ], [ - "typeAnnotation", - option(type_annotation, id.typeAnnotation) + "returnType", + _type(fn.returnType) ], [ - "optional", - bool(id.optional) + "rest", + option(function_type_param, fn.rest) + ], + [ + "typeParameters", + option(type_parameter_declaration, fn.typeParameters) ] ]); }; - const type_annotation = function (param) { - return node("TypeAnnotation", param[0], [[ - "typeAnnotation", - _type(param[1]) + const jsx_identifier = function (param) { + return node("JSXIdentifier", param[0], [[ + "name", + string(param[1].name) ]]); }; - const array_pattern_element = function (p) { - if (p.TAG === /* Element */0) { - return pattern(p._0); + const 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 + ]); } - const match = p._0; - return node("SpreadElementPattern", match[0], [[ - "argument", - pattern(match[1].argument) - ]]); }; - const export_specifier = function (param) { - const specifier = param[1]; - return node("ExportSpecifier", param[0], [ + const jsx_namespaced_name = function (param) { + const namespaced_name = param[1]; + return node("JSXNamespacedName", param[0], [ [ - "id", - identifier(specifier.id) + "namespace", + jsx_identifier(namespaced_name.namespace) ], [ "name", - option(identifier, specifier.name) + jsx_identifier(namespaced_name.name) ] ]); }; + const class_body = function (param) { + return node("ClassBody", param[0], [[ + "body", + array_of_list(class_element, param[1].body) + ]]); + }; + const type_parameter_declaration = function (param) { + return node("TypeParameterDeclaration", param[0], [[ + "params", + array_of_list(type_param, param[1].params) + ]]); + }; const class_implements = function (param) { const $$implements = param[1]; return node("ClassImplements", param[0], [ [ - "id", - identifier($$implements.id) + "id", + identifier($$implements.id) + ], + [ + "typeParameters", + option(type_parameter_instantiation, $$implements.typeParameters) + ] + ]); + }; + const generic_type_qualified_identifier = function (param) { + const q = param[1]; + const id = q.qualification; + let qualification; + qualification = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("QualifiedTypeIdentifier", param[0], [ + [ + "qualification", + qualification ], [ - "typeParameters", - option(type_parameter_instantiation, $$implements.typeParameters) + "id", + identifier(q.id) ] ]); }; - const class_body = function (param) { - return node("ClassBody", param[0], [[ - "body", - array_of_list(class_element, param[1].body) - ]]); - }; - const type_parameter_declaration = function (param) { - return node("TypeParameterDeclaration", param[0], [[ - "params", - array_of_list(type_param, param[1].params) - ]]); - }; - const type_parameter_instantiation = function (param) { - return node("TypeParameterInstantiation", param[0], [[ - "params", - array_of_list(_type, param[1].params) - ]]); - }; const statement = function (param) { const b = param[1]; const loc = param[0]; @@ -16620,755 +16724,362 @@ function parse(content, options) { [ "expression", bool(fn.expression) - ], - [ - "returnType", - option(type_annotation, fn.returnType) - ], - [ - "typeParameters", - option(type_parameter_declaration, fn.typeParameters) - ] - ]); - case /* VariableDeclaration */19 : - return variable_declaration([ - loc, - b._0 - ]); - case /* ClassDeclaration */20 : - let param$1 = [ - loc, - b._0 - ]; - const c = param$1[1]; - const id$1 = c.id; - const match$1 = id$1 !== undefined ? [ - "ClassDeclaration", - identifier(id$1) - ] : [ - "ClassExpression", - $$null - ]; - return node(match$1[0], param$1[0], [ - [ - "id", - match$1[1] - ], - [ - "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 /* InterfaceDeclaration */21 : - return interface_declaration([ - loc, - b._0 - ]); - case /* DeclareVariable */22 : - return declare_variable([ - loc, - b._0 - ]); - case /* DeclareFunction */23 : - return declare_function([ - loc, - b._0 - ]); - case /* DeclareClass */24 : - return declare_class([ - loc, - b._0 - ]); - case /* DeclareModule */25 : - const m = b._0; - const lit = m.id; - let id$2; - id$2 = lit.TAG === /* Identifier */0 ? identifier(lit._0) : literal(lit._0); - const match$2 = m.kind; - let tmp; - tmp = match$2.TAG === /* CommonJS */0 ? string("CommonJS") : string("ES"); - return node("DeclareModule", loc, [ - [ - "id", - id$2 - ], - [ - "body", - block(m.body) - ], - [ - "kind", - tmp - ] - ]); - case /* DeclareModuleExports */26 : - return node("DeclareModuleExports", loc, [[ - "typeAnnotation", - type_annotation(b._0) - ]]); - case /* DeclareExportDeclaration */27 : - const $$export = b._0; - const match$3 = $$export.declaration; - let declaration; - if (match$3 !== undefined) { - switch (match$3.TAG) { - case /* Variable */0 : - declaration = declare_variable(match$3._0); - break; - case /* Function */1 : - declaration = declare_function(match$3._0); - break; - case /* Class */2 : - declaration = declare_class(match$3._0); - break; - case /* DefaultType */3 : - declaration = _type(match$3._0); - break; - case /* NamedType */4 : - declaration = type_alias(match$3._0); - break; - case /* Interface */5 : - declaration = interface_declaration(match$3._0); - break; - - } - } else { - declaration = $$null; - } - return node("DeclareExportDeclaration", loc, [ - [ - "default", - bool($$export.default) - ], - [ - "declaration", - declaration - ], - [ - "specifiers", - export_specifiers($$export.specifiers) - ], - [ - "source", - option(literal, $$export.source) - ] - ]); - case /* ExportDeclaration */28 : - const $$export$1 = b._0; - const match$4 = $$export$1.declaration; - const declaration$1 = match$4 !== undefined ? ( - match$4.TAG === /* Declaration */0 ? statement(match$4._0) : expression(match$4._0) - ) : $$null; - return node("ExportDeclaration", loc, [ - [ - "default", - bool($$export$1.default) - ], - [ - "declaration", - declaration$1 - ], - [ - "specifiers", - export_specifiers($$export$1.specifiers) - ], - [ - "source", - option(literal, $$export$1.source) - ], - [ - "exportKind", - string(export_kind($$export$1.exportKind)) - ] - ]); - case /* ImportDeclaration */29 : - const $$import = b._0; - const specifiers = Stdlib__List.map((function (id) { - switch (id.TAG) { - case /* ImportNamedSpecifier */0 : - const match = id._0; - let local_id = match.local; - let remote_id = match.remote; - const span_loc = local_id !== undefined ? btwn(remote_id[0], local_id[0]) : remote_id[0]; - return node("ImportSpecifier", span_loc, [ - [ - "id", - identifier(remote_id) - ], - [ - "name", - option(identifier, local_id) - ] - ]); - case /* ImportDefaultSpecifier */1 : - let id$1 = id._0; - return node("ImportDefaultSpecifier", id$1[0], [[ - "id", - identifier(id$1) - ]]); - case /* ImportNamespaceSpecifier */2 : - let param = id._0; - return node("ImportNamespaceSpecifier", param[0], [[ - "id", - identifier(param[1]) - ]]); - - } - }), $$import.specifiers); - const match$5 = $$import.importKind; - let import_kind; - switch (match$5) { - case /* ImportType */0 : - import_kind = "type"; - break; - case /* ImportTypeof */1 : - import_kind = "typeof"; - break; - case /* ImportValue */2 : - import_kind = "value"; - break; - - } - return node("ImportDeclaration", loc, [ + ], [ - "specifiers", - array(Stdlib__Array.of_list(specifiers)) + "returnType", + option(type_annotation, fn.returnType) ], [ - "source", - literal($$import.source) + "typeParameters", + option(type_parameter_declaration, fn.typeParameters) + ] + ]); + case /* VariableDeclaration */19 : + return variable_declaration([ + loc, + b._0 + ]); + case /* ClassDeclaration */20 : + let param$1 = [ + loc, + b._0 + ]; + const c = param$1[1]; + const id$1 = c.id; + const match$1 = id$1 !== undefined ? [ + "ClassDeclaration", + identifier(id$1) + ] : [ + "ClassExpression", + $$null + ]; + return node(match$1[0], param$1[0], [ + [ + "id", + match$1[1] ], [ - "importKind", - string(import_kind) + "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) ] ]); - - } - }; - const generic_type_qualified_identifier = function (param) { - const q = param[1]; - const id = q.qualification; - let 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) - ] - ]); - }; - const literal = function (param) { - const lit = param[1]; - const raw = lit.raw; - const value = lit.value; - const loc = param[0]; - let value_; - if (/* tag */typeof value === "number" || typeof value === "string") { - value_ = $$null; - } else { - switch (value.TAG) { - 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 : - const match = value._0; - value_ = regexp$1(loc, match.pattern, match.flags); - break; - - } - } - let props; - let exit = 0; - if (/* tag */typeof value === "number" || typeof value === "string" || value.TAG !== /* RegExp */3) { - exit = 1; - } else { - const match$1 = value._0; - const 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); - }; - const 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 - ]); - } - }; - const jsx_namespaced_name = function (param) { - const namespaced_name = param[1]; - return node("JSXNamespacedName", param[0], [ - [ - "namespace", - jsx_identifier(namespaced_name.namespace) - ], - [ - "name", - jsx_identifier(namespaced_name.name) - ] - ]); - }; - const jsx_identifier = function (param) { - return node("JSXIdentifier", param[0], [[ - "name", - string(param[1].name) - ]]); - }; - const function_type = function (param) { - const fn = param[1]; - return node("FunctionTypeAnnotation", param[0], [ - [ - "params", - array_of_list(function_type_param, fn.params) - ], - [ - "returnType", - _type(fn.returnType) - ], - [ - "rest", - option(function_type_param, fn.rest) - ], - [ - "typeParameters", - option(type_parameter_declaration, fn.typeParameters) - ] - ]); - }; - const function_type_param = function (param) { - const param$1 = param[1]; - return node("FunctionTypeParam", param[0], [ - [ - "name", - identifier(param$1.name) - ], - [ - "typeAnnotation", - _type(param$1.typeAnnotation) - ], - [ - "optional", - bool(param$1.optional) - ] - ]); - }; - const jsx_child = function (param) { - const element = param[1]; - const loc = param[0]; - switch (element.TAG) { - case /* Element */0 : - return jsx_element([ + case /* InterfaceDeclaration */21 : + return interface_declaration([ loc, - element._0 + b._0 + ]); + case /* DeclareVariable */22 : + return declare_variable([ + loc, + b._0 + ]); + case /* DeclareFunction */23 : + return declare_function([ + loc, + b._0 + ]); + case /* DeclareClass */24 : + return declare_class([ + loc, + b._0 + ]); + case /* DeclareModule */25 : + const m = b._0; + const lit = m.id; + let id$2; + id$2 = lit.TAG === /* Identifier */0 ? identifier(lit._0) : literal(lit._0); + const match$2 = m.kind; + let tmp; + tmp = match$2.TAG === /* CommonJS */0 ? string("CommonJS") : string("ES"); + return node("DeclareModule", loc, [ + [ + "id", + id$2 + ], + [ + "body", + block(m.body) + ], + [ + "kind", + tmp + ] ]); - case /* ExpressionContainer */1 : - return jsx_expression_container([ - loc, - element._0 + case /* DeclareModuleExports */26 : + return node("DeclareModuleExports", loc, [[ + "typeAnnotation", + type_annotation(b._0) + ]]); + case /* DeclareExportDeclaration */27 : + const $$export = b._0; + const match$3 = $$export.declaration; + let declaration; + if (match$3 !== undefined) { + switch (match$3.TAG) { + case /* Variable */0 : + declaration = declare_variable(match$3._0); + break; + case /* Function */1 : + declaration = declare_function(match$3._0); + break; + case /* Class */2 : + declaration = declare_class(match$3._0); + break; + case /* DefaultType */3 : + declaration = _type(match$3._0); + break; + case /* NamedType */4 : + declaration = type_alias(match$3._0); + break; + case /* Interface */5 : + declaration = interface_declaration(match$3._0); + break; + + } + } else { + declaration = $$null; + } + return node("DeclareExportDeclaration", loc, [ + [ + "default", + bool($$export.default) + ], + [ + "declaration", + declaration + ], + [ + "specifiers", + export_specifiers($$export.specifiers) + ], + [ + "source", + option(literal, $$export.source) + ] ]); - case /* Text */2 : - let param$1 = [ - loc, - element._0 - ]; - const text = param$1[1]; - return node("JSXText", param$1[0], [ + case /* ExportDeclaration */28 : + const $$export$1 = b._0; + const match$4 = $$export$1.declaration; + const declaration$1 = match$4 !== undefined ? ( + match$4.TAG === /* Declaration */0 ? statement(match$4._0) : expression(match$4._0) + ) : $$null; + return node("ExportDeclaration", loc, [ [ - "value", - string(text.value) + "default", + bool($$export$1.default) ], [ - "raw", - string(text.raw) + "declaration", + declaration$1 + ], + [ + "specifiers", + export_specifiers($$export$1.specifiers) + ], + [ + "source", + option(literal, $$export$1.source) + ], + [ + "exportKind", + string(export_kind($$export$1.exportKind)) ] ]); - - } - }; - const jsx_closing = function (param) { - return node("JSXClosingElement", param[0], [[ - "name", - jsx_name(param[1].name) - ]]); - }; - const jsx_opening = function (param) { - const opening = param[1]; - return node("JSXOpeningElement", param[0], [ - [ - "name", - jsx_name(opening.name) - ], - [ - "attributes", - array_of_list(jsx_opening_attribute, opening.attributes) - ], - [ - "selfClosing", - bool(opening.selfClosing) - ] - ]); - }; - const jsx_expression_container = function (param) { - const expr = param[1].expression; - let expression$1; - expression$1 = expr.TAG === /* Expression */0 ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); - return node("JSXExpressionContainer", param[0], [[ - "expression", - expression$1 - ]]); - }; - const jsx_element = function (param) { - const 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) - ] - ]); - }; - const object_property = function (param) { - if (param.TAG === /* Property */0) { - const match = param._0; - const prop = match[1]; - const lit = prop.key; - let match$1; - switch (lit.TAG) { - case /* Literal */0 : - match$1 = [ - literal(lit._0), - false - ]; - break; - case /* Identifier */1 : - match$1 = [ - identifier(lit._0), - false - ]; - break; - case /* Computed */2 : - match$1 = [ - expression(lit._0), - true - ]; - break; - - } - const match$2 = prop.kind; - let 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] - ], - [ - "value", - expression(prop.value) - ], - [ - "kind", - string(kind) - ], - [ - "method", - bool(prop._method) - ], - [ - "shorthand", - bool(prop.shorthand) - ], - [ - "computed", - bool(match$1[1]) - ] - ]); + case /* ImportDeclaration */29 : + const $$import = b._0; + const specifiers = Stdlib__List.map((function (id) { + switch (id.TAG) { + case /* ImportNamedSpecifier */0 : + const match = id._0; + let local_id = match.local; + let remote_id = match.remote; + const span_loc = local_id !== undefined ? btwn(remote_id[0], local_id[0]) : remote_id[0]; + return node("ImportSpecifier", span_loc, [ + [ + "id", + identifier(remote_id) + ], + [ + "name", + option(identifier, local_id) + ] + ]); + case /* ImportDefaultSpecifier */1 : + let id$1 = id._0; + return node("ImportDefaultSpecifier", id$1[0], [[ + "id", + identifier(id$1) + ]]); + case /* ImportNamespaceSpecifier */2 : + let param = id._0; + return node("ImportNamespaceSpecifier", param[0], [[ + "id", + identifier(param[1]) + ]]); + + } + }), $$import.specifiers); + const match$5 = $$import.importKind; + let import_kind; + switch (match$5) { + case /* ImportType */0 : + import_kind = "type"; + break; + case /* ImportTypeof */1 : + import_kind = "typeof"; + break; + case /* ImportValue */2 : + import_kind = "value"; + break; + + } + return node("ImportDeclaration", loc, [ + [ + "specifiers", + array(Stdlib__Array.of_list(specifiers)) + ], + [ + "source", + literal($$import.source) + ], + [ + "importKind", + string(import_kind) + ] + ]); + } - const match$3 = param._0; - return node("SpreadProperty", match$3[0], [[ - "argument", - expression(match$3[1].argument) - ]]); - }; - const template_literal = function (param) { - const value = param[1]; - return node("TemplateLiteral", param[0], [ - [ - "quasis", - array_of_list(template_element, value.quasis) - ], - [ - "expressions", - array_of_list(expression, value.expressions) - ] - ]); }; - const expression_or_spread = function (expr) { - if (expr.TAG === /* Expression */0) { - return expression(expr._0); - } - const match = expr._0; - return node("SpreadElement", match[0], [[ - "argument", - expression(match[1].argument) + const jsx_expression_container = function (param) { + const expr = param[1].expression; + let expression$1; + expression$1 = expr.TAG === /* Expression */0 ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); + return node("JSXExpressionContainer", param[0], [[ + "expression", + expression$1 ]]); }; - const function_expression = function (param) { - const _function = param[1]; - const b = _function.body; - let body; - body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); - return node("FunctionExpression", param[0], [ + const type_alias = function (param) { + const alias = param[1]; + return node("TypeAlias", 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", - body - ], - [ - "async", - bool(_function.async) - ], - [ - "generator", - bool(_function.generator) - ], - [ - "expression", - bool(_function.expression) - ], - [ - "returnType", - option(type_annotation, _function.returnType) + identifier(alias.id) ], [ "typeParameters", - option(type_parameter_declaration, _function.typeParameters) - ] - ]); - }; - const let_assignment = function (assignment) { - return obj([ - [ - "id", - pattern(assignment.id) + option(type_parameter_declaration, alias.typeParameters) ], [ - "init", - option(expression, assignment.init) + "right", + _type(alias.right) ] ]); }; - const comprehension_block = function (param) { - const b = param[1]; - return node("ComprehensionBlock", param[0], [ - [ - "left", - pattern(b.left) - ], + const $$case = function (param) { + const c = param[1]; + return node("SwitchCase", param[0], [ [ - "right", - expression(b.right) + "test", + option(expression, c.test) ], [ - "each", - bool(b.each) + "consequent", + array_of_list(statement, c.consequent) ] ]); }; - const variable_declarator = function (param) { - const declarator = param[1]; - return node("VariableDeclarator", param[0], [ + const interface_declaration = function (param) { + const i = param[1]; + return node("InterfaceDeclaration", param[0], [ [ "id", - pattern(declarator.id) + identifier(i.id) ], [ - "init", - option(expression, declarator.init) - ] - ]); - }; - const object_type = function (param) { - const o = param[1]; - return node("ObjectTypeAnnotation", param[0], [ - [ - "properties", - array_of_list(object_type_property, o.properties) + "typeParameters", + option(type_parameter_declaration, i.typeParameters) ], [ - "indexers", - array_of_list(object_type_indexer, o.indexers) + "body", + object_type(i.body) ], [ - "callProperties", - array_of_list(object_type_call_property, o.callProperties) + "extends", + array_of_list(interface_extends, i.extends) ] ]); }; - const interface_extends = function (param) { - const g = param[1]; - const id = g.id; - let id$1; - id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("InterfaceExtends", param[0], [ + const declare_variable = function (param) { + return node("DeclareVariable", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + const declare_function = function (param) { + return node("DeclareFunction", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + const let_assignment = function (assignment) { + return obj([ [ "id", - id$1 + pattern(assignment.id) ], [ - "typeParameters", - option(type_parameter_instantiation, g.typeParameters) + "init", + option(expression, assignment.init) ] ]); }; - const jsx_opening_attribute = function (attribute) { - if (attribute.TAG === /* Attribute */0) { - let param = attribute._0; - const attribute$1 = param[1]; - const id = attribute$1.name; - let name; - name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); - return node("JSXAttribute", param[0], [ - [ - "name", - name - ], - [ - "value", - option(jsx_attribute_value, attribute$1.value) - ] - ]); - } else { - let param$1 = attribute._0; - return node("JSXSpreadAttribute", param$1[0], [[ - "argument", - expression(param$1[1].argument) - ]]); - } - }; - const jsx_name = function (id) { - switch (id.TAG) { - case /* Identifier */0 : - return jsx_identifier(id._0); - case /* NamespacedName */1 : - return jsx_namespaced_name(id._0); - case /* MemberExpression */2 : - return jsx_member_expression(id._0); + const variable_declaration = function (param) { + const $$var = param[1]; + const match = $$var.kind; + let kind; + switch (match) { + case /* Var */0 : + kind = "var"; + break; + case /* Let */1 : + kind = "let"; + break; + case /* Const */2 : + kind = "const"; + break; } - }; - const export_kind = function (param) { - if (param === /* ExportType */0) { - return "type"; - } else { - return "value"; - } + return node("VariableDeclaration", param[0], [ + [ + "declarations", + array_of_list(variable_declarator, $$var.declarations) + ], + [ + "kind", + string(kind) + ] + ]); }; const export_specifiers = function (param) { if (param !== undefined) { @@ -17384,16 +17095,24 @@ function parse(content, options) { return array([]); } }; - const $$case = function (param) { - const c = param[1]; - return node("SwitchCase", param[0], [ + const declare_class = function (param) { + const d = param[1]; + return node("DeclareClass", param[0], [ [ - "test", - option(expression, c.test) + "id", + identifier(d.id) ], [ - "consequent", - array_of_list(statement, c.consequent) + "typeParameters", + option(type_parameter_declaration, d.typeParameters) + ], + [ + "body", + object_type(d.body) + ], + [ + "extends", + array_of_list(interface_extends, d.extends) ] ]); }; @@ -17414,101 +17133,261 @@ function parse(content, options) { ] ]); }; - const declare_variable = function (param) { - return node("DeclareVariable", param[0], [[ - "id", - identifier(param[1].id) + const block = function (param) { + return node("BlockStatement", param[0], [[ + "body", + array_of_list(statement, param[1].body) ]]); }; - const interface_declaration = function (param) { - const i = param[1]; - return node("InterfaceDeclaration", param[0], [ + const export_kind = function (param) { + if (param === /* ExportType */0) { + return "type"; + } else { + return "value"; + } + }; + const variable_declarator = function (param) { + const declarator = param[1]; + return node("VariableDeclarator", param[0], [ [ "id", - identifier(i.id) + pattern(declarator.id) ], [ - "typeParameters", - option(type_parameter_declaration, i.typeParameters) + "init", + option(expression, declarator.init) + ] + ]); + }; + const jsx_name = function (id) { + switch (id.TAG) { + case /* Identifier */0 : + return jsx_identifier(id._0); + case /* NamespacedName */1 : + return jsx_namespaced_name(id._0); + case /* MemberExpression */2 : + return jsx_member_expression(id._0); + + } + }; + const template_element = function (param) { + const element = param[1]; + const value = obj([ + [ + "raw", + string(element.value.raw) + ], + [ + "cooked", + string(element.value.cooked) + ] + ]); + return node("TemplateElement", param[0], [ + [ + "value", + value ], [ - "body", - object_type(i.body) + "tail", + bool(element.tail) + ] + ]); + }; + const comprehension_block = function (param) { + const b = param[1]; + return node("ComprehensionBlock", param[0], [ + [ + "left", + pattern(b.left) ], [ - "extends", - array_of_list(interface_extends, i.extends) + "right", + expression(b.right) + ], + [ + "each", + bool(b.each) ] ]); }; - const declare_function = function (param) { - return node("DeclareFunction", param[0], [[ - "id", - identifier(param[1].id) + const expression_or_spread = function (expr) { + if (expr.TAG === /* Expression */0) { + return expression(expr._0); + } + const match = expr._0; + return node("SpreadElement", match[0], [[ + "argument", + expression(match[1].argument) ]]); }; - const type_alias = function (param) { - const alias = param[1]; - return node("TypeAlias", param[0], [ + const function_expression = function (param) { + const _function = param[1]; + const b = _function.body; + let body; + body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); + return node("FunctionExpression", param[0], [ [ "id", - identifier(alias.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", + body + ], + [ + "async", + bool(_function.async) + ], + [ + "generator", + bool(_function.generator) + ], + [ + "expression", + bool(_function.expression) + ], + [ + "returnType", + option(type_annotation, _function.returnType) ], [ "typeParameters", - option(type_parameter_declaration, alias.typeParameters) + option(type_parameter_declaration, _function.typeParameters) + ] + ]); + }; + const template_literal = function (param) { + const value = param[1]; + return node("TemplateLiteral", param[0], [ + [ + "quasis", + array_of_list(template_element, value.quasis) ], [ - "right", - _type(alias.right) + "expressions", + array_of_list(expression, value.expressions) ] ]); }; - const variable_declaration = function (param) { - const $$var = param[1]; - const match = $$var.kind; - let kind; - switch (match) { - case /* Var */0 : - kind = "var"; - break; - case /* Let */1 : - kind = "let"; - break; - case /* Const */2 : - kind = "const"; - break; - + const object_property = function (param) { + if (param.TAG === /* Property */0) { + const match = param._0; + const prop = match[1]; + const lit = prop.key; + let match$1; + switch (lit.TAG) { + case /* Literal */0 : + match$1 = [ + literal(lit._0), + false + ]; + break; + case /* Identifier */1 : + match$1 = [ + identifier(lit._0), + false + ]; + break; + case /* Computed */2 : + match$1 = [ + expression(lit._0), + true + ]; + break; + + } + const match$2 = prop.kind; + let 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] + ], + [ + "value", + expression(prop.value) + ], + [ + "kind", + string(kind) + ], + [ + "method", + bool(prop._method) + ], + [ + "shorthand", + bool(prop.shorthand) + ], + [ + "computed", + bool(match$1[1]) + ] + ]); } - return node("VariableDeclaration", param[0], [ + const match$3 = param._0; + return node("SpreadProperty", match$3[0], [[ + "argument", + expression(match$3[1].argument) + ]]); + }; + const jsx_element = function (param) { + const element = param[1]; + return node("JSXElement", param[0], [ [ - "declarations", - array_of_list(variable_declarator, $$var.declarations) + "openingElement", + jsx_opening(element.openingElement) ], [ - "kind", - string(kind) + "closingElement", + option(jsx_closing, element.closingElement) + ], + [ + "children", + array_of_list(jsx_child, element.children) ] ]); }; - const declare_class = function (param) { - const d = param[1]; - return node("DeclareClass", param[0], [ - [ - "id", - identifier(d.id) - ], + const function_type_param = function (param) { + const param$1 = param[1]; + return node("FunctionTypeParam", param[0], [ [ - "typeParameters", - option(type_parameter_declaration, d.typeParameters) + "name", + identifier(param$1.name) ], [ - "body", - object_type(d.body) + "typeAnnotation", + _type(param$1.typeAnnotation) ], [ - "extends", - array_of_list(interface_extends, d.extends) + "optional", + bool(param$1.optional) ] ]); }; @@ -17631,42 +17510,88 @@ function parse(content, options) { ]); } }; - const jsx_member_expression = function (param) { - const member_expression = param[1]; - const id = member_expression._object; - let _object; - _object = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_member_expression(id._0); - return node("JSXMemberExpression", param[0], [ + const export_specifier = function (param) { + const specifier = param[1]; + return node("ExportSpecifier", param[0], [ [ - "object", - _object + "id", + identifier(specifier.id) ], [ - "property", - jsx_identifier(member_expression.property) + "name", + option(identifier, specifier.name) ] ]); }; - const template_element = function (param) { + const jsx_opening = function (param) { + const opening = param[1]; + return node("JSXOpeningElement", param[0], [ + [ + "name", + jsx_name(opening.name) + ], + [ + "attributes", + array_of_list(jsx_opening_attribute, opening.attributes) + ], + [ + "selfClosing", + bool(opening.selfClosing) + ] + ]); + }; + const jsx_child = function (param) { const element = param[1]; - const value = obj([ - [ - "raw", - string(element.value.raw) - ], - [ - "cooked", - string(element.value.cooked) - ] - ]); - return node("TemplateElement", param[0], [ + const loc = param[0]; + switch (element.TAG) { + case /* Element */0 : + return jsx_element([ + loc, + element._0 + ]); + case /* ExpressionContainer */1 : + return jsx_expression_container([ + loc, + element._0 + ]); + case /* Text */2 : + let param$1 = [ + loc, + element._0 + ]; + const text = param$1[1]; + return node("JSXText", param$1[0], [ + [ + "value", + string(text.value) + ], + [ + "raw", + string(text.raw) + ] + ]); + + } + }; + const jsx_closing = function (param) { + return node("JSXClosingElement", param[0], [[ + "name", + jsx_name(param[1].name) + ]]); + }; + const interface_extends = function (param) { + const g = param[1]; + const id = g.id; + let id$1; + id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("InterfaceExtends", param[0], [ [ - "value", - value + "id", + id$1 ], [ - "tail", - bool(element.tail) + "typeParameters", + option(type_parameter_instantiation, g.typeParameters) ] ]); }; @@ -17741,34 +17666,47 @@ function parse(content, options) { ] ]); }; - const type_param = function (param) { - const tp = param[1]; - const variance = function (param) { - if (param === /* Plus */0) { - return string("plus"); - } else { - return string("minus"); - } - }; - return node("TypeParameter", param[0], [ - [ - "name", - string(tp.name) - ], - [ - "bound", - option(type_annotation, tp.bound) - ], + const jsx_member_expression = function (param) { + const member_expression = param[1]; + const id = member_expression._object; + let _object; + _object = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_member_expression(id._0); + return node("JSXMemberExpression", param[0], [ [ - "variance", - option(variance, tp.variance) + "object", + _object ], [ - "default", - option(_type, tp.default) + "property", + jsx_identifier(member_expression.property) ] ]); }; + const jsx_opening_attribute = function (attribute) { + if (attribute.TAG === /* Attribute */0) { + let param = attribute._0; + const attribute$1 = param[1]; + const id = attribute$1.name; + let name; + name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); + return node("JSXAttribute", param[0], [ + [ + "name", + name + ], + [ + "value", + option(jsx_attribute_value, attribute$1.value) + ] + ]); + } else { + let param$1 = attribute._0; + return node("JSXSpreadAttribute", param$1[0], [[ + "argument", + expression(param$1[1].argument) + ]]); + } + }; const comment = function (param) { const c = param[1]; let match; @@ -17784,6 +17722,68 @@ function parse(content, options) { string(match[1]) ]]); }; + const array_pattern_element = function (p) { + if (p.TAG === /* Element */0) { + return pattern(p._0); + } + const match = p._0; + return node("SpreadElementPattern", match[0], [[ + "argument", + pattern(match[1].argument) + ]]); + }; + const object_pattern_property = function (param) { + if (param.TAG === /* Property */0) { + const match = param._0; + const prop = match[1]; + const lit = prop.key; + let match$1; + switch (lit.TAG) { + case /* Literal */0 : + match$1 = [ + literal(lit._0), + false + ]; + break; + case /* Identifier */1 : + match$1 = [ + identifier(lit._0), + false + ]; + break; + case /* Computed */2 : + match$1 = [ + expression(lit._0), + true + ]; + break; + + } + return node("PropertyPattern", match[0], [ + [ + "key", + match$1[0] + ], + [ + "pattern", + pattern(prop.pattern) + ], + [ + "computed", + bool(match$1[1]) + ], + [ + "shorthand", + bool(prop.shorthand) + ] + ]); + } + const match$2 = param._0; + return node("SpreadPropertyPattern", match$2[0], [[ + "argument", + pattern(match$2[1].argument) + ]]); + }; const program$2 = function (param) { return node("Program", param[0], [ [ diff --git a/jscomp/test/dist/jscomp/test/gpr_3209_test.js b/jscomp/test/dist/jscomp/test/gpr_3209_test.js index d9348e5f4..100eeac01 100644 --- a/jscomp/test/dist/jscomp/test/gpr_3209_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_3209_test.js @@ -4,22 +4,20 @@ function f9(param) { if (/* tag */typeof param === "number" || typeof param === "string") { - switch (param) { - case /* T60 */0 : - case /* T61 */1 : - case /* T62 */2 : - return 1; - default: - return 3; + if (param === /* T63 */3) { + return 3; + } else { + return 1; } - } else { - switch (param.TAG) { - case /* T64 */0 : - case /* T65 */1 : - return 2; - default: + } + switch (param.TAG) { + case /* T64 */0 : + case /* T65 */1 : + return 2; + case /* T66 */2 : + case /* T68 */3 : return 3; - } + } } diff --git a/jscomp/test/dist/jscomp/test/libqueue_test.js b/jscomp/test/dist/jscomp/test/libqueue_test.js index 3c6fc0134..a03745439 100644 --- a/jscomp/test/dist/jscomp/test/libqueue_test.js +++ b/jscomp/test/dist/jscomp/test/libqueue_test.js @@ -27,6 +27,7 @@ const Q = { peek: Stdlib__Queue.peek, peek_opt: Stdlib__Queue.peek_opt, top: Stdlib__Queue.top, + drop: Stdlib__Queue.drop, clear: Stdlib__Queue.clear, copy: Stdlib__Queue.copy, is_empty: Stdlib__Queue.is_empty, diff --git a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js index cd9282b41..a3272112e 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js @@ -11271,25 +11271,6 @@ function directive_parse(token_with_comments, lexbuf) { return v; } }; - const parse_or_aux = function (calc, v) { - const e = token(undefined); - if (/* tag */typeof e === "number" || typeof e === "string") { - if (e === /* BARBAR */8) { - const calc$1 = calc && !v; - const 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; - } else { - push(e); - return v; - } - }; const parse_relation = function (calc) { const curr_token = token(undefined); const curr_loc = curr(lexbuf); @@ -11433,6 +11414,25 @@ function directive_parse(token_with_comments, lexbuf) { } } }; + const parse_or_aux = function (calc, v) { + const e = token(undefined); + if (/* tag */typeof e === "number" || typeof e === "string") { + if (e === /* BARBAR */8) { + const calc$1 = calc && !v; + const 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; + } else { + push(e); + return v; + } + }; const v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); const match = token(undefined); if (/* tag */typeof match === "number" || typeof match === "string") { @@ -12796,66 +12796,6 @@ function token(lexbuf) { }; } -function string(lexbuf) { - lexbuf.lex_mem = Caml_array.make(2, -1); - let ___ocaml_lex_state = 164; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __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 : - const 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); - } - const 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 new Caml_js_exceptions.MelangeError($$Error$2, { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents - }); - 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_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { while(true) { const __ocaml_lex_state = ___ocaml_lex_state; @@ -13076,6 +13016,66 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { }; } +function string(lexbuf) { + lexbuf.lex_mem = Caml_array.make(2, -1); + let ___ocaml_lex_state = 164; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __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 : + const 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); + } + const 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 new Caml_js_exceptions.MelangeError($$Error$2, { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + }); + 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 at_bol(lexbuf) { const pos = lexbuf.lex_start_p; return pos.pos_cnum === pos.pos_bol; diff --git a/jscomp/test/dist/jscomp/test/ocaml_proto_test.js b/jscomp/test/dist/jscomp/test/ocaml_proto_test.js index 9151c999a..749b07656 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_proto_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_proto_test.js @@ -1592,7 +1592,7 @@ const __ocaml_lex_tables = { lex_code: "" }; -function __ocaml_lex_comment_rec(_l, lexbuf, ___ocaml_lex_state) { +function __ocaml_lex_multi_line_comment_rec(_l, lexbuf, ___ocaml_lex_state) { while(true) { const __ocaml_lex_state = ___ocaml_lex_state; const l = _l; @@ -1600,18 +1600,22 @@ function __ocaml_lex_comment_rec(_l, lexbuf, ___ocaml_lex_state) { switch (__ocaml_lex_state$1) { case 0 : update_loc(lexbuf); + ___ocaml_lex_state = 47; + continue ; + case 1 : + Stdlib__Lexing.lexeme(lexbuf); return { TAG: /* Comment_value */0, _0: Stdlib__String.concat("", Stdlib__List.rev(l)) }; - case 1 : - ___ocaml_lex_state = 41; + case 2 : + ___ocaml_lex_state = 47; _l = { hd: Stdlib__Lexing.lexeme(lexbuf), tl: l }; continue ; - case 2 : + case 3 : return /* Comment_eof */0; default: Curry._1(lexbuf.refill_buff, lexbuf); @@ -1657,7 +1661,7 @@ function __ocaml_lex_string_rec(_l, lexbuf, ___ocaml_lex_state) { }; } -function __ocaml_lex_multi_line_comment_rec(_l, lexbuf, ___ocaml_lex_state) { +function __ocaml_lex_comment_rec(_l, lexbuf, ___ocaml_lex_state) { while(true) { const __ocaml_lex_state = ___ocaml_lex_state; const l = _l; @@ -1665,22 +1669,18 @@ function __ocaml_lex_multi_line_comment_rec(_l, lexbuf, ___ocaml_lex_state) { switch (__ocaml_lex_state$1) { case 0 : update_loc(lexbuf); - ___ocaml_lex_state = 47; - continue ; - case 1 : - Stdlib__Lexing.lexeme(lexbuf); return { TAG: /* Comment_value */0, _0: Stdlib__String.concat("", Stdlib__List.rev(l)) }; - case 2 : - ___ocaml_lex_state = 47; + case 1 : + ___ocaml_lex_state = 41; _l = { hd: Stdlib__Lexing.lexeme(lexbuf), tl: l }; continue ; - case 3 : + case 2 : return /* Comment_eof */0; default: Curry._1(lexbuf.refill_buff, lexbuf); diff --git a/jscomp/test/dist/jscomp/test/ocaml_re_test.js b/jscomp/test/dist/jscomp/test/ocaml_re_test.js index d4c554714..f56e6a1d7 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_re_test.js @@ -3384,260 +3384,130 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - const branch$p = function (_left) { - while(true) { - const left = _left; - if (i.contents === l || test(/* '|' */124) || test(/* ')' */41)) { - return seq$2(Stdlib__List.rev(left)); - } - _left = { - hd: piece(undefined), - tl: left - }; - continue ; - }; - }; - const bracket = function (_s) { - while(true) { - const s = _s; - if (Caml_obj.caml_notequal(s, /* [] */0) && accept(/* ']' */93)) { - return s; - } - const match = $$char(undefined); - if (match.NAME === "Char") { - const c = match.VAL; - if (accept(/* '-' */45)) { - if (accept(/* ']' */93)) { - return { - hd: { - TAG: /* Set */0, - _0: single(c) - }, - tl: { - hd: { - TAG: /* Set */0, - _0: { - hd: [ - /* '-' */45, - /* '-' */45 - ], - tl: /* [] */0 - } - }, - tl: s - } - }; - } - const match$1 = $$char(undefined); - if (match$1.NAME !== "Char") { - return { - hd: { - TAG: /* Set */0, - _0: single(c) - }, - tl: { - hd: { - TAG: /* Set */0, - _0: { - hd: [ - /* '-' */45, - /* '-' */45 - ], - tl: /* [] */0 - } - }, - tl: { - hd: match$1.VAL, - tl: s - } - } - }; - } - _s = { - hd: { - TAG: /* Set */0, - _0: seq(c, match$1.VAL) - }, - tl: s - }; - continue ; - } - _s = { - hd: { - TAG: /* Set */0, - _0: single(c) - }, - tl: s - }; - continue ; + const atom = function (param) { + if (accept(/* '.' */46)) { + if (dotall) { + return any; + } else { + return notnl; } - _s = { - hd: match.VAL, - tl: s - }; - continue ; - }; - }; - const $$char = function (param) { - if (i.contents === l) { - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); } - const c = get(undefined); - if (c === /* '[' */91) { - if (accept(/* '=' */61)) { - throw new Caml_js_exceptions.MelangeError(Not_supported, { - MEL_EXN_ID: Not_supported - }); - } - if (accept(/* ':' */58)) { - const compl$1 = accept(/* '^' */94); - let cls; - try { - cls = Stdlib__List.find(accept_s, { - hd: "alnum", - tl: { - hd: "ascii", - tl: { - hd: "blank", - tl: { - hd: "cntrl", - tl: { - hd: "digit", - tl: { - hd: "lower", - tl: { - hd: "print", - tl: { - hd: "space", - tl: { - hd: "upper", - tl: { - hd: "word", - tl: { - hd: "punct", - tl: { - hd: "graph", - tl: { - hd: "xdigit", - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - }); - } - catch (raw_exn){ - const exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.MEL_EXN_ID === Stdlib.Not_found) { + if (accept(/* '(' */40)) { + if (accept(/* '?' */63)) { + if (accept(/* ':' */58)) { + const r = regexp$p(branch$p(/* [] */0)); + if (!accept(/* ')' */41)) { throw new Caml_js_exceptions.MelangeError(Parse_error, { MEL_EXN_ID: Parse_error }); } - throw new Caml_js_exceptions.MelangeError(exn.MEL_EXN_ID, exn); + return r; } - if (!accept_s(":]")) { - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); + if (accept(/* '#' */35)) { + let _param; + while(true) { + if (accept(/* ')' */41)) { + return epsilon; + } + i.contents = i.contents + 1 | 0; + _param = undefined; + continue ; + }; } - const posix_class = posix_class_of_string(cls); - const re = compl$1 ? compl({ - hd: posix_class, - tl: /* [] */0 - }) : posix_class; - return { - NAME: "Set", - VAL: re - }; - } - if (!accept(/* '.' */46)) { - return { - NAME: "Char", - VAL: c - }; - } - if (i.contents === l) { throw new Caml_js_exceptions.MelangeError(Parse_error, { MEL_EXN_ID: Parse_error }); } - const c$1 = get(undefined); - if (!accept(/* '.' */46)) { - throw new Caml_js_exceptions.MelangeError(Not_supported, { - MEL_EXN_ID: Not_supported - }); - } - if (!accept(/* ']' */93)) { + const r$1 = regexp$p(branch$p(/* [] */0)); + if (!accept(/* ')' */41)) { throw new Caml_js_exceptions.MelangeError(Parse_error, { MEL_EXN_ID: Parse_error }); } return { - NAME: "Char", - VAL: c$1 + TAG: /* Group */6, + _0: r$1 }; } - if (c !== /* '\\' */92) { - return { - NAME: "Char", - VAL: c - }; + if (accept(/* '^' */94)) { + if (multiline) { + return /* Beg_of_line */0; + } else { + return /* Beg_of_str */5; + } } - const c$2 = get(undefined); - if (c$2 >= 58) { - if (c$2 >= 123) { - return { - NAME: "Char", - VAL: c$2 - }; + if (accept(/* '$' */36)) { + if (multiline) { + return /* End_of_line */1; + } else if (dollar_endonly) { + return /* Last_end_of_line */7; + } else { + return /* End_of_str */6; } - switch (c$2) { + } + if (accept(/* '[' */91)) { + if (accept(/* '^' */94)) { + return compl(bracket(/* [] */0)); + } else { + return alt$1(bracket(/* [] */0)); + } + } + if (accept(/* '\\' */92)) { + if (i.contents === l) { + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); + } + const c = get(undefined); + switch (c) { + case 48 : + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + throw new Caml_js_exceptions.MelangeError(Not_supported, { + MEL_EXN_ID: Not_supported + }); + case 65 : + return /* Beg_of_str */5; + case 66 : + return /* Not_bound */4; case 68 : - return { - NAME: "Set", - VAL: compl({ - hd: digit, - tl: /* [] */0 - }) - }; + return compl({ + hd: digit, + tl: /* [] */0 + }); + case 71 : + return /* Start */8; case 83 : - return { - NAME: "Set", - VAL: compl({ - hd: space, - tl: /* [] */0 - }) - }; + return compl({ + hd: space, + tl: /* [] */0 + }); case 87 : - return { - NAME: "Set", - VAL: compl({ - hd: alnum, - tl: { - hd: { - TAG: /* Set */0, - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }) - }; + return compl({ + hd: alnum, + tl: { + hd: { + TAG: /* Set */0, + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }); + case 90 : + return /* Last_end_of_line */7; case 58 : case 59 : case 60 : @@ -3652,65 +3522,41 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 95 : case 96 : return { - NAME: "Char", - VAL: c$2 + TAG: /* Set */0, + _0: single(c) }; case 98 : - return { - NAME: "Char", - VAL: /* '\b' */8 - }; + return alt$1({ + hd: /* Beg_of_word */2, + tl: { + hd: /* End_of_word */3, + tl: /* [] */0 + } + }); case 100 : - return { - NAME: "Set", - VAL: digit - }; - case 110 : - return { - NAME: "Char", - VAL: /* '\n' */10 - }; - case 114 : - return { - NAME: "Char", - VAL: /* '\r' */13 - }; + return digit; case 115 : - return { - NAME: "Set", - VAL: space - }; - case 116 : - return { - NAME: "Char", - VAL: /* '\t' */9 - }; + return space; case 119 : - return { - NAME: "Set", - VAL: alt$1({ - hd: alnum, - tl: { - hd: { - TAG: /* Set */0, - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }) - }; - case 65 : - case 66 : + return alt$1({ + hd: alnum, + tl: { + hd: { + TAG: /* Set */0, + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }); case 67 : case 69 : case 70 : - case 71 : case 72 : case 73 : case 74 : @@ -3727,7 +3573,6 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 86 : case 88 : case 89 : - case 90 : case 97 : case 99 : case 101 : @@ -3739,31 +3584,116 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 107 : case 108 : case 109 : + case 110 : case 111 : case 112 : case 113 : + case 114 : + case 116 : case 117 : case 118 : case 120 : case 121 : - case 122 : throw new Caml_js_exceptions.MelangeError(Parse_error, { MEL_EXN_ID: Parse_error }); - + case 122 : + return /* End_of_str */6; + default: + return { + TAG: /* Set */0, + _0: single(c) + }; } } else { - if (c$2 >= 48) { - throw new Caml_js_exceptions.MelangeError(Not_supported, { - MEL_EXN_ID: Not_supported + if (i.contents === l) { + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); + } + const c$1 = get(undefined); + if (c$1 >= 64) { + if (c$1 !== 92) { + if (c$1 !== 123) { + return { + TAG: /* Set */0, + _0: single(c$1) + }; + } + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); + } + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); + } + if (c$1 >= 44) { + if (c$1 >= 63) { + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); + } + return { + TAG: /* Set */0, + _0: single(c$1) + }; + } + if (c$1 >= 42) { + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error }); } return { - NAME: "Char", - VAL: c$2 + TAG: /* Set */0, + _0: single(c$1) }; } }; + const integer = function (param) { + if (i.contents === l) { + return ; + } + const d = get(undefined); + if (d > 57 || d < 48) { + i.contents = i.contents - 1 | 0; + return ; + } else { + let _i = d - /* '0' */48 | 0; + while(true) { + const i$1 = _i; + if (i.contents === l) { + return i$1; + } + const d$1 = get(undefined); + if (d$1 > 57 || d$1 < 48) { + i.contents = i.contents - 1 | 0; + return i$1; + } + const i$p = Math.imul(10, i$1) + (d$1 - /* '0' */48 | 0) | 0; + if (i$p < i$1) { + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); + } + _i = i$p; + continue ; + }; + } + }; + const branch$p = function (_left) { + while(true) { + const left = _left; + if (i.contents === l || test(/* '|' */124) || test(/* ')' */41)) { + return seq$2(Stdlib__List.rev(left)); + } + _left = { + hd: piece(undefined), + tl: left + }; + continue ; + }; + }; const regexp$p = function (_left) { while(true) { const left = _left; @@ -3780,6 +3710,87 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue ; }; }; + const bracket = function (_s) { + while(true) { + const s = _s; + if (Caml_obj.caml_notequal(s, /* [] */0) && accept(/* ']' */93)) { + return s; + } + const match = $$char(undefined); + if (match.NAME === "Char") { + const c = match.VAL; + if (accept(/* '-' */45)) { + if (accept(/* ']' */93)) { + return { + hd: { + TAG: /* Set */0, + _0: single(c) + }, + tl: { + hd: { + TAG: /* Set */0, + _0: { + hd: [ + /* '-' */45, + /* '-' */45 + ], + tl: /* [] */0 + } + }, + tl: s + } + }; + } + const match$1 = $$char(undefined); + if (match$1.NAME !== "Char") { + return { + hd: { + TAG: /* Set */0, + _0: single(c) + }, + tl: { + hd: { + TAG: /* Set */0, + _0: { + hd: [ + /* '-' */45, + /* '-' */45 + ], + tl: /* [] */0 + } + }, + tl: { + hd: match$1.VAL, + tl: s + } + } + }; + } + _s = { + hd: { + TAG: /* Set */0, + _0: seq(c, match$1.VAL) + }, + tl: s + }; + continue ; + } + _s = { + hd: { + TAG: /* Set */0, + _0: single(c) + }, + tl: s + }; + continue ; + } + _s = { + hd: match.VAL, + tl: s + }; + continue ; + }; + }; const piece = function (param) { const r = atom(undefined); if (accept(/* '*' */42)) { @@ -3812,161 +3823,166 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { i.contents = i.contents - 1 | 0; return r; }; - const integer = function (param) { + const $$char = function (param) { if (i.contents === l) { - return ; - } - const d = get(undefined); - if (d > 57 || d < 48) { - i.contents = i.contents - 1 | 0; - return ; - } else { - let _i = d - /* '0' */48 | 0; - while(true) { - const i$1 = _i; - if (i.contents === l) { - return i$1; - } - const d$1 = get(undefined); - if (d$1 > 57 || d$1 < 48) { - i.contents = i.contents - 1 | 0; - return i$1; - } - const i$p = Math.imul(10, i$1) + (d$1 - /* '0' */48 | 0) | 0; - if (i$p < i$1) { - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); - } - _i = i$p; - continue ; - }; + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); } - }; - const atom = function (param) { - if (accept(/* '.' */46)) { - if (dotall) { - return any; - } else { - return notnl; + const c = get(undefined); + if (c === /* '[' */91) { + if (accept(/* '=' */61)) { + throw new Caml_js_exceptions.MelangeError(Not_supported, { + MEL_EXN_ID: Not_supported + }); } - } - if (accept(/* '(' */40)) { - if (accept(/* '?' */63)) { - if (accept(/* ':' */58)) { - const r = regexp$p(branch$p(/* [] */0)); - if (!accept(/* ')' */41)) { + if (accept(/* ':' */58)) { + const compl$1 = accept(/* '^' */94); + let cls; + try { + cls = Stdlib__List.find(accept_s, { + hd: "alnum", + tl: { + hd: "ascii", + tl: { + hd: "blank", + tl: { + hd: "cntrl", + tl: { + hd: "digit", + tl: { + hd: "lower", + tl: { + hd: "print", + tl: { + hd: "space", + tl: { + hd: "upper", + tl: { + hd: "word", + tl: { + hd: "punct", + tl: { + hd: "graph", + tl: { + hd: "xdigit", + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + }); + } + catch (raw_exn){ + const exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.MEL_EXN_ID === Stdlib.Not_found) { throw new Caml_js_exceptions.MelangeError(Parse_error, { MEL_EXN_ID: Parse_error }); } - return r; + throw new Caml_js_exceptions.MelangeError(exn.MEL_EXN_ID, exn); } - if (accept(/* '#' */35)) { - let _param; - while(true) { - if (accept(/* ')' */41)) { - return epsilon; - } - i.contents = i.contents + 1 | 0; - _param = undefined; - continue ; - }; + if (!accept_s(":]")) { + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); } - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); - } - const r$1 = regexp$p(branch$p(/* [] */0)); - if (!accept(/* ')' */41)) { - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); - } - return { - TAG: /* Group */6, - _0: r$1 - }; - } - if (accept(/* '^' */94)) { - if (multiline) { - return /* Beg_of_line */0; - } else { - return /* Beg_of_str */5; - } - } - if (accept(/* '$' */36)) { - if (multiline) { - return /* End_of_line */1; - } else if (dollar_endonly) { - return /* Last_end_of_line */7; - } else { - return /* End_of_str */6; - } - } - if (accept(/* '[' */91)) { - if (accept(/* '^' */94)) { - return compl(bracket(/* [] */0)); - } else { - return alt$1(bracket(/* [] */0)); + const posix_class = posix_class_of_string(cls); + const re = compl$1 ? compl({ + hd: posix_class, + tl: /* [] */0 + }) : posix_class; + return { + NAME: "Set", + VAL: re + }; + } + if (!accept(/* '.' */46)) { + return { + NAME: "Char", + VAL: c + }; } - } - if (accept(/* '\\' */92)) { if (i.contents === l) { throw new Caml_js_exceptions.MelangeError(Parse_error, { MEL_EXN_ID: Parse_error }); } - const c = get(undefined); - switch (c) { - case 48 : - case 49 : - case 50 : - case 51 : - case 52 : - case 53 : - case 54 : - case 55 : - case 56 : - case 57 : - throw new Caml_js_exceptions.MelangeError(Not_supported, { - MEL_EXN_ID: Not_supported - }); - case 65 : - return /* Beg_of_str */5; - case 66 : - return /* Not_bound */4; + const c$1 = get(undefined); + if (!accept(/* '.' */46)) { + throw new Caml_js_exceptions.MelangeError(Not_supported, { + MEL_EXN_ID: Not_supported + }); + } + if (!accept(/* ']' */93)) { + throw new Caml_js_exceptions.MelangeError(Parse_error, { + MEL_EXN_ID: Parse_error + }); + } + return { + NAME: "Char", + VAL: c$1 + }; + } + if (c !== /* '\\' */92) { + return { + NAME: "Char", + VAL: c + }; + } + const c$2 = get(undefined); + if (c$2 >= 58) { + if (c$2 >= 123) { + return { + NAME: "Char", + VAL: c$2 + }; + } + switch (c$2) { case 68 : - return compl({ - hd: digit, - tl: /* [] */0 - }); - case 71 : - return /* Start */8; + return { + NAME: "Set", + VAL: compl({ + hd: digit, + tl: /* [] */0 + }) + }; case 83 : - return compl({ - hd: space, - tl: /* [] */0 - }); - case 87 : - return compl({ - hd: alnum, - tl: { - hd: { - TAG: /* Set */0, - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, + return { + NAME: "Set", + VAL: compl({ + hd: space, tl: /* [] */0 - } - }); - case 90 : - return /* Last_end_of_line */7; + }) + }; + case 87 : + return { + NAME: "Set", + VAL: compl({ + hd: alnum, + tl: { + hd: { + TAG: /* Set */0, + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }) + }; case 58 : case 59 : case 60 : @@ -3981,41 +3997,65 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 95 : case 96 : return { - TAG: /* Set */0, - _0: single(c) + NAME: "Char", + VAL: c$2 }; case 98 : - return alt$1({ - hd: /* Beg_of_word */2, - tl: { - hd: /* End_of_word */3, - tl: /* [] */0 - } - }); + return { + NAME: "Char", + VAL: /* '\b' */8 + }; case 100 : - return digit; + return { + NAME: "Set", + VAL: digit + }; + case 110 : + return { + NAME: "Char", + VAL: /* '\n' */10 + }; + case 114 : + return { + NAME: "Char", + VAL: /* '\r' */13 + }; case 115 : - return space; + return { + NAME: "Set", + VAL: space + }; + case 116 : + return { + NAME: "Char", + VAL: /* '\t' */9 + }; case 119 : - return alt$1({ - hd: alnum, - tl: { - hd: { - TAG: /* Set */0, - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }); + return { + NAME: "Set", + VAL: alt$1({ + hd: alnum, + tl: { + hd: { + TAG: /* Set */0, + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }) + }; + case 65 : + case 66 : case 67 : case 69 : case 70 : + case 71 : case 72 : case 73 : case 74 : @@ -4032,6 +4072,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 86 : case 88 : case 89 : + case 90 : case 97 : case 99 : case 101 : @@ -4043,69 +4084,28 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 107 : case 108 : case 109 : - case 110 : case 111 : case 112 : case 113 : - case 114 : - case 116 : case 117 : case 118 : case 120 : case 121 : + case 122 : throw new Caml_js_exceptions.MelangeError(Parse_error, { MEL_EXN_ID: Parse_error }); - case 122 : - return /* End_of_str */6; - default: - return { - TAG: /* Set */0, - _0: single(c) - }; + } } else { - if (i.contents === l) { - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); - } - const c$1 = get(undefined); - if (c$1 >= 64) { - if (c$1 !== 92) { - if (c$1 !== 123) { - return { - TAG: /* Set */0, - _0: single(c$1) - }; - } - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); - } - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); - } - if (c$1 >= 44) { - if (c$1 >= 63) { - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error - }); - } - return { - TAG: /* Set */0, - _0: single(c$1) - }; - } - if (c$1 >= 42) { - throw new Caml_js_exceptions.MelangeError(Parse_error, { - MEL_EXN_ID: Parse_error + if (c$2 >= 48) { + throw new Caml_js_exceptions.MelangeError(Not_supported, { + MEL_EXN_ID: Not_supported }); } return { - TAG: /* Set */0, - _0: single(c$1) + NAME: "Char", + VAL: c$2 }; } }; diff --git a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js index 99e75c1c5..bcb569249 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js @@ -13952,35 +13952,6 @@ function store_module(slot, id, path, md, env, renv) { }; } -function check_usage(loc, id, warn, tbl) { - if (!(!loc.loc_ghost && is_active(Curry._1(warn, "")))) { - return ; - } - const name = id.name; - const key = [ - name, - loc - ]; - if (Stdlib__Hashtbl.mem(tbl, key)) { - return ; - } - const 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 new Caml_js_exceptions.MelangeError($$Error$2, { @@ -14010,6 +13981,35 @@ function check_value_name(name, loc) { } } +function check_usage(loc, id, warn, tbl) { + if (!(!loc.loc_ghost && is_active(Curry._1(warn, "")))) { + return ; + } + const name = id.name; + const key = [ + name, + loc + ]; + if (Stdlib__Hashtbl.mem(tbl, key)) { + return ; + } + const 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 components_of_module_maker(param) { const sub = param[1]; const env = param[0]; @@ -23386,6 +23386,25 @@ function directive_parse(token_with_comments, lexbuf) { } }; + const parse_or_aux = function (calc, v) { + const e = token(undefined); + if (/* tag */typeof e === "number" || typeof e === "string") { + if (e === /* BARBAR */8) { + const calc$1 = calc && !v; + const 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; + } else { + push(e); + return v; + } + }; const parse_relation = function (calc) { const curr_token = token(undefined); const curr_loc = curr(lexbuf); @@ -23554,25 +23573,6 @@ function directive_parse(token_with_comments, lexbuf) { return v; } }; - const parse_or_aux = function (calc, v) { - const e = token(undefined); - if (/* tag */typeof e === "number" || typeof e === "string") { - if (e === /* BARBAR */8) { - const calc$1 = calc && !v; - const 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; - } else { - push(e); - return v; - } - }; const v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); const match = token(undefined); if (/* tag */typeof match === "number" || typeof match === "string") { @@ -24936,42 +24936,8 @@ function token(lexbuf) { }; } -function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __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 new Caml_js_exceptions.MelangeError($$Error$4, { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents - }); - case 2 : - const edelim = Stdlib__Lexing.lexeme(lexbuf); - const 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 string(lexbuf) { @@ -25030,10 +24996,6 @@ function string(lexbuf) { }; } -function comment(lexbuf) { - return __ocaml_lex_comment_rec(lexbuf, 132); -} - function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { while(true) { const __ocaml_lex_state = ___ocaml_lex_state; @@ -25216,6 +25178,44 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { }; } +function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __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 new Caml_js_exceptions.MelangeError($$Error$4, { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + }); + case 2 : + const edelim = Stdlib__Lexing.lexeme(lexbuf); + const 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 at_bol(lexbuf) { const pos = lexbuf.lex_start_p; return pos.pos_cnum === pos.pos_bol; @@ -26202,79 +26202,65 @@ function TypedtreeMap_MakeMap(funarg) { ctyp_attributes: ct$1.ctyp_attributes }); }; - const map_module_type = function (mty) { - const mty$1 = Curry._1(funarg.enter_module_type, mty); - const sg = mty$1.mty_desc; - let mty_desc; - switch (sg.TAG) { - case /* Tmty_signature */1 : - mty_desc = { - TAG: /* Tmty_signature */1, - _0: map_signature(sg._0) + const 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) + }; + } + }; + const map_package_type = function (pack) { + const pack$1 = Curry._1(funarg.enter_package_type, pack); + const 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 + }); + }; + const 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 + }; + }; + const map_expression = function (exp) { + const exp$1 = Curry._1(funarg.enter_expression, exp); + const list = exp$1.exp_desc; + let exp_desc; + switch (list.TAG) { + case /* Texp_let */2 : + const rec_flag = list._0; + exp_desc = { + TAG: /* Texp_let */2, + _0: rec_flag, + _1: Stdlib__List.map(map_binding, list._1), + _2: map_expression(list._2) }; break; - case /* Tmty_functor */2 : - mty_desc = { - TAG: /* Tmty_functor */2, - _0: sg._0, - _1: sg._1, - _2: may_map(map_module_type, sg._2), - _3: map_module_type(sg._3) - }; - break; - case /* Tmty_with */3 : - mty_desc = { - TAG: /* Tmty_with */3, - _0: map_module_type(sg._0), - _1: Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_with_constraint(param[2]) - ]; - }), sg._1) - }; - break; - case /* Tmty_typeof */4 : - mty_desc = { - TAG: /* Tmty_typeof */4, - _0: map_module_expr(sg._0) - }; - break; - case /* Tmty_ident */0 : - case /* Tmty_alias */5 : - mty_desc = mty$1.mty_desc; - break; - - } - return Curry._1(funarg.leave_module_type, { - mty_desc: mty_desc, - mty_type: mty$1.mty_type, - mty_env: mty$1.mty_env, - mty_loc: mty$1.mty_loc, - mty_attributes: mty$1.mty_attributes - }); - }; - const map_expression = function (exp) { - const exp$1 = Curry._1(funarg.enter_expression, exp); - const list = exp$1.exp_desc; - let exp_desc; - switch (list.TAG) { - case /* Texp_let */2 : - const rec_flag = list._0; - exp_desc = { - TAG: /* Texp_let */2, - _0: rec_flag, - _1: Stdlib__List.map(map_binding, list._1), - _2: map_expression(list._2) - }; - break; - case /* Texp_function */3 : - exp_desc = { - TAG: /* Texp_function */3, - _0: list._0, - _1: Stdlib__List.map(map_case, list._1), - _2: list._2 + case /* Texp_function */3 : + exp_desc = { + TAG: /* Texp_function */3, + _0: list._0, + _1: Stdlib__List.map(map_case, list._1), + _2: list._2 }; break; case /* Texp_apply */4 : @@ -26486,81 +26472,99 @@ function TypedtreeMap_MakeMap(funarg) { exp_attributes: exp$1.exp_attributes }); }; - const map_module_expr = function (mexpr) { - const mexpr$1 = Curry._1(funarg.enter_module_expr, mexpr); - const st = mexpr$1.mod_desc; - let mod_desc; - switch (st.TAG) { - case /* Tmod_ident */0 : - mod_desc = mexpr$1.mod_desc; + const map_class_expr = function (cexpr) { + const cexpr$1 = Curry._1(funarg.enter_class_expr, cexpr); + const clstr = cexpr$1.cl_desc; + let cl_desc; + switch (clstr.TAG) { + 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 /* Tmod_structure */1 : - mod_desc = { - TAG: /* Tmod_structure */1, - _0: map_structure(st._0) + case /* Tcl_structure */1 : + cl_desc = { + TAG: /* Tcl_structure */1, + _0: map_class_structure(clstr._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) + 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 }; 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 + case /* Tcl_apply */3 : + cl_desc = { + TAG: /* Tcl_apply */3, + _0: map_class_expr(clstr._0), + _1: Stdlib__List.map((function (param) { + return [ + param[0], + may_map(map_expression, param[1]), + param[2] + ]; + }), clstr._1) }; break; - case /* Tmod_constraint */4 : - const mtype = st._2; - const mod_type = st._1; - const mexpr$2 = st._0; - mod_desc = /* tag */typeof mtype === "number" || typeof mtype === "string" ? ({ - TAG: /* Tmod_constraint */4, - _0: map_module_expr(mexpr$2), - _1: mod_type, - _2: /* Tmodtype_implicit */0, - _3: st._3 + case /* Tcl_let */4 : + const rec_flat = clstr._0; + cl_desc = { + TAG: /* Tcl_let */4, + _0: rec_flat, + _1: Stdlib__List.map(map_binding, 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) + }; + break; + case /* Tcl_constraint */5 : + const clty = clstr._1; + const cl = clstr._0; + cl_desc = clty !== undefined ? ({ + TAG: /* Tcl_constraint */5, + _0: map_class_expr(cl), + _1: map_class_type(clty), + _2: clstr._2, + _3: clstr._3, + _4: clstr._4 }) : ({ - TAG: /* Tmod_constraint */4, - _0: map_module_expr(mexpr$2), - _1: mod_type, - _2: { - TAG: /* Tmodtype_explicit */0, - _0: map_module_type(mtype._0) - }, - _3: st._3 + TAG: /* Tcl_constraint */5, + _0: map_class_expr(cl), + _1: undefined, + _2: clstr._2, + _3: clstr._3, + _4: clstr._4 }); 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 + return Curry._1(funarg.leave_class_expr, { + cl_desc: cl_desc, + cl_loc: cexpr$1.cl_loc, + cl_type: cexpr$1.cl_type, + cl_env: cexpr$1.cl_env, + cl_attributes: cexpr$1.cl_attributes }); }; - const map_type_parameter = function (param) { - return [ - map_core_type(param[0]), - param[1] - ]; - }; const map_class_type = function (ct) { const ct$1 = Curry._1(funarg.enter_class_type, ct); const csg = ct$1.cltyp_desc; @@ -26598,68 +26602,92 @@ function TypedtreeMap_MakeMap(funarg) { cltyp_attributes: ct$1.cltyp_attributes }); }; - const map_with_constraint = function (cstr) { - const cstr$1 = Curry._1(funarg.enter_with_constraint, cstr); - let tmp; - switch (cstr$1.TAG) { - 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); - }; - const map_signature = function (sg) { - const sg$1 = Curry._1(funarg.enter_signature, sg); - const 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 - }); - }; - const 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) - }; + const map_pattern = function (pat) { + const pat$1 = Curry._1(funarg.enter_pattern, pat); + const list = pat$1.pat_desc; + let pat_desc; + if (/* tag */typeof list === "number" || typeof list === "string") { + pat_desc = pat$1.pat_desc; } else { - return { - TAG: /* Tinherit */1, - _0: map_core_type(rf._0) + switch (list.TAG) { + case /* Tpat_alias */1 : + const pat1 = map_pattern(list._0); + pat_desc = { + TAG: /* Tpat_alias */1, + _0: pat1, + _1: list._1, + _2: list._2 }; - } - }; - const map_package_type = function (pack) { - const pack$1 = Curry._1(funarg.enter_package_type, pack); - const 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 + break; + case /* Tpat_tuple */3 : + pat_desc = { + TAG: /* Tpat_tuple */3, + _0: Stdlib__List.map(map_pattern, list._0) + }; + break; + case /* Tpat_construct */4 : + pat_desc = { + TAG: /* Tpat_construct */4, + _0: list._0, + _1: list._1, + _2: Stdlib__List.map(map_pattern, list._2) + }; + break; + case /* Tpat_variant */5 : + const pato = list._1; + const pato$1 = pato !== undefined ? map_pattern(pato) : pato; + pat_desc = { + TAG: /* Tpat_variant */5, + _0: list._0, + _1: pato$1, + _2: list._2 + }; + break; + case /* Tpat_record */6 : + pat_desc = { + TAG: /* Tpat_record */6, + _0: Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_pattern(param[2]) + ]; + }), list._0), + _1: list._1 + }; + break; + case /* Tpat_array */7 : + pat_desc = { + TAG: /* Tpat_array */7, + _0: Stdlib__List.map(map_pattern, list._0) + }; + break; + case /* Tpat_or */8 : + pat_desc = { + TAG: /* Tpat_or */8, + _0: map_pattern(list._0), + _1: map_pattern(list._1), + _2: list._2 + }; + break; + case /* Tpat_lazy */9 : + pat_desc = { + TAG: /* Tpat_lazy */9, + _0: map_pattern(list._0) + }; + break; + default: + pat_desc = pat$1.pat_desc; + } + } + const pat_extra = Stdlib__List.map(map_pat_extra, pat$1.pat_extra); + return Curry._1(funarg.leave_pattern, { + pat_desc: pat_desc, + pat_loc: pat$1.pat_loc, + pat_extra: pat_extra, + pat_type: pat$1.pat_type, + pat_env: pat$1.pat_env, + pat_attributes: pat$1.pat_attributes }); }; const map_class_structure = function (cs) { @@ -26673,87 +26701,11 @@ function TypedtreeMap_MakeMap(funarg) { cstr_meths: cs$1.cstr_meths }); }; - const 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) - }; - }; - const 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 - }; - }; - const map_exp_extra = function (exp_extra) { - const attrs = exp_extra[2]; - const loc = exp_extra[1]; - const desc = exp_extra[0]; - switch (desc.TAG) { - case /* Texp_constraint */0 : - return [ - { - TAG: /* Texp_constraint */0, - _0: map_core_type(desc._0) - }, - loc, - attrs - ]; - case /* Texp_coerce */1 : - const ct1 = desc._0; - if (ct1 !== undefined) { - return [ - { - TAG: /* Texp_coerce */1, - _0: map_core_type(ct1), - _1: map_core_type(desc._1) - }, - loc, - attrs - ]; - } else { - return [ - { - TAG: /* Texp_coerce */1, - _0: undefined, - _1: map_core_type(desc._1) - }, - loc, - attrs - ]; - } - case /* Texp_poly */3 : - const ct = desc._0; - if (ct !== undefined) { - return [ - { - TAG: /* Texp_poly */3, - _0: map_core_type(ct) - }, - loc, - attrs - ]; - } else { - return exp_extra; - } - case /* Texp_open */2 : - case /* Texp_newtype */4 : - return exp_extra; - - } - }; - const 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 - }; + const map_type_parameter = function (param) { + return [ + map_core_type(param[0]), + param[1] + ]; }; const map_class_field = function (cf) { const cf$1 = Curry._1(funarg.enter_class_field, cf); @@ -26845,100 +26797,370 @@ function TypedtreeMap_MakeMap(funarg) { cf_attributes: cf$1.cf_attributes }); }; - const map_pattern = function (pat) { - const pat$1 = Curry._1(funarg.enter_pattern, pat); - const list = pat$1.pat_desc; - let pat_desc; - if (/* tag */typeof list === "number" || typeof list === "string") { - pat_desc = pat$1.pat_desc; - } else { - switch (list.TAG) { - case /* Tpat_alias */1 : - const pat1 = map_pattern(list._0); - pat_desc = { - TAG: /* Tpat_alias */1, - _0: pat1, - _1: list._1, - _2: list._2 - }; - break; - case /* Tpat_tuple */3 : - pat_desc = { - TAG: /* Tpat_tuple */3, - _0: Stdlib__List.map(map_pattern, list._0) - }; - break; - case /* Tpat_construct */4 : - pat_desc = { - TAG: /* Tpat_construct */4, - _0: list._0, - _1: list._1, - _2: Stdlib__List.map(map_pattern, list._2) - }; - break; - case /* Tpat_variant */5 : - const pato = list._1; - const pato$1 = pato !== undefined ? map_pattern(pato) : pato; - pat_desc = { - TAG: /* Tpat_variant */5, - _0: list._0, - _1: pato$1, - _2: list._2 - }; - break; - case /* Tpat_record */6 : - pat_desc = { - TAG: /* Tpat_record */6, - _0: Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_pattern(param[2]) - ]; - }), list._0), - _1: list._1 - }; - break; - case /* Tpat_array */7 : - pat_desc = { - TAG: /* Tpat_array */7, - _0: Stdlib__List.map(map_pattern, list._0) - }; - break; - case /* Tpat_or */8 : - pat_desc = { - TAG: /* Tpat_or */8, - _0: map_pattern(list._0), - _1: map_pattern(list._1), - _2: list._2 - }; - break; - case /* Tpat_lazy */9 : - pat_desc = { - TAG: /* Tpat_lazy */9, - _0: map_pattern(list._0) - }; - break; - default: - pat_desc = pat$1.pat_desc; - } - } - const pat_extra = Stdlib__List.map(map_pat_extra, pat$1.pat_extra); - return Curry._1(funarg.leave_pattern, { - pat_desc: pat_desc, - pat_loc: pat$1.pat_loc, - pat_extra: pat_extra, - pat_type: pat$1.pat_type, - pat_env: pat$1.pat_env, - pat_attributes: pat$1.pat_attributes - }); - }; - const map_signature_item = function (item) { - const item$1 = Curry._1(funarg.enter_signature_item, item); - const vd = item$1.sig_desc; - let sig_desc; - switch (vd.TAG) { - case /* Tsig_value */0 : + const map_structure_item = function (item) { + const item$1 = Curry._1(funarg.enter_structure_item, item); + const vd = item$1.str_desc; + let str_desc; + switch (vd.TAG) { + case /* Tstr_eval */0 : + str_desc = { + TAG: /* Tstr_eval */0, + _0: map_expression(vd._0), + _1: vd._1 + }; + break; + case /* Tstr_value */1 : + const rec_flag = vd._0; + str_desc = { + TAG: /* Tstr_value */1, + _0: rec_flag, + _1: Stdlib__List.map(map_binding, vd._1) + }; + break; + case /* Tstr_primitive */2 : + str_desc = { + TAG: /* Tstr_primitive */2, + _0: map_value_description(vd._0) + }; + break; + case /* Tstr_type */3 : + str_desc = { + TAG: /* Tstr_type */3, + _0: Stdlib__List.map(map_type_declaration, vd._0) + }; + break; + case /* Tstr_typext */4 : + str_desc = { + TAG: /* Tstr_typext */4, + _0: map_type_extension(vd._0) + }; + break; + case /* Tstr_exception */5 : + str_desc = { + TAG: /* Tstr_exception */5, + _0: map_extension_constructor(vd._0) + }; + break; + case /* Tstr_module */6 : + str_desc = { + TAG: /* Tstr_module */6, + _0: map_module_binding(vd._0) + }; + break; + case /* Tstr_recmodule */7 : + const list = Stdlib__List.map(map_module_binding, vd._0); + str_desc = { + TAG: /* Tstr_recmodule */7, + _0: list + }; + break; + case /* Tstr_modtype */8 : + str_desc = { + TAG: /* Tstr_modtype */8, + _0: map_module_type_declaration(vd._0) + }; + break; + case /* Tstr_open */9 : + str_desc = { + TAG: /* Tstr_open */9, + _0: vd._0 + }; + break; + case /* Tstr_class */10 : + const list$1 = Stdlib__List.map((function (param) { + return [ + map_class_declaration(param[0]), + param[1], + param[2] + ]; + }), vd._0); + str_desc = { + TAG: /* Tstr_class */10, + _0: list$1 + }; + break; + case /* Tstr_class_type */11 : + const list$2 = Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_class_type_declaration(param[2]) + ]; + }), vd._0); + str_desc = { + TAG: /* Tstr_class_type */11, + _0: list$2 + }; + break; + case /* Tstr_include */12 : + const incl = vd._0; + str_desc = { + TAG: /* Tstr_include */12, + _0: { + incl_mod: map_module_expr(incl.incl_mod), + incl_type: incl.incl_type, + incl_loc: incl.incl_loc, + incl_attributes: incl.incl_attributes + } + }; + break; + case /* Tstr_attribute */13 : + str_desc = { + TAG: /* Tstr_attribute */13, + _0: vd._0 + }; + break; + + } + return Curry._1(funarg.leave_structure_item, { + str_desc: str_desc, + str_loc: item$1.str_loc, + str_env: item$1.str_env + }); + }; + const map_class_type_field = function (ctf) { + const ctf$1 = Curry._1(funarg.enter_class_type_field, ctf); + const ct = ctf$1.ctf_desc; + let ctf_desc; + switch (ct.TAG) { + case /* Tctf_inherit */0 : + ctf_desc = { + TAG: /* Tctf_inherit */0, + _0: map_class_type(ct._0) + }; + break; + case /* Tctf_val */1 : + const 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 : + const 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 : + const 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 + }); + }; + const 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 + }; + }; + const 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) + }; + }; + const map_module_expr = function (mexpr) { + const mexpr$1 = Curry._1(funarg.enter_module_expr, mexpr); + const st = mexpr$1.mod_desc; + let mod_desc; + switch (st.TAG) { + 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 : + const mtype = st._2; + const mod_type = st._1; + const mexpr$2 = st._0; + mod_desc = /* tag */typeof mtype === "number" || typeof mtype === "string" ? ({ + TAG: /* Tmod_constraint */4, + _0: map_module_expr(mexpr$2), + _1: mod_type, + _2: /* Tmodtype_implicit */0, + _3: st._3 + }) : ({ + TAG: /* Tmod_constraint */4, + _0: map_module_expr(mexpr$2), + _1: mod_type, + _2: { + TAG: /* Tmodtype_explicit */0, + _0: map_module_type(mtype._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 + }); + }; + const map_exp_extra = function (exp_extra) { + const attrs = exp_extra[2]; + const loc = exp_extra[1]; + const desc = exp_extra[0]; + switch (desc.TAG) { + case /* Texp_constraint */0 : + return [ + { + TAG: /* Texp_constraint */0, + _0: map_core_type(desc._0) + }, + loc, + attrs + ]; + case /* Texp_coerce */1 : + const ct1 = desc._0; + if (ct1 !== undefined) { + return [ + { + TAG: /* Texp_coerce */1, + _0: map_core_type(ct1), + _1: map_core_type(desc._1) + }, + loc, + attrs + ]; + } else { + return [ + { + TAG: /* Texp_coerce */1, + _0: undefined, + _1: map_core_type(desc._1) + }, + loc, + attrs + ]; + } + case /* Texp_poly */3 : + const ct = desc._0; + if (ct !== undefined) { + return [ + { + TAG: /* Texp_poly */3, + _0: map_core_type(ct) + }, + loc, + attrs + ]; + } else { + return exp_extra; + } + case /* Texp_open */2 : + case /* Texp_newtype */4 : + return exp_extra; + + } + }; + const map_class_signature = function (cs) { + const cs$1 = Curry._1(funarg.enter_class_signature, cs); + const csig_self = map_core_type(cs$1.csig_self); + const 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 + }); + }; + const map_extension_constructor = function (ext) { + const ext$1 = Curry._1(funarg.enter_extension_constructor, ext); + const match = ext$1.ext_kind; + let ext_kind; + if (match.TAG === /* Text_decl */0) { + const args = Stdlib__List.map(map_core_type, match._0); + const 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 + }); + }; + const map_signature_item = function (item) { + const item$1 = Curry._1(funarg.enter_signature_item, item); + const vd = item$1.sig_desc; + let sig_desc; + switch (vd.TAG) { + case /* Tsig_value */0 : sig_desc = { TAG: /* Tsig_value */0, _0: map_value_description(vd._0) @@ -27033,140 +27255,57 @@ function TypedtreeMap_MakeMap(funarg) { sig_loc: item$1.sig_loc }); }; - const map_class_expr = function (cexpr) { - const cexpr$1 = Curry._1(funarg.enter_class_expr, cexpr); - const clstr = cexpr$1.cl_desc; - let cl_desc; - switch (clstr.TAG) { - 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) + const map_module_type = function (mty) { + const mty$1 = Curry._1(funarg.enter_module_type, mty); + const sg = mty$1.mty_desc; + let mty_desc; + switch (sg.TAG) { + case /* Tmty_signature */1 : + mty_desc = { + TAG: /* Tmty_signature */1, + _0: map_signature(sg._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 + case /* Tmty_functor */2 : + mty_desc = { + TAG: /* Tmty_functor */2, + _0: sg._0, + _1: sg._1, + _2: may_map(map_module_type, sg._2), + _3: map_module_type(sg._3) }; break; - case /* Tcl_apply */3 : - cl_desc = { - TAG: /* Tcl_apply */3, - _0: map_class_expr(clstr._0), + case /* Tmty_with */3 : + mty_desc = { + TAG: /* Tmty_with */3, + _0: map_module_type(sg._0), _1: Stdlib__List.map((function (param) { return [ param[0], - may_map(map_expression, param[1]), - param[2] + param[1], + map_with_constraint(param[2]) ]; - }), clstr._1) + }), sg._1) }; break; - case /* Tcl_let */4 : - const rec_flat = clstr._0; - cl_desc = { - TAG: /* Tcl_let */4, - _0: rec_flat, - _1: Stdlib__List.map(map_binding, 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) + case /* Tmty_typeof */4 : + mty_desc = { + TAG: /* Tmty_typeof */4, + _0: map_module_expr(sg._0) }; break; - case /* Tcl_constraint */5 : - const clty = clstr._1; - const cl = clstr._0; - cl_desc = clty !== undefined ? ({ - TAG: /* Tcl_constraint */5, - _0: map_class_expr(cl), - _1: map_class_type(clty), - _2: clstr._2, - _3: clstr._3, - _4: clstr._4 - }) : ({ - TAG: /* Tcl_constraint */5, - _0: map_class_expr(cl), - _1: undefined, - _2: clstr._2, - _3: clstr._3, - _4: clstr._4 - }); + case /* Tmty_ident */0 : + case /* Tmty_alias */5 : + mty_desc = mty$1.mty_desc; break; } - return Curry._1(funarg.leave_class_expr, { - cl_desc: cl_desc, - cl_loc: cexpr$1.cl_loc, - cl_type: cexpr$1.cl_type, - cl_env: cexpr$1.cl_env, - cl_attributes: cexpr$1.cl_attributes - }); - }; - const map_pat_extra = function (pat_extra) { - const ct = pat_extra[0]; - if (/* tag */typeof ct === "number" || typeof ct === "string" || 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] - ]; - } - }; - const map_extension_constructor = function (ext) { - const ext$1 = Curry._1(funarg.enter_extension_constructor, ext); - const match = ext$1.ext_kind; - let ext_kind; - if (match.TAG === /* Text_decl */0) { - const args = Stdlib__List.map(map_core_type, match._0); - const 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 + return Curry._1(funarg.leave_module_type, { + mty_desc: mty_desc, + mty_type: mty$1.mty_type, + mty_env: mty$1.mty_env, + mty_loc: mty$1.mty_loc, + mty_attributes: mty$1.mty_attributes }); }; const map_type_declaration = function (decl) { @@ -27219,6 +27358,49 @@ function TypedtreeMap_MakeMap(funarg) { typ_attributes: decl$1.typ_attributes }); }; + const map_with_constraint = function (cstr) { + const cstr$1 = Curry._1(funarg.enter_with_constraint, cstr); + let tmp; + switch (cstr$1.TAG) { + 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); + }; + const map_signature = function (sg) { + const sg$1 = Curry._1(funarg.enter_signature, sg); + const 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 + }); + }; + const map_module_type_declaration = function (mtd) { + const 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 + }); + }; const map_value_description = function (v) { const v$1 = Curry._1(funarg.enter_value_description, v); const val_desc = map_core_type(v$1.val_desc); @@ -27251,19 +27433,6 @@ function TypedtreeMap_MakeMap(funarg) { ci_attributes: cd$1.ci_attributes }); }; - const map_type_extension = function (tyext) { - const tyext$1 = Curry._1(funarg.enter_type_extension, tyext); - const tyext_params = Stdlib__List.map(map_type_parameter, tyext$1.tyext_params); - const 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 - }); - }; const map_class_type_declaration = function (cd) { const cd$1 = Curry._1(funarg.enter_class_type_declaration, cd); const ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); @@ -27283,136 +27452,33 @@ function TypedtreeMap_MakeMap(funarg) { ci_attributes: cd$1.ci_attributes }); }; - const map_module_type_declaration = function (mtd) { - const 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 + const map_type_extension = function (tyext) { + const tyext$1 = Curry._1(funarg.enter_type_extension, tyext); + const tyext_params = Stdlib__List.map(map_type_parameter, tyext$1.tyext_params); + const 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 }); }; - const map_structure_item = function (item) { - const item$1 = Curry._1(funarg.enter_structure_item, item); - const vd = item$1.str_desc; - let str_desc; - switch (vd.TAG) { - case /* Tstr_eval */0 : - str_desc = { - TAG: /* Tstr_eval */0, - _0: map_expression(vd._0), - _1: vd._1 - }; - break; - case /* Tstr_value */1 : - const rec_flag = vd._0; - str_desc = { - TAG: /* Tstr_value */1, - _0: rec_flag, - _1: Stdlib__List.map(map_binding, vd._1) - }; - break; - case /* Tstr_primitive */2 : - str_desc = { - TAG: /* Tstr_primitive */2, - _0: map_value_description(vd._0) - }; - break; - case /* Tstr_type */3 : - str_desc = { - TAG: /* Tstr_type */3, - _0: Stdlib__List.map(map_type_declaration, vd._0) - }; - break; - case /* Tstr_typext */4 : - str_desc = { - TAG: /* Tstr_typext */4, - _0: map_type_extension(vd._0) - }; - break; - case /* Tstr_exception */5 : - str_desc = { - TAG: /* Tstr_exception */5, - _0: map_extension_constructor(vd._0) - }; - break; - case /* Tstr_module */6 : - str_desc = { - TAG: /* Tstr_module */6, - _0: map_module_binding(vd._0) - }; - break; - case /* Tstr_recmodule */7 : - const list = Stdlib__List.map(map_module_binding, vd._0); - str_desc = { - TAG: /* Tstr_recmodule */7, - _0: list - }; - break; - case /* Tstr_modtype */8 : - str_desc = { - TAG: /* Tstr_modtype */8, - _0: map_module_type_declaration(vd._0) - }; - break; - case /* Tstr_open */9 : - str_desc = { - TAG: /* Tstr_open */9, - _0: vd._0 - }; - break; - case /* Tstr_class */10 : - const list$1 = Stdlib__List.map((function (param) { - return [ - map_class_declaration(param[0]), - param[1], - param[2] - ]; - }), vd._0); - str_desc = { - TAG: /* Tstr_class */10, - _0: list$1 - }; - break; - case /* Tstr_class_type */11 : - const list$2 = Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_class_type_declaration(param[2]) - ]; - }), vd._0); - str_desc = { - TAG: /* Tstr_class_type */11, - _0: list$2 - }; - break; - case /* Tstr_include */12 : - const incl = vd._0; - str_desc = { - TAG: /* Tstr_include */12, - _0: { - incl_mod: map_module_expr(incl.incl_mod), - incl_type: incl.incl_type, - incl_loc: incl.incl_loc, - incl_attributes: incl.incl_attributes - } - }; - break; - case /* Tstr_attribute */13 : - str_desc = { - TAG: /* Tstr_attribute */13, - _0: vd._0 - }; - break; - + const map_pat_extra = function (pat_extra) { + const ct = pat_extra[0]; + if (/* tag */typeof ct === "number" || typeof ct === "string" || 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] + ]; } - return Curry._1(funarg.leave_structure_item, { - str_desc: str_desc, - str_loc: item$1.str_loc, - str_env: item$1.str_env - }); }; const map_class_declaration = function (cd) { const cd$1 = Curry._1(funarg.enter_class_declaration, cd); @@ -27428,86 +27494,20 @@ function TypedtreeMap_MakeMap(funarg) { 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 - }); - }; - const 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 - }; - }; - const map_class_signature = function (cs) { - const cs$1 = Curry._1(funarg.enter_class_signature, cs); - const csig_self = map_core_type(cs$1.csig_self); - const 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 - }); - }; - const map_class_type_field = function (ctf) { - const ctf$1 = Curry._1(funarg.enter_class_type_field, ctf); - const ct = ctf$1.ctf_desc; - let ctf_desc; - switch (ct.TAG) { - case /* Tctf_inherit */0 : - ctf_desc = { - TAG: /* Tctf_inherit */0, - _0: map_class_type(ct._0) - }; - break; - case /* Tctf_val */1 : - const 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 : - const 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 : - const 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 + ci_type_decl: cd$1.ci_type_decl, + ci_loc: cd$1.ci_loc, + ci_attributes: cd$1.ci_attributes }); }; + const 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 + }; + }; return { map_structure: map_structure, map_pattern: map_pattern, @@ -33075,90 +33075,6 @@ function unify(env, t1, t2) { } } -function unify_fields(env, ty1, ty2) { - const match = flatten_fields(ty1); - const rest1 = match[1]; - const match$1 = flatten_fields(ty2); - const rest2 = match$1[1]; - const match$2 = associate_fields(match[0], match$1[0]); - const miss2 = match$2[2]; - const miss1 = match$2[1]; - const l1 = repr(ty1).level; - const l2 = repr(ty2).level; - const va = make_rowvar(l1 < l2 ? l1 : l2, Caml_obj.caml_equal(miss2, /* [] */0), rest1, Caml_obj.caml_equal(miss1, /* [] */0), rest2); - const d1 = rest1.desc; - const 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) { - const t2 = param[4]; - const k2 = param[3]; - const t1 = param[2]; - const k1 = param[1]; - const 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_trace){ - const trace = Caml_js_exceptions.internalToOCamlException(raw_trace); - if (trace.MEL_EXN_ID === Unify) { - const desc_3 = newty2(current_level.contents, /* Tnil */0); - const desc = { - TAG: /* Tfield */5, - _0: n, - _1: k1, - _2: t1, - _3: desc_3 - }; - const desc_3$1 = newty2(current_level.contents, /* Tnil */0); - const desc$1 = { - TAG: /* Tfield */5, - _0: n, - _1: k2, - _2: t2, - _3: desc_3$1 - }; - throw new Caml_js_exceptions.MelangeError(Unify, { - MEL_EXN_ID: Unify, - _1: { - hd: [ - newty2(current_level.contents, desc), - newty2(current_level.contents, desc$1) - ], - tl: trace._1 - } - }); - } - throw new Caml_js_exceptions.MelangeError(trace.MEL_EXN_ID, trace); - } - }), match$2[0]); - } - catch (exn){ - log_type(rest1); - rest1.desc = d1; - log_type(rest2); - rest2.desc = d2; - throw new Caml_js_exceptions.MelangeError(exn.MEL_EXN_ID, exn); - } -} - -function unify_list(env, tl1, tl2) { - if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { - throw new Caml_js_exceptions.MelangeError(Unify, { - MEL_EXN_ID: Unify, - _1: /* [] */0 - }); - } - Stdlib__List.iter2((function (param, param$1) { - return unify(env, param, param$1); - }), tl1, tl2); -} - function unify_row(env, row1, row2) { const row1$1 = row_repr_aux(/* [] */0, row1); const row2$1 = row_repr_aux(/* [] */0, row2); @@ -33619,6 +33535,90 @@ function unify_row(env, row1, row2) { } } +function unify_list(env, tl1, tl2) { + if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { + throw new Caml_js_exceptions.MelangeError(Unify, { + MEL_EXN_ID: Unify, + _1: /* [] */0 + }); + } + Stdlib__List.iter2((function (param, param$1) { + return unify(env, param, param$1); + }), tl1, tl2); +} + +function unify_fields(env, ty1, ty2) { + const match = flatten_fields(ty1); + const rest1 = match[1]; + const match$1 = flatten_fields(ty2); + const rest2 = match$1[1]; + const match$2 = associate_fields(match[0], match$1[0]); + const miss2 = match$2[2]; + const miss1 = match$2[1]; + const l1 = repr(ty1).level; + const l2 = repr(ty2).level; + const va = make_rowvar(l1 < l2 ? l1 : l2, Caml_obj.caml_equal(miss2, /* [] */0), rest1, Caml_obj.caml_equal(miss1, /* [] */0), rest2); + const d1 = rest1.desc; + const 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) { + const t2 = param[4]; + const k2 = param[3]; + const t1 = param[2]; + const k1 = param[1]; + const 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_trace){ + const trace = Caml_js_exceptions.internalToOCamlException(raw_trace); + if (trace.MEL_EXN_ID === Unify) { + const desc_3 = newty2(current_level.contents, /* Tnil */0); + const desc = { + TAG: /* Tfield */5, + _0: n, + _1: k1, + _2: t1, + _3: desc_3 + }; + const desc_3$1 = newty2(current_level.contents, /* Tnil */0); + const desc$1 = { + TAG: /* Tfield */5, + _0: n, + _1: k2, + _2: t2, + _3: desc_3$1 + }; + throw new Caml_js_exceptions.MelangeError(Unify, { + MEL_EXN_ID: Unify, + _1: { + hd: [ + newty2(current_level.contents, desc), + newty2(current_level.contents, desc$1) + ], + tl: trace._1 + } + }); + } + throw new Caml_js_exceptions.MelangeError(trace.MEL_EXN_ID, trace); + } + }), match$2[0]); + } + catch (exn){ + log_type(rest1); + rest1.desc = d1; + log_type(rest2); + rest2.desc = d2; + throw new Caml_js_exceptions.MelangeError(exn.MEL_EXN_ID, exn); + } +} + function unify2(env, t1, t2) { const expand_both = function (_t1$p$p, _t2$p$p) { while(true) { @@ -34340,6 +34340,43 @@ function unify3(env, t1, t1$p, t2, t2$p) { } +function unify_kind(k1, k2) { + const k1$1 = field_kind_repr(k1); + const k2$1 = field_kind_repr(k2); + if (k1$1 === k2$1) { + return ; + } + if (/* tag */typeof k1$1 === "number" || typeof k1$1 === "string") { + if (k1$1 === /* Fpresent */0) { + if (!/* tag */(typeof k2$1 === "number" || typeof k2$1 === "string")) { + return set_kind(k2$1._0, k1$1); + } + if (k2$1 === /* Fpresent */0) { + return ; + } + + } + + } else { + const r = k1$1._0; + if (!/* tag */(typeof k2$1 === "number" || typeof k2$1 === "string")) { + return set_kind(r, k2$1); + } + if (k2$1 === /* Fpresent */0) { + return set_kind(r, k2$1); + } + + } + throw new Caml_js_exceptions.MelangeError("Assert_failure", { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32636, + 37 + ] + }); +} + function make_rowvar(level, use1, rest1, use2, rest2) { const set_name = function (ty, name) { const match = ty.desc; @@ -34397,56 +34434,19 @@ function make_rowvar(level, use1, rest1, use2, rest2) { name = name$1; } else { name = undefined; - } - } - } - if (use1) { - return rest1; - } else if (use2) { - return rest2; - } else { - return newty2(level, { - TAG: /* Tvar */0, - _0: name - }); - } -} - -function unify_kind(k1, k2) { - const k1$1 = field_kind_repr(k1); - const k2$1 = field_kind_repr(k2); - if (k1$1 === k2$1) { - return ; - } - if (/* tag */typeof k1$1 === "number" || typeof k1$1 === "string") { - if (k1$1 === /* Fpresent */0) { - if (!/* tag */(typeof k2$1 === "number" || typeof k2$1 === "string")) { - return set_kind(k2$1._0, k1$1); - } - if (k2$1 === /* Fpresent */0) { - return ; - } - - } - - } else { - const r = k1$1._0; - if (!/* tag */(typeof k2$1 === "number" || typeof k2$1 === "string")) { - return set_kind(r, k2$1); - } - if (k2$1 === /* Fpresent */0) { - return set_kind(r, k2$1); + } } - } - throw new Caml_js_exceptions.MelangeError("Assert_failure", { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32636, - 37 - ] - }); + if (use1) { + return rest1; + } else if (use2) { + return rest2; + } else { + return newty2(level, { + TAG: /* Tvar */0, + _0: name + }); + } } function unify$1(env, ty1, ty2) { @@ -41603,124 +41603,6 @@ 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 ; - } - const item = param.hd; - if (!param.tl) { - return Curry._2(out_sig_item.contents, ppf, item); - } - if (item.TAG === /* Osig_typext */2) { - const ext = item._0; - switch (item._1) { - case /* Oext_first */0 : - const gather_extensions = function (_acc, _items) { - while(true) { - const items = _items; - const acc = _acc; - if (!items) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - const match = items.hd; - if (match.TAG !== /* Osig_typext */2) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - const ext = match._0; - switch (match._1) { - case /* Oext_next */1 : - _items = items.tl; - _acc = { - hd: [ - ext.oext_name, - ext.oext_args, - ext.oext_ret_type - ], - tl: acc - }; - continue ; - case /* Oext_first */0 : - case /* Oext_exception */2 : - return [ - Stdlib__List.rev(acc), - items - ]; - - } - }; - }; - const match = gather_extensions({ - hd: [ - ext.oext_name, - ext.oext_args, - ext.oext_ret_type - ], - tl: /* [] */0 - }, param.tl); - const te_otyext_name = ext.oext_type_name; - const te_otyext_params = ext.oext_type_params; - const te_otyext_constructors = match[0]; - const te_otyext_private = ext.oext_private; - const 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)({ - TAG: /* Format */0, - _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]); - case /* Oext_next */1 : - case /* Oext_exception */2 : - break; - - } - } - Curry._4(Stdlib__Format.fprintf(ppf)({ - TAG: /* Format */0, - _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) { if (/* tag */typeof t === "number" || typeof t === "string") { return ; @@ -41851,6 +41733,124 @@ function print_out_module_type(ppf, t) { } } +function print_out_signature(ppf, param) { + if (!param) { + return ; + } + const item = param.hd; + if (!param.tl) { + return Curry._2(out_sig_item.contents, ppf, item); + } + if (item.TAG === /* Osig_typext */2) { + const ext = item._0; + switch (item._1) { + case /* Oext_first */0 : + const gather_extensions = function (_acc, _items) { + while(true) { + const items = _items; + const acc = _acc; + if (!items) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + const match = items.hd; + if (match.TAG !== /* Osig_typext */2) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + const ext = match._0; + switch (match._1) { + case /* Oext_next */1 : + _items = items.tl; + _acc = { + hd: [ + ext.oext_name, + ext.oext_args, + ext.oext_ret_type + ], + tl: acc + }; + continue ; + case /* Oext_first */0 : + case /* Oext_exception */2 : + return [ + Stdlib__List.rev(acc), + items + ]; + + } + }; + }; + const match = gather_extensions({ + hd: [ + ext.oext_name, + ext.oext_args, + ext.oext_ret_type + ], + tl: /* [] */0 + }, param.tl); + const te_otyext_name = ext.oext_type_name; + const te_otyext_params = ext.oext_type_params; + const te_otyext_constructors = match[0]; + const te_otyext_private = ext.oext_private; + const 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)({ + TAG: /* Format */0, + _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]); + case /* Oext_next */1 : + case /* Oext_exception */2 : + break; + + } + } + Curry._4(Stdlib__Format.fprintf(ppf)({ + TAG: /* Format */0, + _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) { case /* Osig_class */0 : diff --git a/jscomp/test/dist/jscomp/test/parser_api.js b/jscomp/test/dist/jscomp/test/parser_api.js index fa3a0225a..55b4b6d9e 100644 --- a/jscomp/test/dist/jscomp/test/parser_api.js +++ b/jscomp/test/dist/jscomp/test/parser_api.js @@ -14483,25 +14483,6 @@ function directive_parse(token_with_comments, lexbuf) { } }; - const parse_or_aux = function (calc, v) { - const e = token(undefined); - if (/* tag */typeof e === "number" || typeof e === "string") { - if (e === /* BARBAR */8) { - const calc$1 = calc && !v; - const 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; - } else { - push(e); - return v; - } - }; const parse_relation = function (calc) { const curr_token = token(undefined); const curr_loc = curr(lexbuf); @@ -14664,6 +14645,25 @@ function directive_parse(token_with_comments, lexbuf) { return v; } }; + const parse_or_aux = function (calc, v) { + const e = token(undefined); + if (/* tag */typeof e === "number" || typeof e === "string") { + if (e === /* BARBAR */8) { + const calc$1 = calc && !v; + const 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; + } else { + push(e); + return v; + } + }; const v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); const match = token(undefined); if (/* tag */typeof match === "number" || typeof match === "string") { @@ -16039,6 +16039,62 @@ function token(lexbuf) { }; } +function string(lexbuf) { + lexbuf.lex_mem = Caml_array.make(2, -1); + let ___ocaml_lex_state = 164; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __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 : + const 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); + } + const 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 new Caml_js_exceptions.MelangeError($$Error$2, { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + }); + 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_comment_rec(lexbuf, ___ocaml_lex_state) { while(true) { const __ocaml_lex_state = ___ocaml_lex_state; @@ -16221,66 +16277,6 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { }; } -function comment(lexbuf) { - return __ocaml_lex_comment_rec(lexbuf, 132); -} - -function string(lexbuf) { - lexbuf.lex_mem = Caml_array.make(2, -1); - let ___ocaml_lex_state = 164; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __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 : - const 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); - } - const 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 new Caml_js_exceptions.MelangeError($$Error$2, { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents - }); - 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) { const __ocaml_lex_state = ___ocaml_lex_state; @@ -16319,6 +16315,10 @@ function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { }; } +function comment(lexbuf) { + return __ocaml_lex_comment_rec(lexbuf, 132); +} + function skip_sharp_bang(lexbuf) { let ___ocaml_lex_state = 192; while(true) { diff --git a/jscomp/test/dist/jscomp/test/re_or_res/reasonReact.js b/jscomp/test/dist/jscomp/test/re_or_res/reasonReact.js index 2ace173f8..b5d5fb83d 100644 --- a/jscomp/test/dist/jscomp/test/re_or_res/reasonReact.js +++ b/jscomp/test/dist/jscomp/test/re_or_res/reasonReact.js @@ -63,8 +63,9 @@ function createClass(debugName) { subscriptions: null, self: (function (state, retainedProps) { let $$this = this; + const _x = $$this.handleMethod; return { - handle: $$this.handleMethod, + handle: _x, state: state, retainedProps: retainedProps, send: $$this.sendMethod, diff --git a/jscomp/test/dist/jscomp/test/test_ari.js b/jscomp/test/dist/jscomp/test/test_ari.js index 5a82d80e3..90a92b540 100644 --- a/jscomp/test/dist/jscomp/test/test_ari.js +++ b/jscomp/test/dist/jscomp/test/test_ari.js @@ -137,6 +137,14 @@ const find_all = Stdlib__List.find_all; const filteri = Stdlib__List.filteri; +const take = Stdlib__List.take; + +const drop = Stdlib__List.drop; + +const take_while = Stdlib__List.take_while; + +const drop_while = Stdlib__List.drop_while; + const partition = Stdlib__List.partition; const partition_map = Stdlib__List.partition_map; @@ -229,6 +237,10 @@ exports.find_mapi = find_mapi; exports.filter = filter; exports.find_all = find_all; exports.filteri = filteri; +exports.take = take; +exports.drop = drop; +exports.take_while = take_while; +exports.drop_while = drop_while; exports.partition = partition; exports.partition_map = partition_map; exports.assoc = assoc; diff --git a/jscomp/test/dist/jscomp/test/test_include.js b/jscomp/test/dist/jscomp/test/test_include.js index 54750d499..c78e83ee3 100644 --- a/jscomp/test/dist/jscomp/test/test_include.js +++ b/jscomp/test/dist/jscomp/test/test_include.js @@ -117,6 +117,14 @@ const find_all = Stdlib__List.find_all; const filteri = Stdlib__List.filteri; +const take = Stdlib__List.take; + +const drop = Stdlib__List.drop; + +const take_while = Stdlib__List.take_while; + +const drop_while = Stdlib__List.drop_while; + const partition = Stdlib__List.partition; const partition_map = Stdlib__List.partition_map; @@ -205,6 +213,10 @@ exports.find_mapi = find_mapi; exports.filter = filter; exports.find_all = find_all; exports.filteri = filteri; +exports.take = take; +exports.drop = drop; +exports.take_while = take_while; +exports.drop_while = drop_while; exports.partition = partition; exports.partition_map = partition_map; exports.assoc = assoc; diff --git a/jscomp/test/dist/jscomp/test/test_pervasive.js b/jscomp/test/dist/jscomp/test/test_pervasive.js index a00bd7bb0..00b39737d 100644 --- a/jscomp/test/dist/jscomp/test/test_pervasive.js +++ b/jscomp/test/dist/jscomp/test/test_pervasive.js @@ -50,6 +50,10 @@ const Stdlib$1 = { filter: Stdlib__List.filter, find_all: Stdlib__List.find_all, filteri: Stdlib__List.filteri, + take: Stdlib__List.take, + drop: Stdlib__List.drop, + take_while: Stdlib__List.take_while, + drop_while: Stdlib__List.drop_while, partition: Stdlib__List.partition, partition_map: Stdlib__List.partition_map, assoc: Stdlib__List.assoc, diff --git a/jscomp/test/dist/jscomp/test/test_pervasives2.js b/jscomp/test/dist/jscomp/test/test_pervasives2.js index 26c07ddd4..47ab371f1 100644 --- a/jscomp/test/dist/jscomp/test/test_pervasives2.js +++ b/jscomp/test/dist/jscomp/test/test_pervasives2.js @@ -51,6 +51,10 @@ const List = { filter: Stdlib__List.filter, find_all: Stdlib__List.find_all, filteri: Stdlib__List.filteri, + take: Stdlib__List.take, + drop: Stdlib__List.drop, + take_while: Stdlib__List.take_while, + drop_while: Stdlib__List.drop_while, partition: Stdlib__List.partition, partition_map: Stdlib__List.partition_map, assoc: Stdlib__List.assoc, diff --git a/jscomp/test/dist/jscomp/test/test_pervasives3.js b/jscomp/test/dist/jscomp/test/test_pervasives3.js index 1d9546d84..e7ba28f3f 100644 --- a/jscomp/test/dist/jscomp/test/test_pervasives3.js +++ b/jscomp/test/dist/jscomp/test/test_pervasives3.js @@ -149,6 +149,10 @@ const Stdlib$1 = { filter: Stdlib__List.filter, find_all: Stdlib__List.find_all, filteri: Stdlib__List.filteri, + take: Stdlib__List.take, + drop: Stdlib__List.drop, + take_while: Stdlib__List.take_while, + drop_while: Stdlib__List.drop_while, partition: Stdlib__List.partition, partition_map: Stdlib__List.partition_map, assoc: Stdlib__List.assoc,