diff --git a/Makefile b/Makefile index 2a2286f3d..5ba231f23 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ test: build clean-tests dune build src/reason-parser-tests/testOprint.exe # ./miscTests/rtopIntegrationTest.sh ./miscTests/jsxPpxTest.sh + ./miscTests/backportSyntaxTests.sh cd formatTest; ./test.sh .PHONY: coverage diff --git a/esy.json b/esy.json index 3570181cb..cc379143b 100644 --- a/esy.json +++ b/esy.json @@ -12,7 +12,7 @@ "@opam/merlin-extend": " >= 0.4", "@opam/result": "*", "@opam/ocaml-migrate-parsetree": "*", - "@opam/dune": "*" + "@opam/dune": "< 2.0.0" }, "devDependencies": { "@opam/merlin": "*", diff --git a/esy.lock/index.json b/esy.lock/index.json index e956614c7..780fd4170 100644 --- a/esy.lock/index.json +++ b/esy.lock/index.json @@ -1,5 +1,5 @@ { - "checksum": "e941f0f78109a9b3d61349ecf8709a87", + "checksum": "fbb536f0a08ce0eda0833957e042c762", "root": "reason-cli@link-dev:./esy.json", "node": { "reason-cli@link-dev:./esy.json": { @@ -9,17 +9,17 @@ "source": { "type": "link-dev", "path": ".", "manifest": "esy.json" }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/utop@opam:2.2.0@1531727e", + "ocaml@4.6.1000@d41d8cd9", "@opam/utop@opam:2.4.3@5dd230c9", "@opam/result@opam:1.4@dc720aef", "@opam/ocamlfind@opam:1.8.1@ff07b0f9", - "@opam/ocaml-migrate-parsetree@opam:1.4.0@0c4ec62d", + "@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc", "@opam/merlin-extend@opam:0.5@a5dd7d4b", "@opam/menhir@opam:20190924@004407ff", - "@opam/fix@opam:20181206@6f3a1b41", "@opam/dune@opam:1.11.4@21d66ccd" + "@opam/fix@opam:20200131@0ecd2f01", "@opam/dune@opam:1.11.4@a7ccb7ae" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/odoc@opam:1.4.2@6f058006", - "@opam/merlin@opam:3.3.2@7a364181" + "ocaml@4.6.1000@d41d8cd9", "@opam/odoc@opam:1.5.0@35218f5f", + "@opam/merlin@opam:3.3.3@d653b06a" ] }, "ocaml@4.6.1000@d41d8cd9": { @@ -36,33 +36,35 @@ "dependencies": [], "devDependencies": [] }, - "@opam/zed@opam:1.6@81e8f144": { - "id": "@opam/zed@opam:1.6@81e8f144", + "@opam/zed@opam:2.0.5@80585091": { + "id": "@opam/zed@opam:2.0.5@80585091", "name": "@opam/zed", - "version": "opam:1.6", + "version": "opam:2.0.5", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/f7/f75c3094af1a22f9801d5ca5eb2d40e0#md5:f75c3094af1a22f9801d5ca5eb2d40e0", - "archive:https://github.com/diml/zed/releases/download/1.6/zed-1.6.tbz#md5:f75c3094af1a22f9801d5ca5eb2d40e0" + "archive:https://opam.ocaml.org/cache/md5/56/56414179d7cccba0e20005d958b5d39e#md5:56414179d7cccba0e20005d958b5d39e", + "archive:https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz#md5:56414179d7cccba0e20005d958b5d39e" ], "opam": { "name": "zed", - "version": "1.6", - "path": "esy.lock/opam/zed.1.6" + "version": "2.0.5", + "path": "esy.lock/opam/zed.2.0.5" } }, "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/react@opam:1.2.1@0e11855f", - "@opam/jbuilder@opam:transition@58bdfe0a", + "@opam/dune@opam:1.11.4@a7ccb7ae", + "@opam/charInfo_width@opam:1.1.0@9d8d61b2", "@opam/camomile@opam:1.0.2@51b42ad8", "@opam/base-bytes@opam:base@19d0c2ff", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/react@opam:1.2.1@0e11855f", - "@opam/jbuilder@opam:transition@58bdfe0a", + "@opam/dune@opam:1.11.4@a7ccb7ae", + "@opam/charInfo_width@opam:1.1.0@9d8d61b2", "@opam/camomile@opam:1.0.2@51b42ad8", "@opam/base-bytes@opam:base@19d0c2ff" ] @@ -86,13 +88,13 @@ "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4", - "@opam/dune@opam:1.11.4@21d66ccd", "@opam/cppo@opam:1.6.6@f4f83858", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/cppo@opam:1.6.6@f4f83858", "@opam/biniou@opam:1.2.1@d7570399", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4", - "@opam/dune@opam:1.11.4@21d66ccd", "@opam/biniou@opam:1.2.1@d7570399" + "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/biniou@opam:1.2.1@d7570399" ] }, "@opam/uutf@opam:1.0.2@4440868f": { @@ -124,36 +126,30 @@ "ocaml@4.6.1000@d41d8cd9", "@opam/uchar@opam:0.0.2@c8218eea" ] }, - "@opam/utop@opam:2.2.0@1531727e": { - "id": "@opam/utop@opam:2.2.0@1531727e", + "@opam/utop@opam:2.4.3@5dd230c9": { + "id": "@opam/utop@opam:2.4.3@5dd230c9", "name": "@opam/utop", - "version": "opam:2.2.0", + "version": "opam:2.4.3", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/c8/c8e4805883ce27a2ef27b0e4322d6f04#md5:c8e4805883ce27a2ef27b0e4322d6f04", - "archive:https://github.com/diml/utop/releases/download/2.2.0/utop-2.2.0.tbz#md5:c8e4805883ce27a2ef27b0e4322d6f04" + "archive:https://opam.ocaml.org/cache/sha256/4e/4e30ba6e224bea5776bc1a6ac3fee7f7548a35acf41d35e59c45913e28a0ea80#sha256:4e30ba6e224bea5776bc1a6ac3fee7f7548a35acf41d35e59c45913e28a0ea80", + "archive:https://github.com/ocaml-community/utop/releases/download/2.4.3/utop-2.4.3.tbz#sha256:4e30ba6e224bea5776bc1a6ac3fee7f7548a35acf41d35e59c45913e28a0ea80" ], "opam": { "name": "utop", - "version": "2.2.0", - "path": "esy.lock/opam/utop.2.2.0" + "version": "2.4.3", + "path": "esy.lock/opam/utop.2.4.3" } }, - "overrides": [ - { - "opamoverride": - "esy.lock/overrides/opam__s__utop_opam__c__2.2.0_opam_override" - } - ], + "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/react@opam:1.2.1@0e11855f", "@opam/ocamlfind@opam:1.8.1@ff07b0f9", "@opam/lwt_react@opam:1.1.3@72987fcf", - "@opam/lwt@opam:4.4.0@0357bb8b", - "@opam/lambda-term@opam:1.13@2381e3c1", - "@opam/jbuilder@opam:transition@58bdfe0a", - "@opam/cppo@opam:1.6.6@f4f83858", + "@opam/lwt@opam:5.1.1@6f0a0b20", + "@opam/lambda-term@opam:2.0.3@9465cf1c", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/cppo@opam:1.6.6@f4f83858", "@opam/camomile@opam:1.0.2@51b42ad8", "@opam/base-unix@opam:base@87d0b2eb", "@opam/base-threads@opam:base@36803084", @@ -163,9 +159,9 @@ "ocaml@4.6.1000@d41d8cd9", "@opam/react@opam:1.2.1@0e11855f", "@opam/ocamlfind@opam:1.8.1@ff07b0f9", "@opam/lwt_react@opam:1.1.3@72987fcf", - "@opam/lwt@opam:4.4.0@0357bb8b", - "@opam/lambda-term@opam:1.13@2381e3c1", - "@opam/jbuilder@opam:transition@58bdfe0a", + "@opam/lwt@opam:5.1.1@6f0a0b20", + "@opam/lambda-term@opam:2.0.3@9465cf1c", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/camomile@opam:1.0.2@51b42ad8", "@opam/base-unix@opam:base@87d0b2eb", "@opam/base-threads@opam:base@36803084" @@ -213,13 +209,13 @@ "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/uutf@opam:1.0.2@4440868f", - "@opam/seq@opam:0.2@35c16df8", "@opam/re@opam:1.9.0@d4d5e13d", - "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + "@opam/seq@opam:0.2.2@e9144e45", "@opam/re@opam:1.9.0@d4d5e13d", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/uutf@opam:1.0.2@4440868f", - "@opam/seq@opam:0.2@35c16df8", "@opam/re@opam:1.9.0@d4d5e13d", - "@opam/dune@opam:1.11.4@21d66ccd" + "@opam/seq@opam:0.2.2@e9144e45", "@opam/re@opam:1.9.0@d4d5e13d", + "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/topkg@opam:1.0.1@a42c631e": { @@ -248,29 +244,29 @@ "ocaml@4.6.1000@d41d8cd9", "@opam/ocamlbuild@opam:0.14.0@6ac75d03" ] }, - "@opam/seq@opam:0.2@35c16df8": { - "id": "@opam/seq@opam:0.2@35c16df8", + "@opam/seq@opam:0.2.2@e9144e45": { + "id": "@opam/seq@opam:0.2.2@e9144e45", "name": "@opam/seq", - "version": "opam:0.2", + "version": "opam:0.2.2", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/1d/1d5a9d0aba27b22433f518cdc495d0fd#md5:1d5a9d0aba27b22433f518cdc495d0fd", - "archive:https://github.com/c-cube/seq/archive/0.2.tar.gz#md5:1d5a9d0aba27b22433f518cdc495d0fd" + "archive:https://opam.ocaml.org/cache/md5/90/9033e02283aa3bde9f97f24e632902e3#md5:9033e02283aa3bde9f97f24e632902e3", + "archive:https://github.com/c-cube/seq/archive/0.2.2.tar.gz#md5:9033e02283aa3bde9f97f24e632902e3" ], "opam": { "name": "seq", - "version": "0.2", - "path": "esy.lock/opam/seq.0.2" + "version": "0.2.2", + "path": "esy.lock/opam/seq.0.2.2" } }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/result@opam:1.4@dc720aef": { @@ -291,11 +287,11 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/react@opam:1.2.1@0e11855f": { @@ -341,12 +337,12 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/seq@opam:0.2@35c16df8", - "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + "ocaml@4.6.1000@d41d8cd9", "@opam/seq@opam:0.2.2@e9144e45", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/seq@opam:0.2@35c16df8", - "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/seq@opam:0.2.2@e9144e45", + "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/ppx_derivers@opam:1.2.1@ecf0aa45": { @@ -367,40 +363,44 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, - "@opam/odoc@opam:1.4.2@6f058006": { - "id": "@opam/odoc@opam:1.4.2@6f058006", + "@opam/odoc@opam:1.5.0@35218f5f": { + "id": "@opam/odoc@opam:1.5.0@35218f5f", "name": "@opam/odoc", - "version": "opam:1.4.2", + "version": "opam:1.5.0", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/d7/d75ce63539040cd199d22203d46fc5f3#md5:d75ce63539040cd199d22203d46fc5f3", - "archive:https://github.com/ocaml/odoc/archive/1.4.2.tar.gz#md5:d75ce63539040cd199d22203d46fc5f3" + "archive:https://opam.ocaml.org/cache/sha256/85/857759be968070bfda208add3ae2c2bc87826ca2bfc39cebab1cc1e13db7a140#sha256:857759be968070bfda208add3ae2c2bc87826ca2bfc39cebab1cc1e13db7a140", + "archive:https://github.com/ocaml/odoc/releases/download/1.5.0/odoc-1.5.0.tbz#sha256:857759be968070bfda208add3ae2c2bc87826ca2bfc39cebab1cc1e13db7a140" ], "opam": { "name": "odoc", - "version": "1.4.2", - "path": "esy.lock/opam/odoc.1.4.2" + "version": "1.5.0", + "path": "esy.lock/opam/odoc.1.5.0" } }, "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/tyxml@opam:4.3.0@c1da25f1", "@opam/result@opam:1.4@dc720aef", "@opam/fpath@opam:0.7.2@45477b93", - "@opam/dune@opam:1.11.4@21d66ccd", "@opam/cppo@opam:1.6.6@f4f83858", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/cppo@opam:1.6.6@f4f83858", "@opam/cmdliner@opam:1.0.4@93208aac", "@opam/astring@opam:0.8.3@4e5e17d5", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/tyxml@opam:4.3.0@c1da25f1", + "@opam/result@opam:1.4@dc720aef", "@opam/fpath@opam:0.7.2@45477b93", + "@opam/dune@opam:1.11.4@a7ccb7ae", + "@opam/cmdliner@opam:1.0.4@93208aac", + "@opam/astring@opam:0.8.3@4e5e17d5" ] }, "@opam/ocplib-endian@opam:1.0@aa720242": { @@ -494,32 +494,32 @@ ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9" ] }, - "@opam/ocaml-migrate-parsetree@opam:1.4.0@0c4ec62d": { - "id": "@opam/ocaml-migrate-parsetree@opam:1.4.0@0c4ec62d", + "@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc": { + "id": "@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc", "name": "@opam/ocaml-migrate-parsetree", - "version": "opam:1.4.0", + "version": "opam:1.5.0", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/sha256/23/231fbdc205187b3ee266b535d9cfe44b599067b2f6e97883c782ea7bb577d3b8#sha256:231fbdc205187b3ee266b535d9cfe44b599067b2f6e97883c782ea7bb577d3b8", - "archive:https://github.com/ocaml-ppx/ocaml-migrate-parsetree/releases/download/v1.4.0/ocaml-migrate-parsetree-v1.4.0.tbz#sha256:231fbdc205187b3ee266b535d9cfe44b599067b2f6e97883c782ea7bb577d3b8" + "archive:https://opam.ocaml.org/cache/sha256/7f/7f56679c9561552762666de5b6b81c8e4cc2e9fd92272e2269878a2eb534e3c0#sha256:7f56679c9561552762666de5b6b81c8e4cc2e9fd92272e2269878a2eb534e3c0", + "archive:https://github.com/ocaml-ppx/ocaml-migrate-parsetree/releases/download/v1.5.0/ocaml-migrate-parsetree-v1.5.0.tbz#sha256:7f56679c9561552762666de5b6b81c8e4cc2e9fd92272e2269878a2eb534e3c0" ], "opam": { "name": "ocaml-migrate-parsetree", - "version": "1.4.0", - "path": "esy.lock/opam/ocaml-migrate-parsetree.1.4.0" + "version": "1.5.0", + "path": "esy.lock/opam/ocaml-migrate-parsetree.1.5.0" } }, "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef", "@opam/ppx_derivers@opam:1.2.1@ecf0aa45", - "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef", "@opam/ppx_derivers@opam:1.2.1@ecf0aa45", - "@opam/dune@opam:1.11.4@21d66ccd" + "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/mmap@opam:1.1.0@b85334ff": { @@ -540,11 +540,11 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/merlin-extend@opam:0.5@a5dd7d4b": { @@ -565,39 +565,39 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/cppo@opam:1.6.6@f4f83858", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, - "@opam/merlin@opam:3.3.2@7a364181": { - "id": "@opam/merlin@opam:3.3.2@7a364181", + "@opam/merlin@opam:3.3.3@d653b06a": { + "id": "@opam/merlin@opam:3.3.3@d653b06a", "name": "@opam/merlin", - "version": "opam:3.3.2", + "version": "opam:3.3.3", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/sha256/1d/1d1c71e663b1e58acf19069cebd1e8d18f7dbe513c6065347d162cdd2c2de801#sha256:1d1c71e663b1e58acf19069cebd1e8d18f7dbe513c6065347d162cdd2c2de801", - "archive:https://github.com/ocaml/merlin/releases/download/v3.3.2/merlin-v3.3.2.tbz#sha256:1d1c71e663b1e58acf19069cebd1e8d18f7dbe513c6065347d162cdd2c2de801" + "archive:https://opam.ocaml.org/cache/sha256/72/72909ef47eea1f6fca13b4109a34dccf8fe3923a3c026f1ed1db9eb5ee9aae15#sha256:72909ef47eea1f6fca13b4109a34dccf8fe3923a3c026f1ed1db9eb5ee9aae15", + "archive:https://github.com/ocaml/merlin/releases/download/v3.3.3/merlin-v3.3.3.tbz#sha256:72909ef47eea1f6fca13b4109a34dccf8fe3923a3c026f1ed1db9eb5ee9aae15" ], "opam": { "name": "merlin", - "version": "3.3.2", - "path": "esy.lock/opam/merlin.3.3.2" + "version": "3.3.3", + "path": "esy.lock/opam/merlin.3.3.3" } }, "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985", "@opam/ocamlfind@opam:1.8.1@ff07b0f9", - "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985", "@opam/ocamlfind@opam:1.8.1@ff07b0f9", - "@opam/dune@opam:1.11.4@21d66ccd" + "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/menhir@opam:20190924@004407ff": { @@ -643,12 +643,12 @@ "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/react@opam:1.2.1@0e11855f", - "@opam/lwt@opam:4.4.0@0357bb8b", "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/lwt@opam:5.1.1@6f0a0b20", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/react@opam:1.2.1@0e11855f", - "@opam/lwt@opam:4.4.0@0357bb8b", "@opam/dune@opam:1.11.4@21d66ccd" + "@opam/lwt@opam:5.1.1@6f0a0b20", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/lwt_log@opam:1.1.1@2d7a797f": { @@ -669,112 +669,85 @@ }, "overrides": [], "dependencies": [ - "@opam/lwt@opam:4.4.0@0357bb8b", "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/lwt@opam:5.1.1@6f0a0b20", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "@opam/lwt@opam:4.4.0@0357bb8b", "@opam/dune@opam:1.11.4@21d66ccd" + "@opam/lwt@opam:5.1.1@6f0a0b20", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, - "@opam/lwt@opam:4.4.0@0357bb8b": { - "id": "@opam/lwt@opam:4.4.0@0357bb8b", + "@opam/lwt@opam:5.1.1@6f0a0b20": { + "id": "@opam/lwt@opam:5.1.1@6f0a0b20", "name": "@opam/lwt", - "version": "opam:4.4.0", + "version": "opam:5.1.1", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/8b/8bfc70c2944020fa08dd04877747f5f9#md5:8bfc70c2944020fa08dd04877747f5f9", - "archive:https://github.com/ocsigen/lwt/archive/4.4.0.tar.gz#md5:8bfc70c2944020fa08dd04877747f5f9" + "archive:https://opam.ocaml.org/cache/md5/4d/4ddec0f42b7aa4a310175a14c47c60a3#md5:4ddec0f42b7aa4a310175a14c47c60a3", + "archive:https://github.com/ocsigen/lwt/archive/5.1.1.tar.gz#md5:4ddec0f42b7aa4a310175a14c47c60a3" ], "opam": { "name": "lwt", - "version": "4.4.0", - "path": "esy.lock/opam/lwt.4.4.0" + "version": "5.1.1", + "path": "esy.lock/opam/lwt.5.1.1" } }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/seq@opam:0.2@35c16df8", + "ocaml@4.6.1000@d41d8cd9", "@opam/seq@opam:0.2.2@e9144e45", "@opam/result@opam:1.4@dc720aef", "@opam/ocplib-endian@opam:1.0@aa720242", "@opam/mmap@opam:1.1.0@b85334ff", "@opam/dune-configurator@opam:1.0.0@4873acd8", - "@opam/dune@opam:1.11.4@21d66ccd", "@opam/cppo@opam:1.6.6@f4f83858", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/cppo@opam:1.6.6@f4f83858", "@opam/base-unix@opam:base@87d0b2eb", "@opam/base-threads@opam:base@36803084", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/seq@opam:0.2@35c16df8", + "ocaml@4.6.1000@d41d8cd9", "@opam/seq@opam:0.2.2@e9144e45", "@opam/result@opam:1.4@dc720aef", "@opam/ocplib-endian@opam:1.0@aa720242", "@opam/mmap@opam:1.1.0@b85334ff", "@opam/dune-configurator@opam:1.0.0@4873acd8", - "@opam/dune@opam:1.11.4@21d66ccd" + "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, - "@opam/lambda-term@opam:1.13@2381e3c1": { - "id": "@opam/lambda-term@opam:1.13@2381e3c1", + "@opam/lambda-term@opam:2.0.3@9465cf1c": { + "id": "@opam/lambda-term@opam:2.0.3@9465cf1c", "name": "@opam/lambda-term", - "version": "opam:1.13", + "version": "opam:2.0.3", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/c1/c13826a97014d4d573b927b623c7e043#md5:c13826a97014d4d573b927b623c7e043", - "archive:https://github.com/diml/lambda-term/releases/download/1.13/lambda-term-1.13.tbz#md5:c13826a97014d4d573b927b623c7e043" + "archive:https://opam.ocaml.org/cache/md5/90/903b6cc234598d67c7c905dfb5230209#md5:903b6cc234598d67c7c905dfb5230209", + "archive:https://github.com/ocaml-community/lambda-term/releases/download/2.0.3/lambda-term-2.0.3.tbz#md5:903b6cc234598d67c7c905dfb5230209" ], "opam": { "name": "lambda-term", - "version": "1.13", - "path": "esy.lock/opam/lambda-term.1.13" + "version": "2.0.3", + "path": "esy.lock/opam/lambda-term.2.0.3" } }, - "overrides": [ - { - "opamoverride": - "esy.lock/overrides/opam__s__lambda_term_opam__c__1.13_opam_override" - } - ], + "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/zed@opam:1.6@81e8f144", + "ocaml@4.6.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", - "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.4.0@0357bb8b", - "@opam/jbuilder@opam:transition@58bdfe0a", + "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:5.1.1@6f0a0b20", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/camomile@opam:1.0.2@51b42ad8", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/zed@opam:1.6@81e8f144", + "ocaml@4.6.1000@d41d8cd9", "@opam/zed@opam:2.0.5@80585091", "@opam/react@opam:1.2.1@0e11855f", "@opam/lwt_react@opam:1.1.3@72987fcf", - "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:4.4.0@0357bb8b", - "@opam/jbuilder@opam:transition@58bdfe0a", + "@opam/lwt_log@opam:1.1.1@2d7a797f", "@opam/lwt@opam:5.1.1@6f0a0b20", + "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/camomile@opam:1.0.2@51b42ad8" ] }, - "@opam/jbuilder@opam:transition@58bdfe0a": { - "id": "@opam/jbuilder@opam:transition@58bdfe0a", - "name": "@opam/jbuilder", - "version": "opam:transition", - "source": { - "type": "install", - "source": [ "no-source:" ], - "opam": { - "name": "jbuilder", - "version": "transition", - "path": "esy.lock/opam/jbuilder.transition" - } - }, - "overrides": [], - "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", - "@esy-ocaml/substs@0.0.1@d41d8cd9" - ], - "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" - ] - }, "@opam/fpath@opam:0.7.2@45477b93": { "id": "@opam/fpath@opam:0.7.2@45477b93", "name": "@opam/fpath", @@ -805,29 +778,29 @@ "@opam/astring@opam:0.8.3@4e5e17d5" ] }, - "@opam/fix@opam:20181206@6f3a1b41": { - "id": "@opam/fix@opam:20181206@6f3a1b41", + "@opam/fix@opam:20200131@0ecd2f01": { + "id": "@opam/fix@opam:20200131@0ecd2f01", "name": "@opam/fix", - "version": "opam:20181206", + "version": "opam:20200131", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/ae/ae129ed3822149a7f8c98f975512e534#md5:ae129ed3822149a7f8c98f975512e534", - "archive:https://gitlab.inria.fr/fpottier/fix/repository/20181206/archive.tar.gz#md5:ae129ed3822149a7f8c98f975512e534" + "archive:https://opam.ocaml.org/cache/md5/99/991ff031666c662eaab638d2e0f4ac1d#md5:991ff031666c662eaab638d2e0f4ac1d", + "archive:https://gitlab.inria.fr/fpottier/fix/repository/20200131/archive.tar.gz#md5:991ff031666c662eaab638d2e0f4ac1d" ], "opam": { "name": "fix", - "version": "20181206", - "path": "esy.lock/opam/fix.20181206" + "version": "20200131", + "path": "esy.lock/opam/fix.20200131" } }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/easy-format@opam:1.3.2@0484b3c4": { @@ -848,11 +821,11 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/dune-configurator@opam:1.0.0@4873acd8": { @@ -870,12 +843,12 @@ }, "overrides": [], "dependencies": [ - "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], - "devDependencies": [ "@opam/dune@opam:1.11.4@21d66ccd" ] + "devDependencies": [ "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, - "@opam/dune@opam:1.11.4@21d66ccd": { - "id": "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/dune@opam:1.11.4@a7ccb7ae": { + "id": "@opam/dune@opam:1.11.4@a7ccb7ae", "name": "@opam/dune", "version": "opam:1.11.4", "source": { @@ -890,12 +863,7 @@ "path": "esy.lock/opam/dune.1.11.4" } }, - "overrides": [ - { - "opamoverride": - "esy.lock/overrides/opam__s__dune_opam__c__1.11.4_opam_override" - } - ], + "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/base-unix@opam:base@87d0b2eb", "@opam/base-threads@opam:base@36803084", @@ -924,12 +892,12 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/base-unix@opam:base@87d0b2eb", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@opam/base-unix@opam:base@87d0b2eb" ] }, @@ -972,6 +940,35 @@ ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9" ] }, + "@opam/charInfo_width@opam:1.1.0@9d8d61b2": { + "id": "@opam/charInfo_width@opam:1.1.0@9d8d61b2", + "name": "@opam/charInfo_width", + "version": "opam:1.1.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/c4/c4ab038e06f06a29692c05fdd7c268c5#md5:c4ab038e06f06a29692c05fdd7c268c5", + "archive:https://bitbucket.org/zandoye/charinfo_width/get/1.1.0.tar.gz#md5:c4ab038e06f06a29692c05fdd7c268c5" + ], + "opam": { + "name": "charInfo_width", + "version": "1.1.0", + "path": "esy.lock/opam/charInfo_width.1.1.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.6.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef", + "@opam/dune@opam:1.11.4@a7ccb7ae", + "@opam/camomile@opam:1.0.2@51b42ad8", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.6.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef", + "@opam/dune@opam:1.11.4@a7ccb7ae", + "@opam/camomile@opam:1.0.2@51b42ad8" + ] + }, "@opam/camomile@opam:1.0.2@51b42ad8": { "id": "@opam/camomile@opam:1.0.2@51b42ad8", "name": "@opam/camomile", @@ -990,11 +987,11 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + "ocaml@4.6.1000@d41d8cd9", "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/biniou@opam:1.2.1@d7570399": { @@ -1016,11 +1013,11 @@ "overrides": [], "dependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4", - "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + "@opam/dune@opam:1.11.4@a7ccb7ae", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ "ocaml@4.6.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4", - "@opam/dune@opam:1.11.4@21d66ccd" + "@opam/dune@opam:1.11.4@a7ccb7ae" ] }, "@opam/base-unix@opam:base@87d0b2eb": { diff --git a/esy.lock/opam/charInfo_width.1.1.0/opam b/esy.lock/opam/charInfo_width.1.1.0/opam new file mode 100644 index 000000000..7c17c9816 --- /dev/null +++ b/esy.lock/opam/charInfo_width.1.1.0/opam @@ -0,0 +1,27 @@ +opam-version: "2.0" +maintainer: "zandoye@gmail.com" +authors: [ "ZAN DoYe" ] +homepage: "https://bitbucket.org/zandoye/charinfo_width/" +bug-reports: "https://bitbucket.org/zandoye/charinfo_width/issues" +license: "MIT" +dev-repo: "hg+https://bitbucket.org/zandoye/charinfo_width" +build: [ + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test & (ocaml:version >= "4.04.0")} +] +depends: [ + "ocaml" {>= "4.02.3"} + "result" + "camomile" {>= "1.0.0" & < "2.0~"} + "dune" + "ppx_expect" {with-test & < "v0.14"} +] + +synopsis: "Determine column width for a character" +description: """ +This module is implemented purely in OCaml and the width function follows the prototype of POSIX's wcwidth.""" + +url { + src:"https://bitbucket.org/zandoye/charinfo_width/get/1.1.0.tar.gz" + checksum: "md5=c4ab038e06f06a29692c05fdd7c268c5" +} diff --git a/esy.lock/opam/fix.20181206/opam b/esy.lock/opam/fix.20200131/opam similarity index 62% rename from esy.lock/opam/fix.20181206/opam rename to esy.lock/opam/fix.20200131/opam index fcdf0423d..4babcba82 100644 --- a/esy.lock/opam/fix.20181206/opam +++ b/esy.lock/opam/fix.20200131/opam @@ -11,14 +11,14 @@ build: [ ] depends: [ "ocaml" { >= "4.03" } - "dune" + "dune" { >= "1.3" } ] synopsis: "Facilities for memoization and fixed points" url { src: - "https://gitlab.inria.fr/fpottier/fix/repository/20181206/archive.tar.gz" + "https://gitlab.inria.fr/fpottier/fix/repository/20200131/archive.tar.gz" checksum: [ - "md5=ae129ed3822149a7f8c98f975512e534" - "sha512=1db240ff0a87200979bf4308e2110a37631f280e36c5f53dde767579ca63992a760eaeb6e1fc9a41c3f3a63d3dc29a3361114ad304cb09e83945ab4213ff5f6d" + "md5=991ff031666c662eaab638d2e0f4ac1d" + "sha512=01c45a1d90b02ec0939e968b185a6a373ac6117e2287b9a26d3db9d71e9569d086cea50da60710fcab5c2ed9d3b4c72b76839c0651e436f1fb39c77dc7c04b5e" ] } diff --git a/esy.lock/opam/jbuilder.transition/opam b/esy.lock/opam/jbuilder.transition/opam deleted file mode 100644 index 3e3174a5f..000000000 --- a/esy.lock/opam/jbuilder.transition/opam +++ /dev/null @@ -1,15 +0,0 @@ -opam-version: "2.0" -maintainer: "opensource@janestreet.com" -authors: ["Jane Street Group, LLC "] -homepage: "https://github.com/ocaml/dune" -bug-reports: "https://github.com/ocaml/dune/issues" -dev-repo: "git+https://github.com/ocaml/dune.git" -license: "MIT" -depends: ["ocaml" "dune"] -post-messages: [ - "Jbuilder has been renamed and the jbuilder package is now a transition \ - package. Use the dune package instead." -] -synopsis: - "This is a transition package, jbuilder is now named dune. Use the dune" -description: "package instead." diff --git a/esy.lock/opam/js_of_ocaml-compiler.3.5.1/opam b/esy.lock/opam/js_of_ocaml-compiler.3.5.1/opam deleted file mode 100644 index d352742e5..000000000 --- a/esy.lock/opam/js_of_ocaml-compiler.3.5.1/opam +++ /dev/null @@ -1,38 +0,0 @@ -opam-version: "2.0" -maintainer: "dev@ocsigen.org" -authors: "Ocsigen team" -bug-reports: "https://github.com/ocsigen/js_of_ocaml/issues" -homepage: "http://ocsigen.github.io/js_of_ocaml" -dev-repo: "git+https://github.com/ocsigen/js_of_ocaml.git" -synopsis: "Compiler from OCaml bytecode to Javascript" -description: """ -Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. -It makes it possible to run pure OCaml programs in JavaScript -environment like browsers and Node.js -""" - -build: [["dune" "build" "-p" name "-j" jobs]] - -depends: [ - "ocaml" {>= "4.02.0"} - "dune" {>= "1.11.1"} - "ppx_expect" {with-test & >= "0.12.0"} - "cmdliner" - "ocaml-migrate-parsetree" - "yojson" # It's optional, but we want users to be able to use source-map without pain. -] - -depopts: [ "ocamlfind" ] - -conflicts: [ - "ocamlfind" {< "1.5.1"} - "js_of_ocaml" {< "3.0"} -] -url { - src: - "https://github.com/ocsigen/js_of_ocaml/releases/download/3.5.1/js_of_ocaml-3.5.1.tbz" - checksum: [ - "sha256=3a050eb9507058164431c8e1f1c86b3c61e30a5d0b0cf2c5f48b959b87eaade9" - "sha512=0bbca03ac220f28adf060d4c2d8f726801bce80461aa73724a6c53b4979af919c820cc723b0a7e9bda93270cef5c0485aea942aa527010a3c386a13b7e2d4842" - ] -} diff --git a/esy.lock/opam/js_of_ocaml.3.5.1/opam b/esy.lock/opam/js_of_ocaml.3.5.1/opam deleted file mode 100644 index f56611a84..000000000 --- a/esy.lock/opam/js_of_ocaml.3.5.1/opam +++ /dev/null @@ -1,33 +0,0 @@ -opam-version: "2.0" -maintainer: "dev@ocsigen.org" -authors: "Ocsigen team" -bug-reports: "https://github.com/ocsigen/js_of_ocaml/issues" -homepage: "http://ocsigen.github.io/js_of_ocaml" -dev-repo: "git+https://github.com/ocsigen/js_of_ocaml.git" -synopsis: "Compiler from OCaml bytecode to Javascript" -description: """ -Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. -It makes it possible to run pure OCaml programs in JavaScript -environment like browsers and Node.js -""" - -name: "js_of_ocaml" - -build: [["dune" "build" "-p" name "-j" jobs]] - -depends: [ - "ocaml" {>= "4.02.0"} - "dune" {>= "1.11.1"} - "ocaml-migrate-parsetree" {>= "1.4"} - "ppx_tools_versioned" {>= "5.2.3"} - "uchar" - "js_of_ocaml-compiler" -] -url { - src: - "https://github.com/ocsigen/js_of_ocaml/releases/download/3.5.1/js_of_ocaml-3.5.1.tbz" - checksum: [ - "sha256=3a050eb9507058164431c8e1f1c86b3c61e30a5d0b0cf2c5f48b959b87eaade9" - "sha512=0bbca03ac220f28adf060d4c2d8f726801bce80461aa73724a6c53b4979af919c820cc723b0a7e9bda93270cef5c0485aea942aa527010a3c386a13b7e2d4842" - ] -} diff --git a/esy.lock/opam/lambda-term.1.13/opam b/esy.lock/opam/lambda-term.2.0.3/opam similarity index 58% rename from esy.lock/opam/lambda-term.1.13/opam rename to esy.lock/opam/lambda-term.2.0.3/opam index 809c2dde2..18c4901c4 100644 --- a/esy.lock/opam/lambda-term.1.13/opam +++ b/esy.lock/opam/lambda-term.2.0.3/opam @@ -1,24 +1,23 @@ opam-version: "2.0" maintainer: "jeremie@dimino.org" authors: ["Jérémie Dimino"] -homepage: "https://github.com/diml/lambda-term" -bug-reports: "https://github.com/diml/lambda-term/issues" -dev-repo: "git://github.com/diml/lambda-term.git" +homepage: "https://github.com/ocaml-community/lambda-term" +bug-reports: "https://github.com/ocaml-community/lambda-term/issues" +dev-repo: "git://github.com/ocaml-community/lambda-term.git" license: "BSD-3-Clause" build: [ - ["jbuilder" "subst" "-p" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] - ["jbuilder" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] depends: [ "ocaml" {>= "4.02.3"} - "lwt" {>= "4.0.0"} + "lwt" {>= "4.0.0"} "lwt_log" "react" - "zed" {>= "1.2" & < "2.0"} - "camomile" {>= "0.8.6"} + "zed" {>= "2.0.3" & < "3.0"} + "camomile" {>= "1.0.1"} "lwt_react" - "jbuilder" {>= "1.0+beta9"} + "dune" {>= "1.1.0"} ] synopsis: "Terminal manipulation library for OCaml" description: """ @@ -30,7 +29,6 @@ for example, ncurses, by providing a native OCaml interface instead of bindings to a C library. Lambda-term integrates with zed to provide text edition facilities in console applications.""" url { - src: - "https://github.com/diml/lambda-term/releases/download/1.13/lambda-term-1.13.tbz" - checksum: "md5=c13826a97014d4d573b927b623c7e043" + src: "https://github.com/ocaml-community/lambda-term/releases/download/2.0.3/lambda-term-2.0.3.tbz" + checksum: "md5=903b6cc234598d67c7c905dfb5230209" } diff --git a/esy.lock/opam/lwt.4.4.0/opam b/esy.lock/opam/lwt.5.1.1/opam similarity index 85% rename from esy.lock/opam/lwt.4.4.0/opam rename to esy.lock/opam/lwt.5.1.1/opam index 21d7aa8da..5eaf079c0 100644 --- a/esy.lock/opam/lwt.4.4.0/opam +++ b/esy.lock/opam/lwt.5.1.1/opam @@ -2,10 +2,10 @@ opam-version: "2.0" synopsis: "Promises and event-driven I/O" -version: "4.4.0" +version: "5.1.1" license: "MIT" homepage: "https://github.com/ocsigen/lwt" -doc: "https://ocsigen.org/lwt/manual/" +doc: "https://ocsigen.org/lwt" bug-reports: "https://github.com/ocsigen/lwt/issues" authors: [ @@ -42,7 +42,7 @@ conflicts: [ ] post-messages: [ - "Lwt 5.0.0 will make some breaking changes in November 2019. See + "Lwt 5.0.0 has made some minor breaking changes. See https://github.com/ocsigen/lwt/issues/584" ] @@ -60,6 +60,6 @@ a single thread by default. This reduces the need for locks or other synchronization primitives. Code can be run in parallel on an opt-in basis." url { - src: "https://github.com/ocsigen/lwt/archive/4.4.0.tar.gz" - checksum: "md5=8bfc70c2944020fa08dd04877747f5f9" + src: "https://github.com/ocsigen/lwt/archive/5.1.1.tar.gz" + checksum: "md5=4ddec0f42b7aa4a310175a14c47c60a3" } diff --git a/esy.lock/opam/merlin.3.3.2/opam b/esy.lock/opam/merlin.3.3.2/opam deleted file mode 100644 index 47fb8f5e0..000000000 --- a/esy.lock/opam/merlin.3.3.2/opam +++ /dev/null @@ -1,70 +0,0 @@ -opam-version: "2.0" -name: "merlin" -maintainer: "defree@gmail.com" -authors: "The Merlin team" -homepage: "https://github.com/ocaml/merlin" -bug-reports: "https://github.com/ocaml/merlin/issues" -dev-repo: "git+https://github.com/ocaml/merlin.git" -build: [ - ["dune" "subst"] {pinned} - ["dune" "build" "-p" name "-j" jobs] -] -depends: [ - "ocaml" {>= "4.02.1" & < "4.09"} - "dune" {>= "1.8.0"} - "ocamlfind" {>= "1.5.2"} - "yojson" - "mdx" {with-test & >= "1.3.0"} -] -synopsis: - "Editor helper, provides completion, typing and source browsing in Vim and Emacs" -description: - "Merlin is an assistant for editing OCaml code. It aims to provide the features available in modern IDEs: error reporting, auto completion, source browsing and much more." -post-messages: [ - "merlin installed. - -Quick setup for VIM -------------------- -Append this to your .vimrc to add merlin to vim's runtime-path: - let g:opamshare = substitute(system('opam config var share'),'\\n$','','''') - execute \"set rtp+=\" . g:opamshare . \"/merlin/vim\" - -Also run the following line in vim to index the documentation: - :execute \"helptags \" . g:opamshare . \"/merlin/vim/doc\" - -Quick setup for EMACS -------------------- -Add opam emacs directory to your load-path by appending this to your .emacs: - (let ((opam-share (ignore-errors (car (process-lines \"opam\" \"config\" \"var\" \"share\"))))) - (when (and opam-share (file-directory-p opam-share)) - ;; Register Merlin - (add-to-list 'load-path (expand-file-name \"emacs/site-lisp\" opam-share)) - (autoload 'merlin-mode \"merlin\" nil t nil) - ;; Automatically start it in OCaml buffers - (add-hook 'tuareg-mode-hook 'merlin-mode t) - (add-hook 'caml-mode-hook 'merlin-mode t) - ;; Use opam switch to lookup ocamlmerlin binary - (setq merlin-command 'opam))) - -Take a look at https://github.com/ocaml/merlin for more information - -Quick setup with opam-user-setup --------------------------------- - -Opam-user-setup support Merlin. - - $ opam user-setup install - -should take care of basic setup. -See https://github.com/OCamlPro/opam-user-setup -" - {success & !user-setup:installed} -] -url { - src: - "https://github.com/ocaml/merlin/releases/download/v3.3.2/merlin-v3.3.2.tbz" - checksum: [ - "sha256=1d1c71e663b1e58acf19069cebd1e8d18f7dbe513c6065347d162cdd2c2de801" - "sha512=3ae021669808a40b4449f1cbdaca40b605ea5779a6204addd8b0ee4af9f14f528d55ca43a8dd3c7d547fb8e4cb256c09a9151d5559ef24dad83b5ab05aa146a2" - ] -} diff --git a/esy.lock/opam/ocaml-migrate-parsetree.1.4.0/opam b/esy.lock/opam/ocaml-migrate-parsetree.1.4.0/opam deleted file mode 100644 index 66d40bacd..000000000 --- a/esy.lock/opam/ocaml-migrate-parsetree.1.4.0/opam +++ /dev/null @@ -1,37 +0,0 @@ -opam-version: "2.0" -maintainer: "frederic.bour@lakaban.net" -authors: [ - "Frédéric Bour " - "Jérémie Dimino " -] -license: "LGPL-2.1-only with OCaml-LGPL-linking-exception" -homepage: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree" -bug-reports: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/issues" -dev-repo: "git+https://github.com/ocaml-ppx/ocaml-migrate-parsetree.git" -doc: "https://ocaml-ppx.github.io/ocaml-migrate-parsetree/" -tags: [ "syntax" "org:ocamllabs" ] -build: [ - ["dune" "build" "-p" name "-j" jobs] -] -depends: [ - "result" - "ppx_derivers" - "dune" {>= "1.9.0"} - "ocaml" {>= "4.02.3"} -] -synopsis: "Convert OCaml parsetrees between different versions" -description: """ -Convert OCaml parsetrees between different versions - -This library converts parsetrees, outcometree and ast mappers between -different OCaml versions. High-level functions help making PPX -rewriters independent of a compiler version. -""" -url { - src: - "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/releases/download/v1.4.0/ocaml-migrate-parsetree-v1.4.0.tbz" - checksum: [ - "sha256=231fbdc205187b3ee266b535d9cfe44b599067b2f6e97883c782ea7bb577d3b8" - "sha512=61ee91d2d146cc2d2ff2d5dc4ef5dea4dc4d3c8dbd8b4c9586d64b6ad7302327ab35547aa0a5b0103c3f07b66b13d416a1bee6d4d117293cd3cabe44113ec6d4" - ] -} diff --git a/esy.lock/opam/odoc.1.4.2/opam b/esy.lock/opam/odoc.1.5.0/opam similarity index 50% rename from esy.lock/opam/odoc.1.4.2/opam rename to esy.lock/opam/odoc.1.5.0/opam index d34a983fa..99f9336f3 100644 --- a/esy.lock/opam/odoc.1.4.2/opam +++ b/esy.lock/opam/odoc.1.5.0/opam @@ -1,8 +1,7 @@ opam-version: "2.0" -version: "1.4.2" homepage: "http://github.com/ocaml/odoc" -doc: "https://github.com/ocaml/odoc#readme" +doc: "https://ocaml.github.io/odoc/" bug-reports: "https://github.com/ocaml/odoc/issues" license: "ISC" @@ -10,26 +9,32 @@ authors: [ "Thomas Refis " "David Sheets " "Leo White " + "Anton Bachin " + "Jon Ludlam " ] maintainer: "Anton Bachin " dev-repo: "git+https://github.com/ocaml/odoc.git" synopsis: "OCaml documentation generator" +description: """ +Odoc is a documentation generator for OCaml. It reads doc comments, +delimited with `(** ... *)`, and outputs HTML. +""" depends: [ - "astring" {build} - "cmdliner" {build & >= "1.0.0"} + "astring" + "cmdliner" "cppo" {build} "dune" - "fpath" {build} + "fpath" "ocaml" {>= "4.02.0"} - "result" {build} - "tyxml" {build & >= "4.3.0"} + "result" + "tyxml" {>= "4.3.0"} "alcotest" {dev & >= "0.8.3"} "markup" {dev & >= "0.8.0"} "ocamlfind" {dev} - "sexplib" {dev & >= "113.33.00" & < "v0.13"} + "sexplib" {dev & >= "113.33.00"} "bisect_ppx" {with-test & >= "1.3.0"} ] @@ -38,8 +43,10 @@ build: [ ["dune" "subst"] {pinned} ["dune" "build" "-p" name "-j" jobs] ] - url { - src: "https://github.com/ocaml/odoc/archive/1.4.2.tar.gz" - checksum: "md5=d75ce63539040cd199d22203d46fc5f3" + src: "https://github.com/ocaml/odoc/releases/download/1.5.0/odoc-1.5.0.tbz" + checksum: [ + "sha256=857759be968070bfda208add3ae2c2bc87826ca2bfc39cebab1cc1e13db7a140" + "sha512=9573230f6ebd7f95d44a5e34f6de68f6b1b530cc7987402f84532e339498dde702082517066c4db428a334510af625db8055ecd03d91b57dd599fd5b3ac53f49" + ] } diff --git a/esy.lock/opam/ppx_tools_versioned.5.2.3/opam b/esy.lock/opam/ppx_tools_versioned.5.2.3/opam deleted file mode 100644 index dbf79a1b0..000000000 --- a/esy.lock/opam/ppx_tools_versioned.5.2.3/opam +++ /dev/null @@ -1,30 +0,0 @@ -opam-version: "2.0" -maintainer: "frederic.bour@lakaban.net" -authors: [ - "Frédéric Bour " - "Alain Frisch " -] -license: "MIT" -homepage: "https://github.com/ocaml-ppx/ppx_tools_versioned" -bug-reports: "https://github.com/ocaml-ppx/ppx_tools_versioned/issues" -dev-repo: "git://github.com/ocaml-ppx/ppx_tools_versioned.git" -tags: [ "syntax" ] -build: [ - ["dune" "subst"] {pinned} - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} -] -depends: [ - "ocaml" {>= "4.02.0"} - "dune" {>= "1.0"} - "ocaml-migrate-parsetree" {>= "1.4.0"} -] -synopsis: "A variant of ppx_tools based on ocaml-migrate-parsetree" -url { - src: - "https://github.com/ocaml-ppx/ppx_tools_versioned/archive/5.2.3.tar.gz" - checksum: [ - "md5=b1455e5a4a1bcd9ddbfcf712ccbd4262" - "sha512=af20aa0031b9c638537bcdb52c75de95f316ae8fd455a38672a60da5c7c6895cca9dbecd5d56a88c3c40979c6a673a047d986b5b41e1e84b528b7df5d905b9b1" - ] -} diff --git a/esy.lock/opam/seq.0.2/opam b/esy.lock/opam/seq.0.2.2/opam similarity index 51% rename from esy.lock/opam/seq.0.2/opam rename to esy.lock/opam/seq.0.2.2/opam index 55c46960c..5ed516543 100644 --- a/esy.lock/opam/seq.0.2/opam +++ b/esy.lock/opam/seq.0.2.2/opam @@ -2,21 +2,23 @@ opam-version: "2.0" synopsis: "Compatibility package for OCaml's standard iterator type starting from 4.07" maintainer: "simon.cruanes.2007@m4x.org" -authors: "Simon Cruanes" license: "LGPL2.1" -tags: ["iterator" "seq" "pure" "list" "compatibility" "cascade"] -homepage: "https://github.com/c-cube/seq/" -bug-reports: "https://github.com/c-cube/seq/issues" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] depends: [ "dune" {>= "1.1.0"} - "ocaml" {< "4.07.0"} + "ocaml" ] -build: ["dune" "build" "-p" name "-j" jobs] +tags: [ "iterator" "seq" "pure" "list" "compatibility" "cascade" ] +homepage: "https://github.com/c-cube/seq/" +bug-reports: "https://github.com/c-cube/seq/issues" dev-repo: "git+https://github.com/c-cube/seq.git" +authors: "Simon Cruanes" url { - src: "https://github.com/c-cube/seq/archive/0.2.tar.gz" + src: "https://github.com/c-cube/seq/archive/0.2.2.tar.gz" checksum: [ - "md5=1d5a9d0aba27b22433f518cdc495d0fd" - "sha512=b2571225a18e624b79dad5e1aab91b22e2fda17702f2e23c438b75d2a71e24c55ee8672005f5cc4b17ae79e3b277b1918b71b5d0d674b8b12ea19b3fb2d747cb" + "md5=9033e02283aa3bde9f97f24e632902e3" + "sha512=cab0eb4cb6d9788b7cbd7acbefefc15689d706c97ff7f75dd97faf3c21e466af4d0ff110541a24729db587e7172b1a30a3c2967e17ec2e49cbd923360052c07c" ] -} \ No newline at end of file +} diff --git a/esy.lock/opam/utop.2.2.0/opam b/esy.lock/opam/utop.2.2.0/opam deleted file mode 100644 index 2dea6484c..000000000 --- a/esy.lock/opam/utop.2.2.0/opam +++ /dev/null @@ -1,35 +0,0 @@ -opam-version: "2.0" -maintainer: "jeremie@dimino.org" -authors: ["Jérémie Dimino"] -license: "BSD-3-Clause" -homepage: "https://github.com/diml/utop" -bug-reports: "https://github.com/diml/utop/issues" -dev-repo: "git+https://github.com/diml/utop.git" -build: [ - ["jbuilder" "subst" "-p" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] - ["jbuilder" "runtest" "-p" name "-j" jobs] {with-test} -] -depends: [ - "ocaml" {>= "4.02.3" & < "4.08.0"} - "base-unix" - "base-threads" - "ocamlfind" {>= "1.7.2"} - "lambda-term" {>= "1.2" & < "2.0"} - "lwt" - "lwt_react" - "camomile" - "react" {>= "1.0.0"} - "cppo" {build & >= "1.1.2"} - "jbuilder" {>= "1.0+beta9"} -] -synopsis: "Universal toplevel for OCaml" -description: """ -utop is an improved toplevel (i.e., Read-Eval-Print Loop or REPL) for -OCaml. It can run in a terminal or in Emacs. It supports line -edition, history, real-time and context sensitive completion, colors, -and more. It integrates with the Tuareg mode in Emacs.""" -url { - src: "https://github.com/diml/utop/releases/download/2.2.0/utop-2.2.0.tbz" - checksum: "md5=c8e4805883ce27a2ef27b0e4322d6f04" -} diff --git a/esy.lock/opam/utop.2.4.3/opam b/esy.lock/opam/utop.2.4.3/opam new file mode 100644 index 000000000..f14fa1014 --- /dev/null +++ b/esy.lock/opam/utop.2.4.3/opam @@ -0,0 +1,41 @@ +opam-version: "2.0" +maintainer: "jeremie@dimino.org" +authors: "Jérémie Dimino" +license: "BSD3" +homepage: "https://github.com/ocaml-community/utop" +bug-reports: "https://github.com/ocaml-community/utop/issues" +doc: "https://ocaml-community.github.io/utop/" +depends: [ + "ocaml" {>= "4.03.0" & < "4.11"} + "base-unix" + "base-threads" + "ocamlfind" {>= "1.7.2"} + "lambda-term" {>= "2.0" & < "3.0"} + "lwt" + "lwt_react" + "camomile" + "react" {>= "1.0.0"} + "cppo" {build & >= "1.1.2"} + "dune" {>= "1.0"} +] +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +dev-repo: "git+https://github.com/ocaml-community/utop.git" +synopsis: "Universal toplevel for OCaml" +description: """ +utop is an improved toplevel (i.e., Read-Eval-Print Loop or REPL) for +OCaml. It can run in a terminal or in Emacs. It supports line +edition, history, real-time and context sensitive completion, colors, +and more. It integrates with the Tuareg mode in Emacs. +""" +url { + src: + "https://github.com/ocaml-community/utop/releases/download/2.4.3/utop-2.4.3.tbz" + checksum: [ + "sha256=4e30ba6e224bea5776bc1a6ac3fee7f7548a35acf41d35e59c45913e28a0ea80" + "sha512=507917f4256c4a37058a106598a61aa092301f008b7e9385950a615e37b7f1a217f1e3b116678cb90ef1938c038ed135dabf2f9987c8fec21b5eb322a005632a" + ] +} diff --git a/esy.lock/opam/zed.1.6/opam b/esy.lock/opam/zed.2.0.5/opam similarity index 60% rename from esy.lock/opam/zed.1.6/opam rename to esy.lock/opam/zed.2.0.5/opam index 9cd69330b..71ef91b06 100644 --- a/esy.lock/opam/zed.1.6/opam +++ b/esy.lock/opam/zed.2.0.5/opam @@ -1,21 +1,21 @@ opam-version: "2.0" maintainer: "opam-devel@lists.ocaml.org" authors: ["Jérémie Dimino"] -homepage: "https://github.com/diml/zed" -bug-reports: "https://github.com/diml/zed/issues" -dev-repo: "git://github.com/diml/zed.git" +homepage: "https://github.com/ocaml-community/zed" +bug-reports: "https://github.com/ocaml-community/zed/issues" +dev-repo: "git://github.com/ocaml-community/zed.git" license: "BSD-3-Clause" depends: [ "ocaml" {>= "4.02.3"} - "jbuilder" {>= "1.0+beta9"} + "dune" {>= "1.1.0"} "base-bytes" - "camomile" {>= "0.8"} + "camomile" {>= "1.0.1"} "react" + "charInfo_width" {>= "1.1.0" & < "2.0~"} ] build: [ - ["jbuilder" "subst" "-p" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] - ["jbuilder" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] synopsis: "Abstract engine for text edition in OCaml" description: """ @@ -27,6 +27,6 @@ Unicode buffers. Zed also features a regular expression search on ropes. To support efficient text edition capabilities, Zed provides macro recording and cursor management facilities.""" url { - src: "https://github.com/diml/zed/releases/download/1.6/zed-1.6.tbz" - checksum: "md5=f75c3094af1a22f9801d5ca5eb2d40e0" + src: "https://github.com/ocaml-community/zed/releases/download/2.0.5/zed-2.0.5.tbz" + checksum: "md5=56414179d7cccba0e20005d958b5d39e" } diff --git a/esy.lock/overrides/opam__s__dune_opam__c__1.11.4_opam_override/package.json b/esy.lock/overrides/opam__s__dune_opam__c__1.11.4_opam_override/package.json deleted file mode 100644 index 064c7e390..000000000 --- a/esy.lock/overrides/opam__s__dune_opam__c__1.11.4_opam_override/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "build": [ - [ - "ocaml", - "bootstrap.ml" - ], - [ - "./boot.exe", - "--release", - "-j", - "4" - ] - ] -} diff --git a/esy.lock/overrides/opam__s__lambda_term_opam__c__1.13_opam_override/files/lambda-term-1.13.patch b/esy.lock/overrides/opam__s__lambda_term_opam__c__1.13_opam_override/files/lambda-term-1.13.patch deleted file mode 100644 index 563657b6d..000000000 --- a/esy.lock/overrides/opam__s__lambda_term_opam__c__1.13_opam_override/files/lambda-term-1.13.patch +++ /dev/null @@ -1,88 +0,0 @@ ---- ./src/lTerm_windows_stubs.c -+++ ./src/lTerm_windows_stubs.c -@@ -16,7 +16,6 @@ - - #if defined(_WIN32) || defined(_WIN64) - --#include - #include - - /* +-----------------------------------------------------------------+ -@@ -140,15 +139,7 @@ - } - } - --CAMLprim value lt_windows_read_console_input_job(value val_fd) --{ -- LWT_UNIX_INIT_JOB(job, read_console_input, 0); -- job->handle = Handle_val(val_fd); -- job->error_code = 0; -- CAMLreturn(lwt_unix_alloc_job(&(job->job))); --} -- --static value result_read_console_input_result(struct job_read_console_input *job) -+static value result_read_console_input(struct job_read_console_input *job) - { - INPUT_RECORD input; - DWORD cks, bs; -@@ -163,23 +154,23 @@ - win32_maperr(error_code); - uerror("ReadConsoleInput", Nothing); - } -- switch (input->EventType) { -+ switch (input.EventType) { - case KEY_EVENT: { - result = caml_alloc(1, 0); - x = caml_alloc_tuple(4); - Field(result, 0) = x; -- cks = input->Event.KeyEvent.dwControlKeyState; -+ cks = input.Event.KeyEvent.dwControlKeyState; - Field(x, 0) = Val_bool((cks & LEFT_CTRL_PRESSED) | (cks & RIGHT_CTRL_PRESSED)); - Field(x, 1) = Val_bool((cks & LEFT_ALT_PRESSED) | (cks & RIGHT_ALT_PRESSED)); - Field(x, 2) = Val_bool(cks & SHIFT_PRESSED); -- code = input->Event.KeyEvent.wVirtualKeyCode; -+ code = input.Event.KeyEvent.wVirtualKeyCode; - for (i = 0; i < sizeof(code_table)/sizeof(code_table[0]); i++) - if (code == code_table[i]) { - Field(x, 3) = Val_int(i); - CAMLreturn(result); - } - y = caml_alloc_tuple(1); -- Field(y, 0) = Val_int(input->Event.KeyEvent.uChar.UnicodeChar); -+ Field(y, 0) = Val_int(input.Event.KeyEvent.uChar.UnicodeChar); - Field(x, 3) = y; - CAMLreturn(result); - } -@@ -187,13 +178,13 @@ - result = caml_alloc(1, 1); - x = caml_alloc_tuple(6); - Field(result, 0) = x; -- cks = input->Event.MouseEvent.dwControlKeyState; -+ cks = input.Event.MouseEvent.dwControlKeyState; - Field(x, 0) = Val_bool((cks & LEFT_CTRL_PRESSED) | (cks & RIGHT_CTRL_PRESSED)); - Field(x, 1) = Val_bool((cks & LEFT_ALT_PRESSED) | (cks & RIGHT_ALT_PRESSED)); - Field(x, 2) = Val_bool(cks & SHIFT_PRESSED); -- Field(x, 4) = Val_int(input->Event.MouseEvent.dwMousePosition.Y); -- Field(x, 5) = Val_int(input->Event.MouseEvent.dwMousePosition.X); -- bs = input->Event.MouseEvent.dwButtonState; -+ Field(x, 4) = Val_int(input.Event.MouseEvent.dwMousePosition.Y); -+ Field(x, 5) = Val_int(input.Event.MouseEvent.dwMousePosition.X); -+ bs = input.Event.MouseEvent.dwButtonState; - if (bs & FROM_LEFT_1ST_BUTTON_PRESSED) - Field(x, 3) = Val_int(0); - else if (bs & FROM_LEFT_2ND_BUTTON_PRESSED) -@@ -212,6 +203,14 @@ - CAMLreturn(Val_int(0)); - } - -+CAMLprim value lt_windows_read_console_input_job(value val_fd) -+{ -+ LWT_UNIX_INIT_JOB(job, read_console_input, 0); -+ job->handle = Handle_val(val_fd); -+ job->error_code = 0; -+ return (lwt_unix_alloc_job(&(job->job))); -+} -+ - /* +-----------------------------------------------------------------+ - | Console informations | - +-----------------------------------------------------------------+ */ diff --git a/esy.lock/overrides/opam__s__lambda_term_opam__c__1.13_opam_override/package.json b/esy.lock/overrides/opam__s__lambda_term_opam__c__1.13_opam_override/package.json deleted file mode 100644 index 3c22b23a6..000000000 --- a/esy.lock/overrides/opam__s__lambda_term_opam__c__1.13_opam_override/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "build": [ - [ - "bash", - "-c", - "#{os == 'windows' ? 'patch -p1 < lambda-term-1.13.patch' : 'true'}" - ], - [ - "jbuilder", - "build", - "-p", - "lambda-term", - "-j", - "4" - ] - ] -} diff --git a/esy.lock/overrides/opam__s__utop_opam__c__2.2.0_opam_override/files/utop-2.2.0.patch b/esy.lock/overrides/opam__s__utop_opam__c__2.2.0_opam_override/files/utop-2.2.0.patch deleted file mode 100644 index f219f4bdb..000000000 --- a/esy.lock/overrides/opam__s__utop_opam__c__2.2.0_opam_override/files/utop-2.2.0.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- ./src/lib/uTop_main.ml -+++ ./src/lib/uTop_main.ml -@@ -1308,6 +1308,9 @@ - (* We lost the terminal. *) - catch Sys.sighup; - (* Termination request. *) -+ if Sys.win32 && !emacs_mode then -+ Sys.set_signal Sys.sigterm Sys.Signal_ignore -+ else - catch Sys.sigterm - - let load_inputrc () = ---- ./src/top/expunge/expunge.ml -+++ ./src/top/expunge/expunge.ml -@@ -3,7 +3,9 @@ - - let run_and_read_lines args = - let cmd = String.concat ~sep:" " (List.map args ~f:Filename.quote) in -+ let cmd = if Sys.win32 then "\"" ^ cmd ^ "\"" else cmd in - let ic = Unix.open_process_in cmd in -+ set_binary_mode_in ic false; - let rec loop acc = - match input_line ic with - | exception End_of_file -> List.rev acc -@@ -60,6 +62,7 @@ - (Filename.quote dst) - (String.concat ~sep:" " (S.elements modules_to_keep)) - in -+ let cmdline = if Sys.win32 then "\"" ^ cmdline ^ "\"" else cmdline in - if verbose then prerr_endline cmdline; - exit (Sys.command cmdline) - diff --git a/esy.lock/overrides/opam__s__utop_opam__c__2.2.0_opam_override/package.json b/esy.lock/overrides/opam__s__utop_opam__c__2.2.0_opam_override/package.json deleted file mode 100644 index 914dfe88a..000000000 --- a/esy.lock/overrides/opam__s__utop_opam__c__2.2.0_opam_override/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "build": [ - [ - "bash", - "-c", - "#{os == 'windows' ? 'patch -p1 < utop-2.2.0.patch' : 'true' }" - ], - [ - "jbuilder", - "build", - "-p", - "utop", - "-j", - "4" - ] - ] -} diff --git a/formatTest/typeCheckedTests/expected_output/features406.4.06.0.re b/formatTest/typeCheckedTests/expected_output/features406.4.06.0.re new file mode 100644 index 000000000..1ef225e53 --- /dev/null +++ b/formatTest/typeCheckedTests/expected_output/features406.4.06.0.re @@ -0,0 +1,27 @@ +module EM = { + /** Exception */ + + exception E(int, int); +}; + +/* Pcl_open */ +class x = { + open EM; + as self; +}; + +module OM = { + type t; +}; + +class y = { + open EM; + open OM; + as self; +}; + +module type S = { + type t = pri ..; + type t += + | Foo; +}; diff --git a/formatTest/typeCheckedTests/expected_output/features408.4.08.0.re b/formatTest/typeCheckedTests/expected_output/features408.4.08.0.re new file mode 100644 index 000000000..e1a9631b7 --- /dev/null +++ b/formatTest/typeCheckedTests/expected_output/features408.4.08.0.re @@ -0,0 +1,19 @@ +open { + type t = string; + }; + +let (let+) = (x, f) => List.map(f, x); + +let (and+) = List.map2((x, y) => (x, y)); + +let x = { + let+ x = [2] + and+ y = [3]; + + (x, y); +}; + +let y = { + let+ x = [2]; + x; +}; diff --git a/formatTest/typeCheckedTests/expected_output/features408.4.08.0.rei b/formatTest/typeCheckedTests/expected_output/features408.4.08.0.rei new file mode 100644 index 000000000..ae50e8341 --- /dev/null +++ b/formatTest/typeCheckedTests/expected_output/features408.4.08.0.rei @@ -0,0 +1,22 @@ +module X: {type t;}; + +module M := X; + +[@attr] +module N := X; + +type y = int; + +type z = int; + +type t = int; + +type x := y; + +[@attr1] +type y := z +[@attr2] +and w := t; + +type x' = | +and y' = |; diff --git a/formatTest/typeCheckedTests/expected_output/letop.re b/formatTest/typeCheckedTests/expected_output/letop.re new file mode 100644 index 000000000..fad703713 --- /dev/null +++ b/formatTest/typeCheckedTests/expected_output/letop.re @@ -0,0 +1,44 @@ +let (let.opt) = (x, f) => + switch (x) { + | None => None + | Some(x) => f(x) + }; +let (let.&opt) = (x, f) => + switch (x) { + | None => None + | Some(x) => Some(f(x)) + }; + +let z = { + let.opt a = Some(2); + let.&opt b = Some(5); + a + b; +}; + +let (let./\/) = (x, f) => + switch (x) { + | None => None + | Some(x) => f(x) + }; +let ( let.&/\* ) = (x, f) => + switch (x) { + | None => None + | Some(x) => Some(f(x)) + }; + +/* Test syntax that could potentially conflict with comments */ +let z = { + let./\/ a = Some(2); + let.&/\* b = Some(5); + a + b; +}; + +let _ = { + let.opt _ = Some("a"); + + let.opt _ = Some("c"); + + // hello + + None; +}; diff --git a/formatTest/typeCheckedTests/expected_output/newAST.4.06.0.re b/formatTest/typeCheckedTests/expected_output/newAST.4.06.0.re new file mode 100644 index 000000000..6d767e348 --- /dev/null +++ b/formatTest/typeCheckedTests/expected_output/newAST.4.06.0.re @@ -0,0 +1,35 @@ +/* Oinherit (https://github.com/ocaml/ocaml/pull/1118) */ +type t = {. a: string}; + +type t1 = { + . + n: string, + ...t, +}; + +type t2('a) = + { + .. + o: string, + ...t, + } as 'a; + +/* Pcl_open, Pcty_open (https://github.com/ocaml/ocaml/pull/1249) */ +module EM = { + type t; +}; + +module OM = { + type t; +}; + +class x = { + open EM; + as self; +}; + +class y = { + open EM; + open OM; + as self; +}; diff --git a/formatTest/typeCheckedTests/input/features406.4.06.0.ml b/formatTest/typeCheckedTests/input/features406.4.06.0.ml new file mode 100644 index 000000000..4be05c44b --- /dev/null +++ b/formatTest/typeCheckedTests/input/features406.4.06.0.ml @@ -0,0 +1,18 @@ +module EM = struct + (** Exception *) + exception E of int * int +end + +(* Pcl_open *) +class x = let open EM in object (self) end + +module OM = struct + type t +end + +class y = let open EM in let open OM in object (self) end + +module type S = sig + type t = private .. + type t += Foo +end diff --git a/formatTest/typeCheckedTests/input/features408.4.08.0.ml b/formatTest/typeCheckedTests/input/features408.4.08.0.ml new file mode 100644 index 000000000..52e986cae --- /dev/null +++ b/formatTest/typeCheckedTests/input/features408.4.08.0.ml @@ -0,0 +1,17 @@ +open struct + type t = string +end + +let (let+) x f = List.map f x + +let (and+) = List.map2 (fun x y -> x,y) + +let x = + let+ x = [2] + and+ y = [3] + in + x, y + +let y = + let+ x = [2] in + x diff --git a/formatTest/typeCheckedTests/input/features408.4.08.0.mli b/formatTest/typeCheckedTests/input/features408.4.08.0.mli new file mode 100644 index 000000000..faf535a98 --- /dev/null +++ b/formatTest/typeCheckedTests/input/features408.4.08.0.mli @@ -0,0 +1,20 @@ +module X : sig + type t +end + +module M := X + +module N := X [@@attr] + +type y = int + +type z = int + +type t = int + +type x := y + +type y := z [@@attr1] +and w := t [@@attr2] + +type x' = | and y' = | diff --git a/formatTest/typeCheckedTests/input/letop.re b/formatTest/typeCheckedTests/input/letop.re new file mode 100644 index 000000000..43451382d --- /dev/null +++ b/formatTest/typeCheckedTests/input/letop.re @@ -0,0 +1,28 @@ +let (let.opt) = (x, f) => switch x { | None => None | Some(x) => f(x) }; +let (let.&opt) = (x, f) => switch x { | None => None | Some(x) => Some(f(x)) }; + +let z = { + let.opt a = Some(2); + let.&opt b = Some(5); + a + b +} + +let (let./\/) = (x, f) => switch x { | None => None | Some(x) => f(x) }; +let (let.&/\*) = (x, f) => switch x { | None => None | Some(x) => Some(f(x)) }; + +/* Test syntax that could potentially conflict with comments */ +let z = { + let./\/ a = Some(2); + let.&/\* b = Some(5); + a + b +} + +let _ = { + let.opt _ = Some("a"); + + let.opt _ = Some("c"); + + // hello + + None; +}; diff --git a/formatTest/typeCheckedTests/input/mlSyntax.ml b/formatTest/typeCheckedTests/input/mlSyntax.ml index a0dabb396..e501ecec2 100644 --- a/formatTest/typeCheckedTests/input/mlSyntax.ml +++ b/formatTest/typeCheckedTests/input/mlSyntax.ml @@ -83,3 +83,4 @@ external pri : unit -> unit = "" type pub = int type pub_ = int + diff --git a/formatTest/typeCheckedTests/input/newAST.4.06.0.re b/formatTest/typeCheckedTests/input/newAST.4.06.0.re new file mode 100644 index 000000000..198c3f5fc --- /dev/null +++ b/formatTest/typeCheckedTests/input/newAST.4.06.0.re @@ -0,0 +1,37 @@ +/* Oinherit (https://github.com/ocaml/ocaml/pull/1118) */ +type t = { + . + a: string +}; + +type t1 = { + . + n: string, + ...t, +}; + +type t2('a) = { + .. + o: string, + ...t, +} as 'a; + +/* Pcl_open, Pcty_open (https://github.com/ocaml/ocaml/pull/1249) */ +module EM = { + type t; +}; + +module OM = { + type t; +}; + +class x = { + open EM; + as self; +}; + +class y = { + open EM; + open OM; + as self; +}; diff --git a/formatTest/unit_tests/expected_output/class_types.re b/formatTest/unit_tests/expected_output/class_types.re index 61f147c84..9d0ecdd8d 100644 --- a/formatTest/unit_tests/expected_output/class_types.re +++ b/formatTest/unit_tests/expected_output/class_types.re @@ -27,3 +27,12 @@ class classWithNoArg = { pub x = 0; pub y = 0; }; + +class type t = { + open M; + as 'a; +}; + +class type t = { + open M; +}; diff --git a/formatTest/unit_tests/expected_output/object.re b/formatTest/unit_tests/expected_output/object.re index b23ba10ba..4251dd614 100644 --- a/formatTest/unit_tests/expected_output/object.re +++ b/formatTest/unit_tests/expected_output/object.re @@ -49,3 +49,30 @@ type o2 = { }; let obj = {as _; [@foo] val a = 1}; + +/* Oinherit (https://github.com/ocaml/ocaml/pull/1118) */ +type t1 = { + . + n: string, + ...t, +}; + +type t1 = { + .. + n: string, + ...t, +}; + +type g1 = { + . + n: string, + ...t, + ...y, +}; + +type g2 = { + . + n: string, + ...t, + ...y, +}; diff --git a/formatTest/unit_tests/expected_output/syntax.re b/formatTest/unit_tests/expected_output/syntax.re index 43849e736..13a8959d2 100644 --- a/formatTest/unit_tests/expected_output/syntax.re +++ b/formatTest/unit_tests/expected_output/syntax.re @@ -1445,3 +1445,15 @@ try({ }) { | _ => () }; + +/* Pcl_open (4.06+) */ +class x = { + open EM; + as self; +}; + +class y = { + open EM; + open OM; + as self; +}; diff --git a/formatTest/unit_tests/expected_output/variants.re b/formatTest/unit_tests/expected_output/variants.re index 38f6f983d..fa61fd7e0 100644 --- a/formatTest/unit_tests/expected_output/variants.re +++ b/formatTest/unit_tests/expected_output/variants.re @@ -683,3 +683,10 @@ type t = B | /** Some more longer docs over here that make sense to break lines on too */ C; + +/* https://github.com/facebook/reason/issues/1828 */ +type widget_state = [ + | `DEFAULT /* here */ + | `HOVER + | `ACTIVE +]; diff --git a/formatTest/unit_tests/input/class_types.re b/formatTest/unit_tests/input/class_types.re index af7ff40a4..168306e5a 100644 --- a/formatTest/unit_tests/input/class_types.re +++ b/formatTest/unit_tests/input/class_types.re @@ -26,3 +26,12 @@ class classWithNoArg { pub x = 0; pub y = 0 }; + +class type t = { + open M; + as 'a; +}; + +class type t = { + open M; +}; diff --git a/formatTest/unit_tests/input/object.re b/formatTest/unit_tests/input/object.re index 4fb8215d6..3ef4f384f 100644 --- a/formatTest/unit_tests/input/object.re +++ b/formatTest/unit_tests/input/object.re @@ -43,3 +43,30 @@ type o2 = { }; let obj = {as _; [@foo] val a = 1}; + +/* Oinherit (https://github.com/ocaml/ocaml/pull/1118) */ +type t1 = { + . + n: string, + ...t, +}; + +type t1 = { + .. + n: string, + ...t, +}; + +type g1 = { + . + n: string, + ...t, + ...y, +}; + +type g2 = { + . + n: string, + ...t, + ...y, +}; diff --git a/formatTest/unit_tests/input/syntax.re b/formatTest/unit_tests/input/syntax.re index 122ee09da..a579f2f01 100644 --- a/formatTest/unit_tests/input/syntax.re +++ b/formatTest/unit_tests/input/syntax.re @@ -1264,3 +1264,15 @@ try({ }) { | _ => () }; + +/* Pcl_open (4.06+) */ +class x = { + open EM; + as self; +}; + +class y = { + open EM; + open OM; + as self; +}; diff --git a/formatTest/unit_tests/input/variants.re b/formatTest/unit_tests/input/variants.re index 6df72ab12..b3dccec37 100644 --- a/formatTest/unit_tests/input/variants.re +++ b/formatTest/unit_tests/input/variants.re @@ -420,3 +420,10 @@ type t = B | /** Some more longer docs over here that make sense to break lines on too */ C; + +/* https://github.com/facebook/reason/issues/1828 */ +type widget_state = [ + | `DEFAULT /* here */ + | `HOVER + | `ACTIVE + ]; diff --git a/miscTests/backportSyntaxTests.sh b/miscTests/backportSyntaxTests.sh new file mode 100755 index 000000000..15fb77504 --- /dev/null +++ b/miscTests/backportSyntaxTests.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +echo "Testing the backport of 'letop'" +testPath="./miscTests/backport_syntax_tests" +input=$testPath/basic.re +output=$testPath/basic.bin +binary=$testPath/bin + +./_build/install/default/bin/refmt $input --print binary > $output +ocamlc -impl $output -o $binary +$binary +rm $output $binary $testPath/basic.cm* diff --git a/miscTests/backport_syntax_tests/basic.re b/miscTests/backport_syntax_tests/basic.re new file mode 100644 index 000000000..f5aa53d54 --- /dev/null +++ b/miscTests/backport_syntax_tests/basic.re @@ -0,0 +1,21 @@ + +let (let.opt) = (x, f) => switch x { | None => None | Some(x) => f(x) }; +let (let.&opt) = (x, f) => switch x { | None => None | Some(x) => Some(f(x)) }; +let (and.opt) = (a, b) => switch (a, b) { | (Some(a), Some(b)) => Some((a, b)) | _ => None }; + +let x = { + let.opt a = Some(1); + let.opt b = Some(2) + and.opt c = Some(3) + and.opt d = Some(4); + Some((a, b, c, d)) +} +let y = { + let.opt a = Some(1) + and.opt b = None + and.opt c = Some(4); + Some((a, b, c)) +} +assert(x == Some((1,2,3,4))); +assert(y == None); +print_endline("Success") \ No newline at end of file diff --git a/src/ppx/reactjs_jsx_ppx_v2.ml b/src/ppx/reactjs_jsx_ppx_v2.ml index 272b39719..a36ef88ee 100644 --- a/src/ppx/reactjs_jsx_ppx_v2.ml +++ b/src/ppx/reactjs_jsx_ppx_v2.ml @@ -43,11 +43,11 @@ (* #if defined BS_NO_COMPILER_PATCH then *) open Migrate_parsetree -open Ast_404 -module To_current = Convert(OCaml_404)(OCaml_current) +open Ast_408 +module To_current = Convert(OCaml_408)(OCaml_current) -let nolabel = Ast_404.Asttypes.Nolabel -let labelled str = Ast_404.Asttypes.Labelled str +let nolabel = Ast_408.Asttypes.Nolabel +let labelled str = Ast_408.Asttypes.Labelled str let argIsKeyRef = function | (Asttypes.Labelled ("key" | "ref"), _) | (Asttypes.Optional ("key" | "ref"), _) -> true | _ -> false @@ -148,7 +148,7 @@ let jsxMapper () = (* [@JSX] div(~children=
), coming from
...
*) | { pexp_attributes - } when pexp_attributes |> List.exists (fun (attribute, _) -> attribute.txt = "JSX") -> + } when pexp_attributes |> List.exists (fun { attr_name = { txt }; _} -> txt = "JSX") -> raise (Invalid_argument "A spread + a JSX literal as a DOM element's \ children don't make sense written together. You can simply remove the spread.") | _ -> "createElementVariadic" @@ -245,10 +245,10 @@ let jsxMapper () = *) | { pstr_loc; - pstr_desc = Pstr_attribute ( - ({txt = "bs.config"} as bsConfigLabel), - PStr [{pstr_desc = Pstr_eval ({pexp_desc = Pexp_record (recordFields, b)} as innerConfigRecord, a)} as configRecord] - ) + pstr_desc = Pstr_attribute { + attr_name = ({txt = "bs.config"} as bsConfigLabel); + attr_payload = PStr [{pstr_desc = Pstr_eval ({pexp_desc = Pexp_record (recordFields, b)} as innerConfigRecord, a)} as configRecord] + }; _ }::restOfStructure -> begin let (jsxField, recordFieldsWithoutJsx) = recordFields |> List.partition (fun ({txt}, _) -> txt = Lident "jsx") in match (jsxField, recordFieldsWithoutJsx) with @@ -272,9 +272,10 @@ let jsxMapper () = | fields -> default_mapper.structure mapper ({ pstr_loc; pstr_desc = Pstr_attribute ( - bsConfigLabel, - PStr [{configRecord with pstr_desc = Pstr_eval ({innerConfigRecord with pexp_desc = Pexp_record (fields, b)}, a)}] - ) + { attr_name = bsConfigLabel; + attr_payload = PStr [{configRecord with pstr_desc = Pstr_eval ({innerConfigRecord with pexp_desc = Pexp_record (fields, b)}, a)}]; + attr_loc = bsConfigLabel.loc + }) }::restOfStructure) end | _ -> raise (Invalid_argument "JSX: the file-level bs.config's {jsx: ...} config accepts only a version number") @@ -289,7 +290,7 @@ let jsxMapper () = pexp_desc = Pexp_apply (callExpression, callArguments); pexp_attributes } -> - let (jsxAttribute, nonJSXAttributes) = List.partition (fun (attribute, _) -> attribute.txt = "JSX") pexp_attributes in + let (jsxAttribute, nonJSXAttributes) = List.partition (fun { attr_name = {txt}; _} -> txt = "JSX") pexp_attributes in (match (jsxAttribute, nonJSXAttributes) with (* no JSX attribute *) | ([], _) -> default_mapper.expr mapper expression @@ -302,7 +303,7 @@ let jsxMapper () = | Pexp_construct ({txt = Lident "[]"; loc}, None); pexp_attributes } as listItems -> - let (jsxAttribute, nonJSXAttributes) = List.partition (fun (attribute, _) -> attribute.txt = "JSX") pexp_attributes in + let (jsxAttribute, nonJSXAttributes) = List.partition (fun {attr_name = {txt}} -> txt = "JSX") pexp_attributes in (match (jsxAttribute, nonJSXAttributes) with (* no JSX attribute *) | ([], _) -> default_mapper.expr mapper expression diff --git a/src/reason-parser-tests/testOprint.cppo.ml b/src/reason-parser-tests/testOprint.cppo.ml index f66fd4dd5..0340139c2 100644 --- a/src/reason-parser-tests/testOprint.cppo.ml +++ b/src/reason-parser-tests/testOprint.cppo.ml @@ -21,8 +21,8 @@ open Migrate_parsetree -module Convert = Migrate_parsetree.Convert (OCaml_404) (OCaml_current) -module ConvertBack = Migrate_parsetree.Convert (OCaml_current) (OCaml_404) +module Convert = Migrate_parsetree.Convert (Migrate_parsetree.OCaml_408) (Migrate_parsetree.OCaml_current) +module ConvertBack = Migrate_parsetree.Convert (Migrate_parsetree.OCaml_current) (Migrate_parsetree.OCaml_408) let main () = let filename = "./TestTest.ml" in @@ -43,7 +43,7 @@ let main () = let env = Compmisc.initial_env() in let (typedtree, _) = Typemod.type_implementation modulename modulename modulename env ast in let tree = Printtyp.tree_of_signature typedtree.Typedtree.str_type in - let phrase = (Ast_404.Outcometree.Ophr_signature + let phrase = (Ast_408.Outcometree.Ophr_signature (List.map (fun item -> (ConvertBack.copy_out_sig_item item, None)) tree) ) in let fmt = Format.str_formatter in diff --git a/src/reason-parser/reason_attributes.ml b/src/reason-parser/reason_attributes.ml index 144fda937..db13e7c8b 100644 --- a/src/reason-parser/reason_attributes.ml +++ b/src/reason-parser/reason_attributes.ml @@ -1,5 +1,5 @@ open Migrate_parsetree -open Ast_404 +open Ast_408 open Location open Parsetree @@ -18,28 +18,28 @@ let rec partitionAttributes ?(partDoc=false) ?(allowUncurry=true) attrs : attrib match attrs with | [] -> {arityAttrs=[]; docAttrs=[]; stdAttrs=[]; jsxAttrs=[]; stylisticAttrs=[]; uncurried = false} - | (({txt = "bs"}, PStr []) as attr)::atTl -> + | ({ attr_name = {txt = "bs"}; attr_payload = PStr []; _ } as attr)::atTl -> let partition = partitionAttributes ~partDoc ~allowUncurry atTl in if allowUncurry then {partition with uncurried = true} else {partition with stdAttrs=attr::partition.stdAttrs} - | (({txt="JSX"}, _) as jsx)::atTl -> + | ({ attr_name = {txt="JSX"}; _ } as jsx)::atTl -> let partition = partitionAttributes ~partDoc ~allowUncurry atTl in {partition with jsxAttrs=jsx::partition.jsxAttrs} - | (({txt="explicit_arity"}, _) as arity_attr)::atTl - | (({txt="implicit_arity"}, _) as arity_attr)::atTl -> + | ({ attr_name = {txt="explicit_arity"}; _} as arity_attr)::atTl + | ({ attr_name = {txt="implicit_arity"}; _} as arity_attr)::atTl -> let partition = partitionAttributes ~partDoc ~allowUncurry atTl in {partition with arityAttrs=arity_attr::partition.arityAttrs} - | (({txt="ocaml.text"}, _) as doc)::atTl when partDoc = true -> + | ({ attr_name = {txt="ocaml.text"}; _} as doc)::atTl when partDoc = true -> let partition = partitionAttributes ~partDoc ~allowUncurry atTl in {partition with docAttrs=doc::partition.docAttrs} - | (({txt="ocaml.doc"}, _) as doc)::atTl when partDoc = true -> + | ({ attr_name = {txt="ocaml.doc"}; _} as doc)::atTl when partDoc = true -> let partition = partitionAttributes ~partDoc ~allowUncurry atTl in {partition with docAttrs=doc::partition.docAttrs} - | (({txt="reason.raw_literal"}, _) as attr) :: atTl -> + | ({ attr_name = {txt="reason.raw_literal"}; _} as attr) :: atTl -> let partition = partitionAttributes ~partDoc ~allowUncurry atTl in {partition with stylisticAttrs=attr::partition.stylisticAttrs} - | (({txt="reason.preserve_braces"}, _) as attr) :: atTl -> + | ({ attr_name = {txt="reason.preserve_braces"}; _} as attr) :: atTl -> let partition = partitionAttributes ~partDoc ~allowUncurry atTl in {partition with stylisticAttrs=attr::partition.stylisticAttrs} | atHd :: atTl -> @@ -51,8 +51,9 @@ let extractStdAttrs attrs = let extract_raw_literal attrs = let rec loop acc = function - | ({txt="reason.raw_literal"}, - PStr [{pstr_desc = Pstr_eval({pexp_desc = Pexp_constant(Pconst_string(text, None))}, _)}]) + | { attr_name = {txt="reason.raw_literal"}; + attr_payload = + PStr [{pstr_desc = Pstr_eval({pexp_desc = Pexp_constant(Pconst_string(text, None))}, _)}]} :: rest -> (Some text, List.rev_append acc rest) | [] -> (None, List.rev acc) @@ -69,7 +70,7 @@ let without_stylistic_attrs attrs = in loop [] attrs -let is_preserve_braces_attr ({txt}, _) = +let is_preserve_braces_attr { attr_name = {txt}; _} = txt = "reason.preserve_braces" let has_preserve_braces_attrs stylisticAttrs = @@ -80,6 +81,6 @@ let maybe_remove_stylistic_attrs attrs should_preserve = attrs else List.filter (function - | ({txt="reason.raw_literal"}, _) -> true + | { attr_name = {txt="reason.raw_literal"}; _} -> true | _ -> false) attrs diff --git a/src/reason-parser/reason_declarative_lexer.mll b/src/reason-parser/reason_declarative_lexer.mll index 22d1fcb5b..83c0608fd 100644 --- a/src/reason-parser/reason_declarative_lexer.mll +++ b/src/reason-parser/reason_declarative_lexer.mll @@ -320,6 +320,10 @@ let operator_chars = ['!' '$' '%' '&' '+' '-' ':' '<' '=' '>' '?' '@' '^' '|' '~' '#' '.'] | ( '\\'? ['/' '*'] ) +let dotsymbolchar = + ['!' '$' '%' '&' '*' '+' '-' '/' ':' '=' '>' '?' '@' '^' '|' '\\' 'a'-'z' 'A'-'Z' '_' '0'-'9'] +let kwdopchar = ['$' '&' '*' '+' '-' '/' '<' '=' '>' '@' '^' '|' '.' '!'] + let decimal_literal = ['0'-'9'] ['0'-'9' '_']* let hex_literal = @@ -620,6 +624,10 @@ rule token state = parse | op -> INFIXOP3 op } | '%' operator_chars* { INFIXOP3 (lexeme_operator lexbuf) } + | "let" kwdopchar dotsymbolchar * + { LETOP (lexeme_operator lexbuf) } + | "and" kwdopchar dotsymbolchar * + { ANDOP (lexeme_operator lexbuf) } | eof { EOF } | _ { raise_error diff --git a/src/reason-parser/reason_errors.ml b/src/reason-parser/reason_errors.ml index 84a5c0a0a..7df0a1b9f 100644 --- a/src/reason-parser/reason_errors.ml +++ b/src/reason-parser/reason_errors.ml @@ -127,7 +127,7 @@ let () = | _ -> None ) -open Migrate_parsetree.Ast_404 +open Migrate_parsetree.Ast_408 let str_eval_message text = { Parsetree. @@ -136,6 +136,7 @@ let str_eval_message text = { { pexp_loc = Location.none; pexp_desc = Pexp_constant (Parsetree.Pconst_string (text, None)); pexp_attributes = []; + pexp_loc_stack = []; }, [] ); diff --git a/src/reason-parser/reason_errors.mli b/src/reason-parser/reason_errors.mli index 0fecc50e6..fc265e8a4 100644 --- a/src/reason-parser/reason_errors.mli +++ b/src/reason-parser/reason_errors.mli @@ -8,7 +8,7 @@ was too fine to be captured by the grammar rules *) -open Migrate_parsetree.Ast_404 +open Migrate_parsetree.Ast_408 type lexing_error = | Illegal_character of char diff --git a/src/reason-parser/reason_heuristics.ml b/src/reason-parser/reason_heuristics.ml index d07e0c729..d0f11cc5e 100644 --- a/src/reason-parser/reason_heuristics.ml +++ b/src/reason-parser/reason_heuristics.ml @@ -1,7 +1,7 @@ open Migrate_parsetree let is_punned_labelled_expression e lbl = - let open Ast_404.Parsetree in + let open Ast_408.Parsetree in match e.pexp_desc with | Pexp_ident { txt } | Pexp_constraint ({pexp_desc = Pexp_ident { txt }}, _) @@ -17,8 +17,8 @@ let is_punned_labelled_expression e lbl = * where the sum of the string contents and identifier names are less than the print width *) let funAppCallbackExceedsWidth ~printWidth ~args ~funExpr () = - let open Ast_404.Parsetree in - let open Ast_404.Asttypes in + let open Ast_408.Parsetree in + let open Ast_408.Asttypes in let funLen = begin match funExpr.pexp_desc with | Pexp_ident ident -> let identList = Longident.flatten ident.txt in @@ -88,17 +88,17 @@ let singleTokenPatternOmmitTrail txt = String.length txt < 4 * -> setTimeout((.) => Js.log("hola"), 1000); *) let bsExprCanBeUncurried expr = - match Ast_404.Parsetree.(expr.pexp_desc) with + match Ast_408.Parsetree.(expr.pexp_desc) with | Pexp_fun _ | Pexp_apply _ -> true | _ -> false let isUnderscoreIdent expr = - match Ast_404.Parsetree.(expr.pexp_desc) with + match Ast_408.Parsetree.(expr.pexp_desc) with | Pexp_ident ({txt = Lident "_"}) -> true | _ -> false -let isPipeFirst e = match Ast_404.Parsetree.(e.pexp_desc) with +let isPipeFirst e = match Ast_408.Parsetree.(e.pexp_desc) with | Pexp_ident({txt = Longident.Lident("|.")}) -> true | Pexp_apply( {pexp_desc = Pexp_ident({txt = Longident.Lident("|.")})}, @@ -107,7 +107,7 @@ let isPipeFirst e = match Ast_404.Parsetree.(e.pexp_desc) with | _ -> false let isUnderscoreApplication expr = - let open Ast_404.Parsetree in + let open Ast_408.Parsetree in match expr with | {pexp_attributes = []; pexp_desc = Pexp_fun( Nolabel, @@ -125,7 +125,7 @@ let isUnderscoreApplication expr = * An application with pipe first inside jsx children requires special treatment. * Jsx children don't allow expression application, hence we need the braces * preserved in this case. *) -let isPipeFirstWithNonSimpleJSXChild e = match Ast_404.Parsetree.(e.pexp_desc) with +let isPipeFirstWithNonSimpleJSXChild e = match Ast_408.Parsetree.(e.pexp_desc) with | Pexp_apply( {pexp_desc = Pexp_ident({txt = Longident.Lident("|.")})}, [Nolabel, {pexp_desc = Pexp_apply(_)}; _] diff --git a/src/reason-parser/reason_oprint.cppo.ml b/src/reason-parser/reason_oprint.cppo.ml index 8b0cfd4b5..9714b2b34 100644 --- a/src/reason-parser/reason_oprint.cppo.ml +++ b/src/reason-parser/reason_oprint.cppo.ml @@ -86,7 +86,7 @@ #ifdef BS_NO_COMPILER_PATCH open Migrate_parsetree -open Ast_404 +open Ast_408 #endif open Format @@ -101,7 +101,7 @@ let cautious f ppf arg = #ifdef BS_NO_COMPILER_PATCH let rec print_ident ppf = function - Oide_ident s -> pp_print_string ppf s + Oide_ident s -> pp_print_string ppf s.printed_name | Oide_dot (id, s) -> print_ident ppf id; pp_print_char ppf '.'; pp_print_string ppf s | Oide_apply (id1, id2) -> @@ -166,7 +166,7 @@ let print_out_value ppf tree = let rec print_tree_1 ppf = function (* for the next few cases, please see context at https://github.com/facebook/reason/pull/1516#issuecomment-337069150 *) - | Oval_constr (name, [Oval_constr ((Oide_ident "()"), [])]) -> + | Oval_constr (name, [Oval_constr ((Oide_ident { printed_name = "()" }), [])]) -> (* for normal variants, but sugar Foo(()) to Foo() *) fprintf ppf "@[<1>%a()@]" print_ident name | Oval_constr (name, [param]) -> @@ -175,7 +175,7 @@ let print_out_value ppf tree = | Oval_constr (name, (_ :: _ as params)) -> fprintf ppf "@[<1>%a(%a)@]" print_ident name (print_tree_list print_tree_1 ",") params - | Oval_variant (name, Some (Oval_constr ((Oide_ident "()"), []))) -> + | Oval_variant (name, Some (Oval_constr ((Oide_ident { printed_name = "()" }), []))) -> (* for polymorphic variants, but sugar `foo(()) to `foo() *) fprintf ppf "@[<2>`%s()@]" name | Oval_variant (name, Some param) -> @@ -197,11 +197,7 @@ let print_out_value ppf tree = | Oval_nativeint i -> fprintf ppf "%nin" i | Oval_float f -> pp_print_string ppf (float_repres f) | Oval_char c -> fprintf ppf "%C" c -#if OCAML_VERSION >= (4,3,0) && not defined BS_NO_COMPILER_PATCH - | Oval_string (s,_,_) -> -#else - | Oval_string s -> -#endif + | Oval_string (s, _, _) -> begin try fprintf ppf "\"%s\"" (Reason_syntax_util.escape_string s) with Invalid_argument s when s = "String.create" -> fprintf ppf "" end @@ -347,7 +343,7 @@ and print_simple_out_type ppf = (* same for `Js.Internal.fn(...)`. Either might shown *) | Otyp_constr ( (Oide_dot ( - (Oide_dot ((Oide_ident "Js"), "Internal") | Oide_ident "Js_internal"), + (Oide_dot ((Oide_ident { printed_name = "Js" }), "Internal") | Oide_ident { printed_name = "Js_internal" }), ("fn" | "meth" as name) ) as id), ([Otyp_variant(_, Ovar_fields [variant, _, tys], _, _); result] as tyl) @@ -355,7 +351,7 @@ and print_simple_out_type ppf = (* Otyp_arrow *) let make tys result = if tys = [] then - Otyp_arrow ("", Otyp_constr (Oide_ident "unit", []),result) + Otyp_arrow ("", Otyp_constr (Oide_ident { printed_name = "unit" }, []),result) else match tys with | [ Otyp_tuple tys as single] -> @@ -386,7 +382,8 @@ and print_simple_out_type ppf = (* also BuckleScript-specific. See the comment in the previous pattern *) | Otyp_constr ( (Oide_dot ( - (Oide_dot ((Oide_ident "Js"), "Internal") | Oide_ident "Js_internal"), "meth_callback" ) as id + (Oide_dot ((Oide_ident { printed_name = "Js" }), "Internal") + | Oide_ident { printed_name = "Js_internal" }), "meth_callback" ) as id ), ([Otyp_variant(_, Ovar_fields [variant, _, tys], _,_); result] as tyl) ) -> @@ -415,7 +412,7 @@ and print_simple_out_type ppf = end (* also BuckleScript-specific. Turns Js.t({. foo: bar}) into {. "foo": bar} *) | Otyp_constr ( - (Oide_dot ((Oide_ident "Js"), "t")), + (Oide_dot ((Oide_ident { printed_name = "Js" }), "t")), [Otyp_object (fields, rest)] ) -> let dot = match rest with @@ -452,12 +449,7 @@ and print_simple_out_type ppf = Ovar_fields fields -> print_list print_row_field (fun ppf -> fprintf ppf "@;<1 -2>| ") ppf fields -#if OCAML_VERSION >= (4,3,0) && not defined BS_NO_COMPILER_PATCH | Ovar_typ typ -> print_simple_out_type ppf typ -#else - | Ovar_name (id, tyl) -> - fprintf ppf "@[%a%a@]" print_typargs tyl print_ident id -#endif in fprintf ppf "%s[%s@[@[%a@]%a ]@]" (if non_gen then "_" else "") (if closed then if tags = None then " " else "< " @@ -472,7 +464,7 @@ and print_simple_out_type ppf = | Otyp_abstract | Otyp_open | Otyp_sum _ | Otyp_record _ | Otyp_manifest (_, _) -> () | Otyp_module (p, n, tyl) -> - fprintf ppf "@[<1>(module %s" p; + fprintf ppf "@[<1>(module %a" print_ident p; let first = ref true in List.iter2 (fun s t -> @@ -481,10 +473,8 @@ and print_simple_out_type ppf = ) n tyl; fprintf ppf ")@]" -#if OCAML_VERSION >= (4,3,0) || defined BS_NO_COMPILER_PATCH | Otyp_attribute (t, attr) -> fprintf ppf "@[<1>(%a [@@%s])@]" print_out_type t attr.oattr_name -#endif and print_object_fields ~quote_fields ppf = function @@ -707,16 +697,10 @@ and print_out_sig_item ppf = | Orec_first -> "type" | Orec_next -> "and") ppf td -#if OCAML_VERSION >= (4,3,0) || defined BS_NO_COMPILER_PATCH | Osig_ellipsis -> fprintf ppf "..." | Osig_value {oval_name; oval_type; oval_prims; oval_attributes} -> let printAttributes ppf = List.iter (fun a -> fprintf ppf "[@@%s]" a.oattr_name) in -#else - | Osig_value(oval_name, oval_type, oval_prims) -> - let printAttributes ppf attrs = () in - let oval_attributes = [] in -#endif let keyword = if oval_prims = [] then "let" else "external" in let (hackyBucklescriptExternalAnnotation, rhsValues) = List.partition (fun item -> (* "BS:" is considered as a bucklescript external annotation, `[@bs.module]` and the sort. diff --git a/src/reason-parser/reason_parser.mly b/src/reason-parser/reason_parser.mly index a3171f4c4..86bb14735 100644 --- a/src/reason-parser/reason_parser.mly +++ b/src/reason-parser/reason_parser.mly @@ -49,7 +49,7 @@ %{ open Migrate_parsetree -open OCaml_404.Ast +open OCaml_408.Ast open Reason_syntax_util open Location open Asttypes @@ -140,7 +140,11 @@ module Clflags = Reason_syntax_util.Clflags *) -let uncurry_payload ?(name="bs") loc = ({loc; txt = name}, PStr []) +let uncurry_payload ?(name="bs") loc = + { attr_name = {loc; txt = name}; + attr_payload = PStr []; + attr_loc = loc + } let dummy_loc () = { loc_start = Lexing.dummy_pos; @@ -234,7 +238,7 @@ let may_tuple startp endp = function let mkct lbl = let lident = Lident lbl.txt in let ttype = Ptyp_constr({txt = lident; loc = lbl.loc}, []) in - {ptyp_desc = ttype; ptyp_loc = lbl.loc; ptyp_attributes = []} + {ptyp_desc = ttype; ptyp_loc = lbl.loc; ptyp_attributes = []; ptyp_loc_stack =[]} let mkcf ?(loc=dummy_loc()) ?(ghost=false) d = let loc = set_loc_state ghost loc in @@ -242,7 +246,10 @@ let mkcf ?(loc=dummy_loc()) ?(ghost=false) d = let simple_ghost_text_attr ?(loc=dummy_loc ()) txt = let loc = set_loc_state true loc in - [({txt; loc}, PStr [])] + [{ attr_name = {txt; loc}; + attr_payload = PStr []; + attr_loc = loc; + }] let mkExplicitArityTuplePat ?(loc=dummy_loc ()) pat = (* Tell OCaml type system that what this tuple construction represents is @@ -408,7 +415,12 @@ let mktailpat_extension loc (seq, ext_opt) = handle_seq seq let makeFrag loc body = - let attribute = ({txt = "JSX"; loc = loc}, PStr []) in + let attribute = { + attr_name = {txt = "JSX"; loc = loc}; + attr_payload = PStr []; + attr_loc = loc + } + in { body with pexp_attributes = attribute :: body.pexp_attributes } @@ -419,15 +431,15 @@ let mkstrexp e attrs = match e with | ({pexp_desc = Pexp_apply (({pexp_attributes} as e1), args) } as eRewrite) when let f = (List.filter (function - | ({txt = "bs"}, _) -> true + | { attr_name = {txt = "bs"}; _} -> true | _ -> false ) e.pexp_attributes) in List.length f > 0 -> let appExprAttrs = List.filter (function - | ({txt = "bs"}, PStr []) -> false + | { attr_name = {txt = "bs"}; attr_payload = PStr []; _ } -> false | _ -> true ) pexp_attributes in let strEvalAttrs = (uncurry_payload e1.pexp_loc)::(List.filter (function - | ({txt = "bs"}, PStr []) -> false + | { attr_name = {txt = "bs"}; attr_payload = PStr []} -> false | _ -> true ) attrs) in let e = { eRewrite with @@ -471,13 +483,32 @@ let not_expecting start_pos end_pos nonterm = let location = mklocation start_pos end_pos in raise_error (Not_expecting (location, nonterm)) location +(* Taken from the OCaml compiler. The next comment is also present there. + + This is somewhat hackish: we don't want to allow "type nonrec t := ...", + because the definition is nonrecursive by default. Simply removing + "nonrec_flag" from the rule results in a shift/reduce conflict: + "TYPE . UNDERSCORE" + can either be a shift in the type_subst_declaration rule, or a reduce of + nonrec_flag in the type_declaration rule. + To avoid it we could either %inline the nonrec_flag rule, but "meh", or we + could add nonrec_flag to the type_subst_declaration rule, and explicitely + check if it was passed. In which case we raise a proper error. *) +let check_nonrec_absent loc nonrec_flag = + match nonrec_flag with + | Recursive -> + () (* nothing to do, this happens when "nonrec" is absent from the source *) + | Nonrecursive -> + let err = {|"nonrec", type substitutions are non recursive by default|} in + raise Syntaxerr.(Error(Not_expecting(loc, err))) + let mkexp_fun {Location.txt; loc} body = let loc = mklocation loc.loc_start body.pexp_loc.loc_end in match txt with | Term (label, default_expr, pat) -> Exp.fun_ ~loc label default_expr pat body | Type str -> - Exp.newtype ~loc str body + Exp.newtype ~loc (mkloc str loc) body let mkclass_fun {Location. txt ; loc} body = let loc = mklocation loc.loc_start body.pcl_loc.loc_end in @@ -584,7 +615,7 @@ let mkexp_app_rev startp endp (body, args) = let attrs = e.pexp_attributes in let hasUncurryAttr = ref false in let newAttrs = List.filter (function - | ({txt = "uncurry"}, PStr []) -> + | { attr_name = {txt = "uncurry"}; attr_payload = PStr []; _} -> hasUncurryAttr := true; false | _ -> true) attrs @@ -712,7 +743,13 @@ let varify_constructors var_names t = Ptyp_constr(longident, List.map loop lst) | Ptyp_object (lst, o) -> Ptyp_object - (List.map (fun (s, attrs, t) -> (s, attrs, loop t)) lst, o) + (List.map + (fun ({ pof_desc; _ } as obj) -> + let pof_desc' = match pof_desc with + | Otag (s, t) -> Otag (s, loop t) + | Oinherit t -> Oinherit (loop t) + in + { obj with pof_desc = pof_desc' }) lst, o) | Ptyp_class (longident, lst) -> Ptyp_class (longident, List.map loop lst) | Ptyp_alias(core_type, string) -> @@ -722,7 +759,7 @@ let varify_constructors var_names t = Ptyp_variant(List.map loop_row_field row_field_list, flag, lbl_lst_option) | Ptyp_poly(string_lst, core_type) -> - List.iter (check_variable var_names t.ptyp_loc) string_lst; + List.iter (fun x -> check_variable var_names t.ptyp_loc x.txt) string_lst; Ptyp_poly(string_lst, loop core_type) | Ptyp_package(longident,lst) -> Ptyp_package(longident,List.map (fun (n,typ) -> (n,loop typ) ) lst) @@ -731,11 +768,14 @@ let varify_constructors var_names t = in {t with ptyp_desc = desc} and loop_row_field = - function - | Rtag(label,attrs,flag,lst) -> - Rtag(label,attrs,flag,List.map loop lst) - | Rinherit t -> + fun ({ prf_desc; _} as rf) -> + let prf_desc' = match prf_desc with + | Rtag(label, flag, lst) -> + Rtag(label, flag, List.map loop lst) + | Rinherit t -> Rinherit (loop t) + in + { rf with prf_desc = prf_desc' } in loop t @@ -751,7 +791,7 @@ let pexp_newtypes ?loc newtypes exp = let wrap_type_annotation newtypes core_type body = let exp = mkexp(Pexp_constraint(body,core_type)) in let exp = pexp_newtypes newtypes exp in - let typ = mktyp ~ghost:true (Ptyp_poly(newtypes,varify_constructors newtypes core_type)) in + let typ = mktyp ~ghost:true (Ptyp_poly(newtypes,varify_constructors (List.map (fun {txt} -> txt) newtypes) core_type)) in (exp, typ) @@ -845,8 +885,11 @@ let arity_conflict_resolving_mapper super = | Some {pexp_desc = Pexp_tuple [sp]} -> Some sp | _ -> args in super.expr mapper - {pexp_desc=Pexp_construct(lid, new_args); pexp_loc; pexp_attributes= - normalized_attributes "explicit_arity" pexp_attributes} + { pexp_desc=Pexp_construct(lid, new_args); + pexp_loc; + pexp_attributes = normalized_attributes "explicit_arity" pexp_attributes; + pexp_loc_stack = [] + } | x -> super.expr mapper x end; pat = begin fun mapper pattern -> @@ -859,8 +902,11 @@ let arity_conflict_resolving_mapper super = | Some {ppat_desc = Ppat_tuple [sp]} -> Some sp | _ -> args in super.pat mapper - {ppat_desc=Ppat_construct(lid, new_args); ppat_loc; ppat_attributes= - normalized_attributes "explicit_arity" ppat_attributes} + { ppat_desc=Ppat_construct(lid, new_args); + ppat_loc; + ppat_attributes = normalized_attributes "explicit_arity" ppat_attributes; + ppat_loc_stack = []; + } | x -> super.pat mapper x end; } @@ -904,7 +950,12 @@ let jsx_component module_name attrs children loc = mkexp ~loc:module_name.loc (Pexp_ident(mkloc (Lident firstPart) module_name.loc)) in let body = mkexp(Pexp_apply(element_fn, attrs @ children)) ~loc in - let attribute = ({txt = "JSX"; loc = loc}, PStr []) in + let attribute = { + attr_name = {txt = "JSX"; loc = loc}; + attr_payload = PStr []; + attr_loc = loc; + } + in { body with pexp_attributes = attribute :: body.pexp_attributes } let rec ignoreLapply = function @@ -940,12 +991,18 @@ let doc_attr text loc = let exp = { pexp_desc = Pexp_constant (Pconst_string(text, None)); pexp_loc = loc; - pexp_attributes = []; } + pexp_attributes = []; + pexp_loc_stack = []; + } in let item = { pstr_desc = Pstr_eval (exp, []); pstr_loc = exp.pexp_loc } in - (doc_loc loc, PStr [item]) + { + attr_name = doc_loc loc; + attr_payload = PStr [item]; + attr_loc = loc + } let prepend_attrs_to_labels attrs = function | [] -> [] (* not possible for valid inputs *) @@ -1019,15 +1076,19 @@ let package_type_of_module_type pmty = | _ -> None let add_brace_attr expr = - let label = Location.mknoloc "reason.preserve_braces" in - let payload = PStr [] in - {expr with pexp_attributes= (label, payload) :: expr.pexp_attributes } + let attr = { + attr_name = Location.mknoloc "reason.preserve_braces"; + attr_payload = PStr []; + attr_loc = Location.none + } + in + { expr with pexp_attributes= attr :: expr.pexp_attributes } %} %[@recover.prelude - open Migrate_parsetree.OCaml_404.Ast + open Migrate_parsetree.OCaml_408.Ast open Parsetree open Ast_helper @@ -1097,6 +1158,8 @@ let add_brace_attr expr = (* SLASHGREATER is an INFIXOP3 that is handled specially *) %token SLASHGREATER %token INFIXOP4 +%token LETOP +%token ANDOP %token INHERIT %token INITIALIZER %token INT @@ -1320,22 +1383,22 @@ conflicts. (* Entry points *) %start implementation (* for implementation files *) -%type implementation +%type implementation %start interface (* for interface files *) -%type interface +%type interface %start toplevel_phrase (* for interactive use *) -%type toplevel_phrase +%type toplevel_phrase %start use_file (* for the #use directive *) -%type use_file +%type use_file %start parse_core_type -%type parse_core_type +%type parse_core_type %start parse_expression -%type parse_expression +%type parse_expression %start parse_pattern -%type parse_pattern +%type parse_pattern (* Instead of reporting an error directly, productions specified - * below will be reduced first and poped up in the stack to a higher + * below will be reduced first and popped up in the stack to a higher * level production. * * This is essential to error reporting as it is much friendier to provide @@ -1345,7 +1408,10 @@ conflicts. * * See Menhir's manual for more details. *) -%on_error_reduce structure_item let_binding_body +%on_error_reduce structure_item + let_binding_body + letop_bindings + letop_binding_body as_loc(attribute)+ type_longident constr_longident @@ -1625,7 +1691,7 @@ structure_item: | str_type_extension { mkstr(Pstr_typext $1) } | str_exception_declaration - { mkstr(Pstr_exception $1) } + { mkstr(Pstr_exception (Te.mk_exception ~loc:$1.pext_loc $1)) } | item_attributes opt_LET_MODULE_ident module_binding_body { let loc = mklocation $symbolstartpos $endpos in mkstr(Pstr_module (Mb.mk $2 $3 ~attrs:$1 ~loc)) } @@ -1640,7 +1706,7 @@ structure_item: | item_attributes MODULE TYPE OF? as_loc(ident) module_type_body(EQUAL) { let loc = mklocation $symbolstartpos $endpos in mkstr(Pstr_modtype (Mtd.mk $5 ~typ:$6 ~attrs:$1 ~loc)) } - | open_statement + | open_declaration { mkstr(Pstr_open $1) } | item_attributes CLASS class_declaration_details and_class_declaration* { let (ident, binding, virt, params) = $3 in @@ -1812,6 +1878,7 @@ signature: | signature_items SEMI signature { $1 @ $3 } ; + signature_item: | item_attributes LET as_loc(val_ident) COLON core_type @@ -1830,6 +1897,8 @@ signature_item: } | type_declarations { let (nonrec_flag, tyl) = $1 in Psig_type (nonrec_flag, tyl) } + | type_subst_declarations + { Psig_typesubst $1 } | sig_type_extension { Psig_typext $1 } | sig_exception_declaration @@ -1849,6 +1918,8 @@ signature_item: ~loc ) } + | item_attributes opt_LET_MODULE as_loc(UIDENT) COLONEQUAL as_loc(mod_ext_longident) + { Psig_modsubst (Ms.mk $3 $5 ~attrs:$1 ~loc:(mklocation $symbolstartpos $endpos))} | item_attributes opt_LET_MODULE_REC_ident module_type_body(COLON) and_module_rec_declaration* { let loc = mklocation $symbolstartpos $endpos($3) in @@ -1861,7 +1932,7 @@ signature_item: { let loc = mklocation $symbolstartpos $endpos in Psig_modtype (Mtd.mk $4 ~typ:$5 ~loc ~attrs:$1) } - | open_statement + | open_description { Psig_open $1 } | item_attributes INCLUDE module_type { let loc = mklocation $symbolstartpos $endpos in @@ -1881,7 +1952,12 @@ signature_items: { List.map (fun x -> mksig ~loc:x.loc (Psig_attribute x.txt)) $1 } ; -open_statement: +open_declaration: + item_attributes OPEN override_flag module_expr + { Opn.mk $4 ~override:$3 ~attrs:$1 ~loc:(mklocation $symbolstartpos $endpos) } +; + +open_description: item_attributes OPEN override_flag as_loc(mod_longident) { Opn.mk $4 ~override:$3 ~attrs:$1 ~loc:(mklocation $symbolstartpos $endpos) } ; @@ -1940,6 +2016,10 @@ mark_position_cl | let_bindings SEMI class_expr_lets_and_rest { class_of_let_bindings $1 $3 } | object_body { mkclass (Pcl_structure $1) } + | LET? OPEN override_flag as_loc(mod_longident) SEMI class_expr_lets_and_rest + { let loc = mklocation $startpos($2) $endpos($3) in + let od = Opn.mk ~override:$3 ~loc $4 in + mkclass (Pcl_open (od, $6)) } ) {$1}; object_body_class_fields: @@ -2015,7 +2095,7 @@ mark_position_cl class_field: | mark_position_cf - ( item_attributes INHERIT override_flag class_expr preceded(AS,LIDENT)? + ( item_attributes INHERIT override_flag class_expr as_loc(preceded(AS,LIDENT))? { mkcf_attrs (Pcf_inherit ($3, $4, $5)) $1 } | item_attributes VAL value { mkcf_attrs (Pcf_val $3) $1 } @@ -2080,7 +2160,7 @@ method_: { let loc = mklocation $symbolstartpos $endpos in ($2, Cfk_concrete ($1, mkexp ~ghost:true ~loc (Pexp_poly($4, $3)))) } - | override_flag as_loc(label) COLON TYPE LIDENT+ DOT core_type + | override_flag as_loc(label) COLON TYPE as_loc(LIDENT)+ DOT core_type either(preceded(EQUAL,expr), braced_expr) (* WITH locally abstract types, you'll see a Ptyp_poly in the Pexp_poly, but the expression will be a Pexp_newtype and type vars will be @@ -2243,17 +2323,26 @@ mark_position_cty ) {$1}; class_type_body: - | LBRACE class_sig_body RBRACE - { mkcty ~loc:(mklocation $startpos $endpos) (Pcty_signature $2) } - | LBRACE DOT class_sig_body RBRACE + | LBRACE class_sig_body_cty RBRACE + { mkcty ~loc:(mklocation $startpos $endpos) $2 } + | LBRACE DOT class_sig_body_cty RBRACE { let loc = mklocation $startpos $endpos in - let ct = mkcty ~loc (Pcty_signature $3) in + let ct = mkcty ~loc $3 in {ct with pcty_attributes = [uncurry_payload loc]} } ; class_sig_body_fields: lseparated_list(SEMI, class_sig_field) SEMI? { List.concat $1 } +; + +class_sig_body_cty: + | class_sig_body { Pcty_signature $1 } + | LET? OPEN override_flag as_loc(mod_longident) SEMI as_loc(class_sig_body_cty) + { let {txt; loc} = $6 in + let od = Opn.mk ~override:$3 ~loc:(mklocation $startpos($2) $endpos($3)) $4 in + Pcty_open (od, mkcty ~loc txt) } +; class_sig_body: | class_self_type @@ -2274,9 +2363,9 @@ class_sig_field: { mkctf_attrs (Pctf_inherit $3) $1 } | item_attributes VAL value_type { mkctf_attrs (Pctf_val $3) $1 } - | item_attributes PRI virtual_flag label COLON poly_type + | item_attributes PRI virtual_flag as_loc(label) COLON poly_type { mkctf_attrs (Pctf_method ($4, Private, $3, $6)) $1 } - | item_attributes PUB virtual_flag label COLON poly_type + | item_attributes PUB virtual_flag as_loc(label) COLON poly_type { mkctf_attrs (Pctf_method ($4, Public, $3, $6)) $1 } | item_attributes CONSTRAINT constrain_field { mkctf_attrs (Pctf_constraint $3) $1 } @@ -2288,7 +2377,7 @@ class_sig_field: ; value_type: - mutable_or_virtual_flags label COLON core_type + mutable_or_virtual_flags as_loc(label) COLON core_type { let (mut, virt) = $1 in ($2, mut, virt, $4) } ; @@ -2354,6 +2443,12 @@ class_type_declaration_details: { ($2, $4, $1, $3) } ; +%inline open_dot_declaration: as_loc(mod_longident) + { let loc = mklocation $startpos($1) $endpos($1) in + let me = Mod.ident ~loc $1 in + Opn.mk ~loc me } +; + (* Core expressions *) (* Note: If we will parse this as Pexp_apply, and it will @@ -2411,7 +2506,10 @@ seq_expr_no_seq [@recover.expr default_expr ()]: | opt_LET_MODULE_ident module_binding_body SEMI seq_expr { mkexp (Pexp_letmodule($1, $2, $4)) } | item_attributes LET? OPEN override_flag as_loc(mod_longident) SEMI seq_expr - { let exp = mkexp (Pexp_open($4, $5, $7)) in + { let loc = (mklocation $startpos($1) $endpos($4)) in + let me = Mod.ident ~loc $5 in + let od = Opn.mk ~override:$4 ~loc me in + let exp = mkexp (Pexp_open(od, $7)) in { exp with pexp_attributes = $1 } } | str_exception_declaration SEMI seq_expr { @@ -2424,6 +2522,12 @@ seq_expr_no_seq [@recover.expr default_expr ()]: { let loc = mklocation $symbolstartpos $endpos in expr_of_let_bindings ~loc $1 (ghunit ~loc ()) } +| as_loc(LETOP) letop_bindings SEMI seq_expr + { let (pbop_pat, pbop_exp, rev_ands) = $2 in + let ands = List.rev rev_ands in + let pbop_loc = mklocation $symbolstartpos $endpos($2) in + let let_ = {pbop_op = $1; pbop_pat; pbop_exp; pbop_loc} in + mkexp ~loc:pbop_loc (Pexp_letop { let_; ands; body = $4}) } ; seq_expr: @@ -2924,15 +3028,14 @@ parenthesized_expr: { may_tuple $startpos $endpos $2 } | E as_loc(POSTFIXOP) { mkexp(Pexp_apply(mkoperator $2, [Nolabel, $1])) } - | as_loc(mod_longident) DOT LPAREN expr_list RPAREN - { mkexp(Pexp_open(Fresh, $1, may_tuple $startpos($3) $endpos($5) $4)) } + | od=open_dot_declaration DOT LPAREN expr_list RPAREN + { mkexp(Pexp_open(od, may_tuple $startpos($3) $endpos($5) $4)) } | E DOT as_loc(label_longident) { mkexp(Pexp_field($1, $3)) } - | as_loc(mod_longident) DOT LBRACE RBRACE + | od=open_dot_declaration DOT LBRACE RBRACE { let loc = mklocation $symbolstartpos $endpos in let pat = mkpat (Ppat_var (mkloc "this" loc)) in - mkexp(Pexp_open (Fresh, $1, - mkexp(Pexp_object(Cstr.mk pat [])))) + mkexp(Pexp_open (od, mkexp(Pexp_object(Cstr.mk pat [])))) } | E LBRACKET expr RBRACKET { let loc = mklocation $symbolstartpos $endpos in @@ -2947,43 +3050,43 @@ parenthesized_expr: | E bigarray_access { let loc = mklocation $symbolstartpos $endpos in bigarray_get ~loc $1 $2 } - | as_loc(mod_longident) DOT LBRACE record_expr RBRACE + | od=open_dot_declaration DOT LBRACE record_expr RBRACE { let loc = mklocation $symbolstartpos $endpos in - mkexp(Pexp_open(Fresh, $1, mk_record_expr ~loc $4)) + mkexp(Pexp_open(od, mk_record_expr ~loc $4)) } - | as_loc(mod_longident) DOT LBRACE record_expr_with_string_keys RBRACE + | od=open_dot_declaration DOT LBRACE record_expr_with_string_keys RBRACE { let (exten, fields) = $4 in let loc = mklocation $symbolstartpos $endpos in let rec_exp = mkexp ~loc (Pexp_extension (mkloc ("bs.obj") loc, PStr [mkstrexp (mkexp ~loc (Pexp_record(fields, exten))) []])) in - mkexp(Pexp_open(Fresh, $1, rec_exp)) + mkexp(Pexp_open(od, rec_exp)) } - | as_loc(mod_longident) DOT LBRACKETBAR expr_list BARRBRACKET + | od=open_dot_declaration DOT LBRACKETBAR expr_list BARRBRACKET { let loc = mklocation $symbolstartpos $endpos in let rec_exp = Exp.mk ~loc ~attrs:[] (Pexp_array $4) in - mkexp(Pexp_open(Fresh, $1, rec_exp)) + mkexp(Pexp_open(od, rec_exp)) } (* Parse Module.[
] *) - | as_loc(mod_longident) DOT LBRACKETLESS jsx_without_leading_less RBRACKET + | od=open_dot_declaration DOT LBRACKETLESS jsx_without_leading_less RBRACKET { let seq, ext_opt = [$4], None in let loc = mklocation $startpos($4) $endpos($4) in let list_exp = make_real_exp (mktailexp_extension loc seq ext_opt) in let list_exp = { list_exp with pexp_loc = loc } in - mkexp (Pexp_open (Fresh, $1, list_exp)) + mkexp (Pexp_open (od, list_exp)) } - | as_loc(mod_longident) DOT LBRACKET RBRACKET + | od=open_dot_declaration DOT LBRACKET RBRACKET { let loc = mklocation $startpos($3) $endpos($4) in let list_exp = make_real_exp (mktailexp_extension loc [] None) in let list_exp = { list_exp with pexp_loc = loc } in - mkexp (Pexp_open (Fresh, $1, list_exp)) + mkexp (Pexp_open (od, list_exp)) } - | as_loc(mod_longident) DOT LBRACKET expr_comma_seq_extension RBRACKET + | od=open_dot_declaration DOT LBRACKET expr_comma_seq_extension RBRACKET { let seq, ext_opt = $4 in let loc = mklocation $startpos($4) $endpos($4) in let list_exp = make_real_exp (mktailexp_extension loc seq ext_opt) in let list_exp = { list_exp with pexp_loc = loc } in - mkexp (Pexp_open (Fresh, $1, list_exp)) + mkexp (Pexp_open (od, list_exp)) } | as_loc(PREFIXOP) E %prec below_DOT_AND_SHARP { mkexp(Pexp_apply(mkoperator $1, [Nolabel, $2])) } @@ -2997,12 +3100,12 @@ parenthesized_expr: { mkexp (Pexp_apply(mkoperator $1, [Nolabel,$2])) }*) | NEW as_loc(class_longident) { mkexp (Pexp_new $2) } - | as_loc(mod_longident) DOT LBRACELESS field_expr_list COMMA? GREATERRBRACE + | od=open_dot_declaration DOT LBRACELESS field_expr_list COMMA? GREATERRBRACE { let loc = mklocation $symbolstartpos $endpos in let exp = Exp.mk ~loc ~attrs:[] (Pexp_override $4) in - mkexp (Pexp_open(Fresh, $1, exp)) + mkexp (Pexp_open(od, exp)) } - | E SHARP label + | E SHARP as_loc(label) { mkexp (Pexp_send($1, $3)) } | E as_loc(SHARPOP) simple_expr_no_call { mkinfixop $1 (mkoperator $2) $3 } @@ -3011,9 +3114,9 @@ parenthesized_expr: mkinfixop $1 (mkoperator op) $3 } | E as_loc(MINUSGREATER) simple_expr_no_call { mkinfixop $1 (mkoperator {$2 with txt = "|."}) $3 } - | as_loc(mod_longident) DOT LPAREN MODULE module_expr COLON package_type RPAREN + | od=open_dot_declaration DOT LPAREN MODULE module_expr COLON package_type RPAREN { let loc = mklocation $symbolstartpos $endpos in - mkexp (Pexp_open(Fresh, $1, + mkexp (Pexp_open(od, mkexp ~loc (Pexp_constraint (mkexp ~ghost:true ~loc (Pexp_pack $5), $7)))) } | extension @@ -3221,13 +3324,13 @@ let_binding_body: ($1, ghexp_constraint loc $4 $2) } | simple_pattern_ident fun_def(EQUAL,core_type) { ($1, $2) } - | simple_pattern_ident COLON preceded(QUOTE,ident)+ DOT core_type + | simple_pattern_ident COLON as_loc(preceded(QUOTE,ident))+ DOT core_type EQUAL mark_position_exp(expr) { let typ = mktyp ~ghost:true (Ptyp_poly($3, $5)) in let loc = mklocation $symbolstartpos $endpos in (mkpat ~ghost:true ~loc (Ppat_constraint($1, typ)), $7) } - | simple_pattern_ident COLON TYPE LIDENT+ DOT core_type + | simple_pattern_ident COLON TYPE as_loc(LIDENT)+ DOT core_type EQUAL mark_position_exp(expr) (* Because core_type will appear to contain "type constructors" since the * type variables listed in LIDENT+ don't have leading single quotes, we @@ -3299,6 +3402,28 @@ let_binding_body: } ; +letop_binding_body: + | pat = simple_pattern_ident exp = expr + { (pat, exp) } + | pat = simple_pattern COLON typ = core_type EQUAL exp = expr + { let loc = mklocation $startpos(pat) $endpos(typ) in + (mkpat ~ghost:true ~loc (Ppat_constraint(pat, typ)), exp) } + | pat = pattern EQUAL exp = expr + { (pat, exp) } +; + +letop_bindings: + body = letop_binding_body + { let let_pat, let_exp = body in + let_pat, let_exp, [] } + | bindings = letop_bindings pbop_op = as_loc(ANDOP) body = let_binding_body + { let let_pat, let_exp, rev_ands = bindings in + let pbop_pat, pbop_exp = body in + let pbop_loc = mklocation $symbolstartpos $endpos in + let and_ = {pbop_op; pbop_pat; pbop_exp; pbop_loc} in + let_pat, let_exp, and_ :: rev_ands } +; + (* * TODO: * In OCaml, the following function binding would be parsed by the function @@ -3828,23 +3953,69 @@ type_declaration_kind: { ($1, $2, $endpos($2), $3) } ; +type_subst_kind: + | COLONEQUAL private_flag type_subst_constructor_declarations + { let (cstrs, constraints, endpos, and_types) = $3 in + ((Ptype_variant (cstrs), $2, None), constraints, endpos, and_types) } + | COLONEQUAL core_type EQUAL private_flag type_subst_constructor_declarations + { let (cstrs, constraints, endpos, and_types) = $5 in + ((Ptype_variant cstrs, $4, Some $2), constraints, endpos, and_types) } + | type_subst_other_kind constraints and_type_subst_declaration + { ($1, $2, $endpos($2), $3) } +; + +type_subst_declarations: + item_attributes TYPE nrf=nonrec_flag name=as_loc(LIDENT) + params=type_variables_with_variance kind_priv_man=type_subst_kind + { check_nonrec_absent (mklocation $startpos(nrf) $endpos(nrf)) nrf; + let (kind, priv, manifest), cstrs, endpos, and_types = kind_priv_man in + let ty = + Type.mk name ~params ~cstrs ~kind ~priv + ?manifest ~attrs:$1 + ~loc:(mklocation $symbolstartpos endpos) + in + ty :: and_types } +; + +and_type_subst_declaration: + | { [] } + | item_attributes AND name=as_loc(LIDENT) + params=type_variables_with_variance kind_priv_man=type_subst_kind + { let (kind, priv, manifest), cstrs, endpos, and_types = kind_priv_man in + Type.mk name ~params ~cstrs + ~kind ~priv ?manifest + ~attrs:$1 + ~loc:(mklocation $symbolstartpos endpos) + :: and_types + } +; + %inline constraints: | { [] } | preceded(CONSTRAINT, constrain)+ { $1 } ; +type_subst_other_kind: + nonempty_type_other_kind(COLONEQUAL) + { $1 } + type_other_kind: | (*empty*) { (Ptype_abstract, Public, None) } - | EQUAL private_flag core_type + | nonempty_type_other_kind(EQUAL) + { $1 } +; + +%inline nonempty_type_other_kind(eq_symbol): + | eq_symbol private_flag core_type { (Ptype_abstract, $2, Some $3) } - | EQUAL private_flag item_attributes record_declaration + | eq_symbol private_flag item_attributes record_declaration { (Ptype_record (prepend_attrs_to_labels $3 $4), $2, None) } - | EQUAL DOTDOT - { (Ptype_open, Public, None) } - | EQUAL core_type EQUAL DOTDOT + | eq_symbol private_flag DOTDOT + { (Ptype_open, $2, None) } + | eq_symbol core_type EQUAL DOTDOT { (Ptype_open, Public, Some $2) } - | EQUAL core_type EQUAL private_flag item_attributes record_declaration + | eq_symbol core_type EQUAL private_flag item_attributes record_declaration { (Ptype_record (prepend_attrs_to_labels $5 $6), $4, Some $2) } ; @@ -3888,8 +4059,9 @@ mark_position_typ { $1 }; constructor_declarations: - either(constructor_declaration,bar_constructor_declaration) - constructor_declarations_aux + | BAR and_type_declaration { ([], [], $endpos, $2) } + | either(constructor_declaration,bar_constructor_declaration) + constructor_declarations_aux { let (cstrs, constraints, endpos, and_types) = $2 in ($1 :: cstrs, constraints, endpos, and_types) } @@ -3904,6 +4076,23 @@ constructor_declarations_aux: { ([], $1, $endpos($1), $2) } ; +type_subst_constructor_declarations: + either(constructor_declaration,bar_constructor_declaration) + type_subst_constructor_declarations_aux + { let (cstrs, constraints, endpos, and_types) = $2 in + ($1 :: cstrs, constraints, endpos, and_types) + } +; + +type_subst_constructor_declarations_aux: + | bar_constructor_declaration type_subst_constructor_declarations_aux + { let (cstrs, constraints, endpos, and_types) = $2 in + ($1 :: cstrs, constraints, endpos, and_types) + } + | constraints and_type_subst_declaration + { ([], $1, $endpos($1), $2) } +; + bar_constructor_declaration: item_attributes BAR constructor_declaration { {$3 with pcd_attributes = $1 @ $3.pcd_attributes} } @@ -3920,13 +4109,15 @@ constructor_declaration: str_exception_declaration: item_attributes EXCEPTION either(extension_constructor_declaration, extension_constructor_rebind) - { {$3 with pext_attributes = $3.pext_attributes @ $1} } + { { $3 with pext_attributes = $3.pext_attributes @ $1} } ; sig_exception_declaration: item_attributes EXCEPTION extension_constructor_declaration - { {$3 with pext_attributes = $3.pext_attributes @ $1} } + { let decl = { $3 with pext_attributes = $3.pext_attributes @ $1} in + Te.mk_exception ~loc:decl.pext_loc decl + } ; generalized_constructor_arguments: @@ -4054,12 +4245,13 @@ with_constraint: fallback other in let loc = mklocation $symbolstartpos $endpos in - Pwith_typesubst (Type.mk {$2 with txt=last} ~params:$3 ~manifest:$5 ~loc) + Pwith_typesubst ($2, Type.mk {$2 with txt=last} ~params:$3 ~manifest:$5 ~loc) } | MODULE as_loc(mod_longident) EQUAL as_loc(mod_ext_longident) { Pwith_module ($2, $4) } | MODULE as_loc(UIDENT) COLONEQUAL as_loc(mod_ext_longident) - { Pwith_modsubst ($2, $4) } + { let lident = {$2 with txt=Lident $2.txt} in + Pwith_modsubst (lident, $4) } ; (* Polymorphic types *) @@ -4067,7 +4259,7 @@ poly_type: mark_position_typ ( core_type { $1 } - | preceded(QUOTE,ident)+ DOT core_type + | as_loc(preceded(QUOTE,ident))+ DOT core_type { mktyp(Ptyp_poly($1, $3)) } ) {$1}; @@ -4366,9 +4558,11 @@ object_record_type: object_label_declaration: | item_attributes as_loc(LIDENT) - { ($2.txt, $1, mkct $2) } - | item_attributes LIDENT COLON poly_type - { ($2, $1, $4) } + { Of.tag ~attrs:$1 $2 (mkct $2) } + | item_attributes as_loc(LIDENT) COLON poly_type + { Of.tag ~attrs:$1 $2 $4 } + | DOTDOTDOT as_loc(LIDENT) + { Of.inherit_ ~loc:(mklocation $symbolstartpos $endpos) (mkct $2) } ; object_label_declarations: @@ -4376,7 +4570,9 @@ object_label_declarations: string_literal_label: item_attributes STRING COLON poly_type - { let (label, _raw, _delim) = $2 in (label, $1, $4) } + { let (label, _raw, _delim) = $2 in + let lblloc = mkloc label (mklocation $startpos($2) $endpos($2)) in + Of.tag ~loc:(mklocation $symbolstartpos $endpos) ~attrs:$1 lblloc $4 } ; string_literal_labels: @@ -4400,26 +4596,29 @@ row_field_list: row_field: | tag_field { $1 } - | non_arrowed_core_type { Rinherit $1 } + | non_arrowed_core_type + { Rf.inherit_ ~loc:(mklocation $symbolstartpos $endpos) $1 } ; +(* TODO::: *) bar_row_field: item_attributes BAR row_field - { match $3 with - | Rtag (name, attrs, amp, typs) -> - Rtag (name, $1 @ attrs, amp, typs) + { let loc = (mklocation $symbolstartpos $endpos) in + match $3.prf_desc with + | Rtag (name, amp, typs) -> + Rf.tag ~loc ~attrs:($1 @ $3.prf_attributes) name amp typs | Rinherit typ -> - Rinherit {typ with ptyp_attributes = $1 @ typ.ptyp_attributes} + Rf.inherit_ ~loc { typ with ptyp_attributes = ($1 @ typ.ptyp_attributes) } } ; tag_field: - | item_attributes name_tag + | item_attributes as_loc(name_tag) boption(AMPERSAND) separated_nonempty_list(AMPERSAND, non_arrowed_simple_core_types) - { Rtag ($2, $1, $3, $4) } - | item_attributes name_tag - { Rtag ($2, $1, true, []) } + { Rf.tag ~loc:(mklocation $symbolstartpos $endpos) ~attrs:$1 $2 $3 $4 } + | item_attributes as_loc(name_tag) + { Rf.tag ~loc:(mklocation $symbolstartpos $endpos) ~attrs:$1 $2 true [] } ; (* Constants *) @@ -4434,7 +4633,10 @@ constant: | None -> [] | Some raw -> let constant = Ast_helper.Exp.constant (Pconst_string (raw, None)) in - [Location.mknoloc "reason.raw_literal", PStr [mkstrexp constant []]] + [ { attr_name = Location.mknoloc "reason.raw_literal"; + attr_payload = PStr [mkstrexp constant []]; + attr_loc = Location.none + } ] in (attr, Pconst_string (s, d)) } @@ -4495,6 +4697,8 @@ operator: | POSTFIXOP { $1 } | BANG { "!" } | infix_operator { $1 } + | LETOP { $1 } + | ANDOP { $1 } ; %inline constr_ident: | UIDENT { $1 } @@ -4573,16 +4777,29 @@ class_longident: (* Toplevel directives *) toplevel_directive: - SHARP ident embedded - ( (* empty *) { Pdir_none } - | STRING { let (s, _, _) = $1 in Pdir_string s } - | INT { let (n, m) = $1 in Pdir_int (n, m) } - | val_longident { Pdir_ident $1 } - | mod_longident { Pdir_ident $1 } - | FALSE { Pdir_bool false } - | TRUE { Pdir_bool true } + SHARP as_loc(ident) embedded + ( (* empty *) { None } + | STRING { let (s, _, _) = $1 in Some(Pdir_string s) } + | INT { let (n, m) = $1 in Some(Pdir_int (n, m)) } + | val_longident { Some(Pdir_ident $1) } + | mod_longident { Some(Pdir_ident $1) } + | FALSE { Some(Pdir_bool false) } + | TRUE { Some(Pdir_bool true) } ) - { Ptop_dir($2, $3) } + { + let pdir_arg = match $3 with + | None -> None + | Some pdira_desc -> Some { + pdira_desc; + pdira_loc = mklocation $startpos($3) $endpos($3); + } + in + Ptop_dir + { pdir_name = $2 + ; pdir_arg + ; pdir_loc = $2.loc + } + } ; (* Miscellaneous *) @@ -4704,7 +4921,13 @@ attr_id: ; attribute: - | LBRACKETAT attr_id payload RBRACKET { ($2, $3) } + | LBRACKETAT attr_id payload RBRACKET + { + { attr_name = $2; + attr_payload = $3; + attr_loc = mklocation $symbolstartpos $endpos + } + } | DOCSTRING { doc_attr $1 (mklocation $symbolstartpos $endpos) } ; diff --git a/src/reason-parser/reason_parser_def.ml b/src/reason-parser/reason_parser_def.ml index cedd181d2..ad6d4dfed 100644 --- a/src/reason-parser/reason_parser_def.ml +++ b/src/reason-parser/reason_parser_def.ml @@ -1,4 +1,4 @@ -open Migrate_parsetree.OCaml_404.Ast +open Migrate_parsetree.OCaml_408.Ast type labelled_parameter = | Term of Asttypes.arg_label * Parsetree.expression option * Parsetree.pattern diff --git a/src/reason-parser/reason_pprint_ast.ml b/src/reason-parser/reason_pprint_ast.ml index 68d244e9c..d62e39bc1 100644 --- a/src/reason-parser/reason_pprint_ast.ml +++ b/src/reason-parser/reason_pprint_ast.ml @@ -49,7 +49,7 @@ module Easy_format = Vendored_easy_format open Migrate_parsetree -open Ast_404 +open Ast_408 open Asttypes open Location open Longident @@ -138,6 +138,8 @@ and tokenFixity = | UnaryNotPrefix of string | UnaryPostfix of string | Infix of string + | Letop of string + | Andop of string | Normal (* Type which represents a resolvedRule's InfixTree flattened *) @@ -177,6 +179,9 @@ let add_extension_sugar keyword = function let string_equal : string -> string -> bool = (=) +let string_loc_equal: string Ast_408.Asttypes.loc -> string Ast_408.Asttypes.loc -> bool = + fun l1 l2 -> l1.txt = l2.txt + let longident_same l1 l2 = let rec equal l1 l2 = match l1, l2 with @@ -236,9 +241,13 @@ let same_ast_modulo_varification_and_extensions t1 t2 = loop core_type1' core_type2' | (Ptyp_tuple lst1, Ptyp_tuple lst2) -> for_all2' loop lst1 lst2 | (Ptyp_object (lst1, o1), Ptyp_object (lst2, o2)) -> - let tester = fun (s1, _, t1) (s2, _, t2) -> - string_equal s1 s2 && - loop t1 t2 + let tester = fun t1 t2 -> + match t1.pof_desc, t2.pof_desc with + | Otag (s1, t1), Otag (s2, t2) -> + string_equal s1.txt s2.txt && + loop t1 t2 + | Oinherit t1, Oinherit t2 -> loop t1 t2 + | _ -> false in for_all2' tester lst1 lst2 && o1 = o2 | (Ptyp_class (longident1, lst1), Ptyp_class (longident2, lst2)) -> @@ -252,7 +261,7 @@ let same_ast_modulo_varification_and_extensions t1 t2 = flag1 = flag2 && lbl_lst_option1 = lbl_lst_option2 | (Ptyp_poly (string_lst1, core_type1), Ptyp_poly (string_lst2, core_type2))-> - for_all2' string_equal string_lst1 string_lst2 && + for_all2' string_loc_equal string_lst1 string_lst2 && loop core_type1 core_type2 | (Ptyp_package(longident1, lst1), Ptyp_package (longident2, lst2)) -> longident_same longident1 longident2 && @@ -263,9 +272,9 @@ let same_ast_modulo_varification_and_extensions t1 t2 = and testPackageType (lblLongIdent1, ct1) (lblLongIdent2, ct2) = longident_same lblLongIdent1 lblLongIdent2 && loop ct1 ct2 - and rowFieldEqual f1 f2 = match (f1, f2) with - | ((Rtag(label1, _, flag1, lst1)), (Rtag (label2, _, flag2, lst2))) -> - string_equal label1 label2 && + and rowFieldEqual f1 f2 = match (f1.prf_desc, f2.prf_desc) with + | ((Rtag(label1, flag1, lst1)), (Rtag (label2, flag2, lst2))) -> + string_equal label1.txt label2.txt && flag1 = flag2 && for_all2' loop lst1 lst2 | (Rinherit t1, Rinherit t2) -> loop t1 t2 @@ -293,7 +302,7 @@ let expandLocation pos ~expand:(startPos, endPos) = * 2| let f = ... by the attr on line 1, not the lnum of the `let` *) let rec firstAttrLoc loc = function - | ((attrLoc, _) : Ast_404.Parsetree.attribute) ::attrs -> + | ({ attr_name = attrLoc; _} : Ast_408.Parsetree.attribute) ::attrs -> if attrLoc.loc.loc_start.pos_lnum < loc.loc_start.pos_lnum && not attrLoc.loc.loc_ghost then @@ -323,6 +332,10 @@ let extractLocValBinding {pvb_pat; pvb_expr; pvb_attributes;} = let estimatedLoc = firstAttrLoc pvb_pat.ppat_loc pvb_attributes in {estimatedLoc with loc_end = pvb_expr.pexp_loc.loc_end} +let extractLocBindingOp {pbop_pat; pbop_exp} = + let estimatedLoc = firstAttrLoc pbop_pat.ppat_loc [] in + {estimatedLoc with loc_end = pbop_exp.pexp_loc.loc_end} + let extractLocModuleBinding {pmb_expr; pmb_attributes} = let estimatedLoc = firstAttrLoc pmb_expr.pmod_loc pmb_attributes in {estimatedLoc with loc_end = pmb_expr.pmod_loc.loc_end} @@ -455,6 +468,9 @@ let unary_minus_prefix_symbols = [ "~-"; "~-."] ;; let unary_plus_prefix_symbols = ["~+"; "~+." ] ;; let infix_symbols = [ '='; '<'; '>'; '@'; '^'; '|'; '&'; '+'; '-'; '*'; '/'; '$'; '%'; '\\'; '#' ] +(* this should match "kwdopchar" from reason_declarative_lexer.mll *) +let let_monad_symbols = [ '$'; '&'; '*'; '+'; '-'; '/'; '<'; '='; '>'; '@'; + '^'; '|'; '.'; '!'] let special_infix_strings = ["asr"; "land"; "lor"; "lsl"; "lsr"; "lxor"; "mod"; "or"; ":="; "!="; "!=="] @@ -466,6 +482,20 @@ let requireIndentFor = [updateToken; ":="] let namedArgSym = "~" +let letop s = + String.length s > 3 + && s.[0] = 'l' + && s.[1] = 'e' + && s.[2] = 't' + && List.mem s.[3] let_monad_symbols + +let andop s = + String.length s > 3 + && s.[0] = 'a' + && s.[1] = 'n' + && s.[2] = 'd' + && List.mem s.[3] let_monad_symbols + let requireNoSpaceFor tok = tok = pipeFirstToken || (tok.[0] = '#' && tok <> "#=") @@ -501,6 +531,8 @@ let printedStringAndFixity = function else AlmostSimplePrefix s ) + | s when letop s -> Letop s + | s when andop s -> Andop s | _ -> Normal @@ -696,6 +728,8 @@ let needs_parens txt = | UnaryMinusPrefix _ -> true | UnaryNotPrefix _ -> true | AlmostSimplePrefix _ -> true + | Letop _ -> true + | Andop _ -> true | Normal -> false (* some infixes need spaces around parens to avoid clashes with comment @@ -988,7 +1022,7 @@ let isArityClear attrs = (!configuredSettings).assumeExplicitArity || List.exists (function - | ({txt="explicit_arity"}, _) -> true + | { attr_name = {txt="explicit_arity"}; _} -> true | _ -> false ) attrs @@ -2453,7 +2487,7 @@ let printer = object(self:'self) | sl -> makeList ~break:IfNeed ~postSpace:true [ makeList [ - makeList ~postSpace:true (List.map (fun x -> self#tyvar x) sl); + makeList ~postSpace:true (List.map (fun {txt} -> self#tyvar txt) sl); atom "."; ]; ct @@ -2656,14 +2690,14 @@ let printer = object(self:'self) source_map ~loc:pext_loc everything (* shared by [Pstr_type,Psig_type]*) - method type_def_list (rf, l) = + method type_def_list ?(eq_symbol="=") (rf, l) = (* As oposed to used in type substitution. *) let formatOneTypeDefStandard prepend td = let itm = self#formatOneTypeDef prepend (atom ~loc:td.ptype_name.loc td.ptype_name.txt) - (atom "=") + (atom eq_symbol) td in let {stdAttrs; docAttrs} = partitionAttributes ~partDoc:true td.ptype_attributes in @@ -2701,6 +2735,11 @@ let printer = object(self:'self) items ) + method type_variant_list lst = + match lst with + | [] -> [atom "|"] + | _ -> List.map (fun x -> self#type_variant_leaf x) lst + method type_variant_leaf ?opt_ampersand:(a=false) ?polymorphic:(p=false) = self#type_variant_leaf1 a p true method type_variant_leaf_nobar ?opt_ampersand:(a=false) ?polymorphic:(p=false) = self#type_variant_leaf1 a p false @@ -2908,16 +2947,24 @@ let printer = object(self:'self) (* ] *) (* EQUAL PRIVATE constructor_declarations {(Ptype_variant _, Private, None)} *) | (Ptype_variant lst, Private, None) -> [ - [privateAtom; makeList ~break:IfNeed ~postSpace:true ~inline:(true, true) (List.map self#type_variant_leaf lst)] + [privateAtom; makeList ~break:IfNeed ~postSpace:true ~inline:(true, true) (self#type_variant_list lst)] ] (* EQUAL private_flag BAR constructor_declarations {(Ptype_variant _, $2, None)} *) - | (Ptype_variant lst, scope, None) -> [ - privatize scope [makeList ~break:Always_rec ~postSpace:true ~inline:(true, true) (List.map self#type_variant_leaf lst)] + | (Ptype_variant lst, scope, None) -> [ + privatize scope + [makeList + ~break:(if lst == [] then IfNeed else Always_rec) + ~postSpace:true + ~inline:(true, true) + (self#type_variant_list lst)] ] (* EQUAL DOTDOT {(Ptype_open, Public, None)} *) | (Ptype_open, Public, None) -> [ [atom ".."] ] + | (Ptype_open, Private, None) -> [ + [privateAtom; atom ".."] + ] (* Super confusing how record/variants' manifest is not actually the description of the structure. What's in the manifest in that case is the *second* EQUALS asignment. *) @@ -2936,7 +2983,7 @@ let printer = object(self:'self) (Ptype_variant _, _, Some _)} *) | (Ptype_variant lst, scope, Some mani) -> [ [self#core_type mani]; - let variant = makeList ~break:IfNeed ~postSpace:true ~inline:(true, true) (List.map self#type_variant_leaf lst) in + let variant = makeList ~break:IfNeed ~postSpace:true ~inline:(true, true) (self#type_variant_list lst) in privatize scope [variant]; ] @@ -3055,19 +3102,17 @@ let printer = object(self:'self) )) ) | Ptyp_variant (l, closed, low) -> - let pcd_loc = x.ptyp_loc in let pcd_attributes = x.ptyp_attributes in let pcd_res = None in let variant_helper i rf = - match rf with - | Rtag (label, attrs, opt_ampersand, ctl) -> - let pcd_name = { - txt = label; - loc = pcd_loc; - } in + match rf.prf_desc with + | Rtag (label, opt_ampersand, ctl) -> let pcd_args = Pcstr_tuple ctl in - let all_attrs = List.concat [pcd_attributes; attrs] in - self#type_variant_leaf ~opt_ampersand ~polymorphic:true {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes = all_attrs} + let all_attrs = List.concat [pcd_attributes; rf.prf_attributes] in + self#type_variant_leaf + ~opt_ampersand + ~polymorphic:true + {pcd_name = label; pcd_args; pcd_res; pcd_loc = label.loc; pcd_attributes = all_attrs} | Rinherit ct -> (* '| type' is required if the Rinherit is not the first row_field in the list @@ -3805,7 +3850,7 @@ let printer = object(self:'self) )} as e -> let args = PipeFirstTree.Args args in begin match pexp_attributes with - | [{txt = "bs"}, PStr []] -> + | [{ attr_name = {txt = "bs"}; attr_payload = PStr []}] -> flatten ((PipeFirstTree.ExpU arg2)::args::acc) arg1 | [] -> (* the uncurried attribute might sit on the Pstr_eval @@ -4470,11 +4515,11 @@ let printer = object(self:'self) label (atom (lbl ^ "=")) (makeList ~break:IfNeed ~wrap:("{", "}") [self#dont_preserve_braces#simplifyUnparseExpr expression]) - | Pexp_open (_, lid, e) + | Pexp_open (me, e) when self#isSeriesOfOpensFollowedByNonSequencyExpression expression -> label (makeList [atom lbl; atom "="; - (label (self#longident_loc lid) (atom "."))]) + (label (self#moduleExpressionToFormattedApplicationItems me.popen_expr) (atom "."))]) (self#formatNonSequencyExpression e) | Pexp_apply ({pexp_desc = Pexp_ident _} as funExpr, args) when printedStringAndFixityExpr funExpr == Normal && @@ -4915,7 +4960,7 @@ let printer = object(self:'self) in let prepare_arg = function | `Value (l,eo,p) -> source_map ~loc:p.ppat_loc (self#label_exp l eo p) - | `Type nt -> atom ("type " ^ nt) + | `Type nt -> atom ("type " ^ nt.txt) in let single_argument_no_parens p ret = if uncurried then false @@ -4958,7 +5003,7 @@ let printer = object(self:'self) leadingAbstractVars nonVarifiedType = same_ast_modulo_varification_and_extensions polyType nonVarifiedType && - for_all2' string_equal typeVars leadingAbstractVars + for_all2' string_loc_equal typeVars leadingAbstractVars (* Reinterpret this as a pattern constraint since we don't currently have a way to disambiguate. There is currently a way to disambiguate a parsing @@ -5009,7 +5054,7 @@ let printer = object(self:'self) method locallyAbstractPolymorphicFunctionBinding prefixText layoutPattern funWithNewTypes absVars bodyType = let appTerms = self#unparseExprApplicationItems funWithNewTypes in - let locallyAbstractTypes = (List.map atom absVars) in + let locallyAbstractTypes = (List.map (fun x -> atom x.txt) absVars) in let typeLayout = source_map ~loc:bodyType.ptyp_loc (self#core_type bodyType) in @@ -5112,9 +5157,9 @@ let printer = object(self:'self) *) method attachDocAttrsToLayout (* all std attributes attached on the ast node backing the layout *) - ~stdAttrs:(stdAttrs : Ast_404.Parsetree.attributes) + ~stdAttrs:(stdAttrs : Ast_408.Parsetree.attributes) (* all doc comments attached on the ast node backing the layout *) - ~docAttrs:(docAttrs : Ast_404.Parsetree.attributes) + ~docAttrs:(docAttrs : Ast_408.Parsetree.attributes) (* location of the layout *) ~loc (* layout to attach the doc comments to *) @@ -5133,11 +5178,11 @@ let printer = object(self:'self) * of the whole layout. *) let loc = match stdAttrs with - | (astLoc, _)::_ -> astLoc.loc + | { attr_name = astLoc; _}::_ -> astLoc.loc | [] -> loc in let rec aux prevLoc layout = function - | ((x, _) as attr : Ast_404.Parsetree.attribute)::xs -> + | ({ attr_name = x; _} as attr : Ast_408.Parsetree.attribute)::xs -> let newLayout = let range = Range.makeRangeBetween x.loc prevLoc in let layout = @@ -5155,12 +5200,18 @@ let printer = object(self:'self) in aux loc layout (List.rev docAttrs) - method binding prefixText x = (* TODO: print attributes *) - let body = match x.pvb_pat.ppat_desc with + method value_binding prefixText { pvb_pat; pvb_attributes; pvb_loc; pvb_expr } = + self#binding prefixText ~attrs:pvb_attributes ~loc:pvb_loc ~pat:pvb_pat pvb_expr + + method binding_op prefixText { pbop_pat; pbop_loc; pbop_exp } = + self#binding (escape_stars_slashes prefixText) ~loc:pbop_loc ~pat:pbop_pat pbop_exp + + method binding prefixText ?(attrs=[]) ~loc ~pat expr = (* TODO: print attributes *) + let body = match pat.ppat_desc with | (Ppat_var _) -> self#wrappedBinding prefixText ~arrow:"=>" - (source_map ~loc:x.pvb_pat.ppat_loc (self#simple_pattern x.pvb_pat)) - [] x.pvb_expr + (source_map ~loc:pat.ppat_loc (self#simple_pattern pat)) + [] expr (* Ppat_constraint is used in bindings of the form @@ -5199,9 +5250,9 @@ let printer = object(self:'self) ); *) let layoutPattern = - source_map ~loc:x.pvb_pat.ppat_loc (self#simple_pattern p) + source_map ~loc:pat.ppat_loc (self#simple_pattern p) in - let leadingAbsTypesAndExpr = self#leadingCurriedAbstractTypes x.pvb_expr in + let leadingAbsTypesAndExpr = self#leadingCurriedAbstractTypes expr in match (p.ppat_desc, ty.ptyp_desc, leadingAbsTypesAndExpr) with | (Ppat_var _, Ptyp_poly (typeVars, varifiedPolyType), @@ -5251,7 +5302,7 @@ let printer = object(self:'self) nonVarifiedExprType | _ -> let typeLayout = source_map ~loc:ty.ptyp_loc (self#core_type ty) in - let appTerms = self#unparseExprApplicationItems x.pvb_expr in + let appTerms = self#unparseExprApplicationItems expr in self#formatSimplePatternBinding prefixText layoutPattern @@ -5260,19 +5311,19 @@ let printer = object(self:'self) ) | _ -> let layoutPattern = - source_map ~loc:x.pvb_pat.ppat_loc (self#pattern x.pvb_pat) + source_map ~loc:pat.ppat_loc (self#pattern pat) in - let appTerms = self#unparseExprApplicationItems x.pvb_expr in + let appTerms = self#unparseExprApplicationItems expr in self#formatSimplePatternBinding prefixText layoutPattern None appTerms in - let {stdAttrs; docAttrs} = partitionAttributes ~partDoc:true x.pvb_attributes in + let {stdAttrs; docAttrs} = partitionAttributes ~partDoc:true attrs in let body = makeList ~inline:(true, true) [body] in - let layout = self#attach_std_item_attrs stdAttrs (source_map ~loc:x.pvb_loc body) in + let layout = self#attach_std_item_attrs stdAttrs (source_map ~loc:loc body) in self#attachDocAttrsToLayout ~stdAttrs ~docAttrs - ~loc:x.pvb_pat.ppat_loc + ~loc:pat.ppat_loc ~layout () @@ -5316,6 +5367,19 @@ let printer = object(self:'self) loc_ghost = false } + method bindingOpsLocationRange { let_; ands; _ } = + let fstLoc = let_.pbop_loc in + let lstLoc = match ands with + | [] -> fstLoc + | xs -> + let len = List.length xs in + (List.nth xs (len - 1)).pbop_loc in + { + loc_start = fstLoc.loc_start; + loc_end = lstLoc.loc_end; + loc_ghost = false + } + method bindings ?extension (rf, l) = let label = add_extension_sugar "let" extension in let label = match rf with @@ -5323,11 +5387,11 @@ let printer = object(self:'self) | Recursive -> label ^ " rec" in match l with - | [x] -> self#binding label x + | [x] -> self#value_binding label x | l -> let items = List.mapi (fun i x -> let loc = extractLocValBinding x in - let layout = self#binding (if i == 0 then label else "and") x in + let layout = self#value_binding (if i == 0 then label else "and") x in (loc, layout) ) l in @@ -5344,6 +5408,31 @@ let printer = object(self:'self) ~inline:(true, true) itemsLayout + method letop_bindings { let_; ands } = + let label = let_.pbop_op.txt in + let let_item = self#binding_op label let_ in + match ands with + | [] -> let_item + | l -> + let and_items = List.map (fun x -> + let loc = extractLocBindingOp x in + let layout = self#binding_op x.pbop_op.txt x in + (loc, layout) + ) l + in + let itemsLayout = groupAndPrint + ~xf:(fun (_, layout) -> layout) + ~getLoc:(fun (loc, _) -> loc) + ~comments:self#comments + ((extractLocBindingOp let_, let_item) :: and_items) + in + makeList + ~postSpace:true + ~break:Always + ~indent:0 + ~inline:(true, true) + itemsLayout + method letList expr = (* Recursively transform a nested ast of "let-items", into a flat * list containing the location indicating start/end of the "let-item" and @@ -5362,13 +5451,22 @@ let printer = object(self:'self) let bindingsLoc = self#bindingsLocationRange l in let layout = source_map ~loc:bindingsLoc bindingsLayout in processLetList ((bindingsLoc, layout)::acc) e - | (attrs, Pexp_open (ovf, lid, e)) + | ([], Pexp_letop ( {body; _} as op)) -> + (* For "letList" bindings, the start/end isn't as simple as with + * module value bindings. For "let lists", the sequences were formed + * within braces {}. The parser relocates the first let binding to the + * first brace. *) + let bindingsLayout = self#letop_bindings op in + let bindingsLoc = self#bindingOpsLocationRange op in + let layout = source_map ~loc:bindingsLoc bindingsLayout in + processLetList ((bindingsLoc, layout)::acc) body + | (attrs, Pexp_open (me, e)) (* Add this when check to make sure these are handled as regular "simple expressions" *) when not (self#isSeriesOfOpensFollowedByNonSequencyExpression {expr with pexp_attributes = []}) -> - let overrideStr = match ovf with | Override -> "!" | Fresh -> "" in + let overrideStr = match me.popen_override with | Override -> "!" | Fresh -> "" in let openLayout = label ~space:true (atom ("open" ^ overrideStr)) - (self#longident_loc lid) + (self#moduleExpressionToFormattedApplicationItems me.popen_expr) in let attrsOnOpen = makeList ~inline:(true, true) ~postSpace:true ~break:Always @@ -5377,11 +5475,11 @@ let printer = object(self:'self) (* Just like the bindings, have to synthesize a location since the * Pexp location is parsed (potentially) beginning with the open * brace {} in the let sequence. *) - let layout = source_map ~loc:lid.loc attrsOnOpen in + let layout = source_map ~loc:me.popen_loc attrsOnOpen in let loc = { - lid.loc with + me.popen_loc with loc_start = { - lid.loc.loc_start with + me.popen_loc.loc_start with pos_lnum = expr.pexp_loc.loc_start.pos_lnum } } in @@ -5488,7 +5586,10 @@ let printer = object(self:'self) in let attrs = if implicit_arity && (not polyVariant) then - ({txt="implicit_arity"; loc=eo.pexp_loc}, PStr []) :: stdAttrs + { attr_name = { txt="implicit_arity"; loc=eo.pexp_loc } + ; attr_payload = PStr [] + ; attr_loc = eo.pexp_loc + } :: stdAttrs else stdAttrs in @@ -5531,7 +5632,10 @@ let printer = object(self:'self) let construction = label ~space ctor arguments in if implicit_arity && (not polyVariant) then formatAttributed construction - (self#attributes [({txt="implicit_arity"; loc=po.ppat_loc}, PStr [])]) + (self#attributes + [ { attr_name = { txt="implicit_arity"; loc=po.ppat_loc } + ; attr_payload = PStr [] + ; attr_loc = po.ppat_loc }]) else construction @@ -5896,6 +6000,7 @@ let printer = object(self:'self) | UnaryNotPrefix _ | UnaryPostfix _ | Infix _ -> self#simplifyUnparseExpr x + | Letop _ | Andop _ | Normal -> if x.pexp_attributes == [] then (* `let a = foo().bar` instead of `let a = (foo()).bar *) @@ -6021,34 +6126,37 @@ let printer = object(self:'self) method isSeriesOfOpensFollowedByNonSequencyExpression expr = match (expr.pexp_attributes, expr.pexp_desc) with | ([], Pexp_let _) -> false + | ([], Pexp_letop _) -> false | ([], Pexp_sequence _) -> false | ([], Pexp_letmodule _) -> false - | ([], Pexp_open (ovf, _, e)) -> - ovf == Fresh && self#isSeriesOfOpensFollowedByNonSequencyExpression e + | ([], Pexp_open (me, e)) -> + me.popen_override == Fresh && self#isSeriesOfOpensFollowedByNonSequencyExpression e | ([], Pexp_letexception _) -> false | ([], Pexp_extension ({txt}, _)) -> txt = "bs.obj" | _ -> true method unparseObject ?wrap:((lwrap,rwrap)=("", "")) ?(withStringKeys=false) l o = - let core_field_type (s, attrs, ct) = - let l = extractStdAttrs attrs in - let row = - let rowKey = if withStringKeys then - (makeList ~wrap:("\"", "\"") [atom s]) - else (atom s) + let core_field_type = fun { pof_desc; pof_attributes; _ } -> match pof_desc with + | Otag ({txt}, ct) -> + let l = extractStdAttrs pof_attributes in + let row = + let rowKey = if withStringKeys then + (makeList ~wrap:("\"", "\"") [atom txt]) + else (atom txt) in label ~space:true - (makeList ~break:Layout.Never [rowKey; (atom ":")]) - (self#core_type ct) - in - (match l with - | [] -> row - | _::_ -> - makeList - ~postSpace:true - ~break:IfNeed - ~inline:(true, true) - (List.concat [self#attributes attrs; [row]])) + (makeList ~break:Layout.Never [rowKey; (atom ":")]) + (self#core_type ct) + in + (match l with + | [] -> row + | _::_ -> + makeList + ~postSpace:true + ~break:IfNeed + ~inline:(true, true) + (List.concat [self#attributes pof_attributes; [row]])) + | Oinherit ct -> makeList ~break:Layout.Never [atom "..."; self#core_type ct] in let rows = List.map core_field_type l in let openness = match o with @@ -6231,7 +6339,8 @@ let printer = object(self:'self) | Pexp_array l -> Some (self#unparseSequence ~construct:`Array l) | Pexp_let _ | Pexp_sequence _ - | Pexp_letmodule _ | Pexp_letexception _ -> + | Pexp_letmodule _ | Pexp_letexception _ + | Pexp_letop _ -> Some (makeLetSequence (self#letList x)) | Pexp_extension e -> begin match expression_immediate_extension_sugar x with @@ -6245,10 +6354,14 @@ let printer = object(self:'self) Some (makeLetSequence (self#letList x)) | _ -> Some (self#extension e) end - | Pexp_open (_, lid, e) -> + | Pexp_open (me, e) -> if self#isSeriesOfOpensFollowedByNonSequencyExpression x then - Some (label (label (self#longident_loc lid) (atom ("."))) - (self#formatNonSequencyExpression e)) + Some + (label + (label + (self#moduleExpressionToFormattedApplicationItems me.popen_expr) + (atom ("."))) + (self#formatNonSequencyExpression e)) else Some (makeLetSequence (self#letList x)) | Pexp_send (e, s) -> @@ -6261,7 +6374,7 @@ let printer = object(self:'self) in let lhs = self#simple_enough_to_be_lhs_dot_send e in let lhs = if needparens then makeList ~wrap:("(",")") [lhs] else lhs in - Some (label (makeList [lhs; atom "#";]) (atom s)) + Some (label (makeList [lhs; atom "#";]) (atom s.txt)) | _ -> None in match item with @@ -6363,12 +6476,14 @@ let printer = object(self:'self) (* [@ ...] Simple attributes *) method attribute = function - | { Location. txt = ("ocaml.doc" | "ocaml.text") }, - PStr [{ pstr_desc = Pstr_eval ({ pexp_desc = Pexp_constant (Pconst_string(text, None)) } , _); - pstr_loc }] -> + | { attr_name = { Location. txt = ("ocaml.doc" | "ocaml.text") } + ; attr_payload = + PStr [{ pstr_desc = Pstr_eval ({ pexp_desc = Pexp_constant (Pconst_string(text, None)) } , _); + pstr_loc }] + ; _ } -> let text = if text = "" then "/**/" else "/**" ^ text ^ "*/" in makeList ~inline:(true, true) ~postSpace:true ~preSpace:true ~indent:0 ~break:IfNeed [atom ~loc:pstr_loc text] - | (s, e) -> self#payload "@" s e + | { attr_name; attr_payload; _ } -> self#payload "@" attr_name attr_payload (* [@@ ... ] Attributes that occur after a major item in a structure/class *) method item_attribute = self#attribute @@ -6447,7 +6562,7 @@ let printer = object(self:'self) | Pctf_inherit ct -> label ~space:true (atom "inherit") (self#class_constructor_type ct) | Pctf_val (s, mf, vf, ct) -> - let valueFlags = self#value_type_flags_for (s ^ ":") (vf, mf) in + let valueFlags = self#value_type_flags_for (s.txt ^ ":") (vf, mf) in label ~space:true ( @@ -6457,7 +6572,7 @@ let printer = object(self:'self) ) (self#core_type ct) | Pctf_method (s, pf, vf, ct) -> - let methodFlags = self#method_sig_flags_for (s ^ ":") vf + let methodFlags = self#method_sig_flags_for (s.txt ^ ":") vf in let pubOrPrivate = match pf with @@ -6530,7 +6645,7 @@ let printer = object(self:'self) | _ -> [formattedDocs; formattedAttrs; primDecl] in makeSpacedBreakableInlineList layouts - method class_instance_type x = + method classTypeSigsAndRest x = match x.pcty_desc with | Pcty_signature cs -> let {pcsig_self = ct; pcsig_fields = l} = cs in @@ -6541,12 +6656,21 @@ let printer = object(self:'self) label ~space:true (atom "as") (self#core_type ct) :: instTypeFields in + allItems + | _ -> [self#class_instance_type x] + + method class_instance_type x = + match x.pcty_desc with + | Pcty_signature _ + | Pcty_open _ -> + let opens, rest = self#classTypeOpens x in + let cs = self#classTypeSigsAndRest rest in self#attach_std_item_attrs ~allowUncurry:false x.pcty_attributes ( makeList ~wrap:("{", "}") ~postSpace:true ~break:Layout.Always_rec - (List.map semiTerminated allItems) + (List.map semiTerminated (List.concat [opens; cs])) ) | Pcty_constr (li, l) -> self#attach_std_attrs x.pcty_attributes ( @@ -6561,6 +6685,22 @@ let printer = object(self:'self) self#attach_std_item_attrs x.pcty_attributes (self#extension e) | Pcty_arrow _ -> failwith "class_instance_type should not be printed with Pcty_arrow" + method classTypeOpens x = + let rec gatherOpens acc opn = + match opn.pcty_desc with + | Pcty_open (md, ct) -> + let li = md.popen_expr in + gatherOpens + (source_map ~loc:li.loc + (label ~space:true + (atom ("open" ^ (override md.popen_override))) + (self#longident_loc li)) + :: acc) + ct + | _ -> List.rev acc, opn + in + gatherOpens [] x + method class_declaration_list l = let class_declaration ?(class_keyword=false) ({pci_params=ls; pci_name={txt}; pci_virt; pci_loc} as x) = @@ -6676,7 +6816,7 @@ let printer = object(self:'self) ( match so with | None -> inheritExp; - | Some s -> label ~space:true inheritExp (atom ("as " ^ s)) + | Some s -> label ~space:true inheritExp (atom ("as " ^ s.txt)) ) | Pcf_val (s, mf, Cfk_concrete (ovf, e)) -> let opening = match mf with @@ -6833,9 +6973,12 @@ let printer = object(self:'self) objects. *) | Pcl_let _ - | Pcl_structure _ -> - let rows = (self#classExprLetsAndRest x) in - makeList ~wrap:("{", "}") ~inline:(true, false) ~postSpace:true ~break:Always_rec (List.map semiTerminated rows) + | Pcl_structure _ + | Pcl_open _ -> + let opens, rest = self#classExprOpens x in + let rows = self#classExprLetsAndRest rest in + makeList ~wrap:("{", "}") ~inline:(true, false) ~postSpace:true ~break:Always_rec + (List.map semiTerminated (List.concat [opens; rows])) | Pcl_extension e -> self#extension e | _ -> formatPrecedence (self#class_expr x) in source_map ~loc:x.pcl_loc itm @@ -6853,8 +6996,25 @@ let printer = object(self:'self) (self#bindings (rf, l)) in (binding :: self#classExprLetsAndRest ce) + | Pcl_open (_, ce) -> self#classExprLetsAndRest ce | _ -> [self#class_expr x] + method classExprOpens x = + let rec gatherOpens acc opn = + match opn.pcl_desc with + | Pcl_open (md, ce) -> + let li = md.popen_expr in + gatherOpens + (source_map ~loc:li.loc + (label ~space:true + (atom ("open" ^ (override md.popen_override))) + (self#longident_loc li)) + :: acc) + ce + | _ -> List.rev acc, opn + in + gatherOpens [] x + method class_expr x = let {stdAttrs} = partitionAttributes x.pcl_attributes in (* We cannot handle the attributes here. Must handle them in each item *) @@ -6884,6 +7044,7 @@ let printer = object(self:'self) label (makeList ~postSpace:true [atom "class"; self#longident_loc li]) (makeTup (List.map self#non_arrowed_non_simple_core_type l)) + | Pcl_open _ | Pcl_constraint _ | Pcl_extension _ | Pcl_let _ @@ -6950,7 +7111,9 @@ let printer = object(self:'self) | Psig_typext te -> self#type_extension te | Psig_exception ed -> - self#exception_declaration ed + self#exception_declaration + { ed.ptyexn_constructor + with pext_attributes = ed.ptyexn_attributes @ ed.ptyexn_constructor.pext_attributes} | Psig_class l -> let class_description ?(class_keyword=false) @@ -7029,12 +7192,12 @@ let printer = object(self:'self) self#attach_std_item_attrs stdAttrs @@ label ~space:true (atom ("open" ^ (override od.popen_override))) - (self#longident_loc od.popen_lid) + (self#longident_loc od.popen_expr) in self#attachDocAttrsToLayout ~stdAttrs ~docAttrs - ~loc:od.popen_lid.loc + ~loc:od.popen_expr.loc ~layout () | Psig_include incl -> @@ -7121,6 +7284,25 @@ let printer = object(self:'self) ~loc ~layout () + | Psig_modsubst { pms_name; pms_manifest; pms_attributes; pms_loc } -> + let name = atom pms_name.txt in + let main = makeList ~postSpace:true + [atom "module"; name; atom ":="; self#longident_loc pms_manifest] + in + let {stdAttrs; docAttrs} = + partitionAttributes ~partDoc:true pms_attributes + in + let layout = + self#attach_std_item_attrs stdAttrs main + in + self#attachDocAttrsToLayout + ~stdAttrs + ~docAttrs + ~loc:pms_loc + ~layout + () + | Psig_typesubst l -> + self#type_def_list ~eq_symbol:":=" (Recursive, l) in source_map ~loc:x.psig_loc item @@ -7234,13 +7416,13 @@ let printer = object(self:'self) td | Pwith_module (li, li2) -> modSub (self#longident_loc li) li2 "=" - | Pwith_typesubst td -> + | Pwith_typesubst (_, td) -> self#formatOneTypeDef typeAtom (atom ~loc:td.ptype_name.loc td.ptype_name.txt) destrAtom td - | Pwith_modsubst (s, li2) -> modSub (atom s.txt) li2 ":=" + | Pwith_modsubst (s, li2) -> modSub (self#longident s.txt) li2 ":=" in (match l with | [] -> self#module_type ~space letPattern mt @@ -7437,7 +7619,10 @@ let printer = object(self:'self) | Pstr_type (rf, l) -> (self#type_def_list (rf, l)) | Pstr_value (rf, l) -> (self#bindings (rf, l)) | Pstr_typext te -> (self#type_extension te) - | Pstr_exception ed -> (self#exception_declaration ed) + | Pstr_exception ed -> + self#exception_declaration + { ed.ptyexn_constructor + with pext_attributes = ed.ptyexn_attributes @ ed.ptyexn_constructor.pext_attributes} | Pstr_module x -> let bindingName = atom ~loc:x.pmb_name.loc x.pmb_name.txt in self#attach_std_item_attrs x.pmb_attributes @@ @@ -7446,7 +7631,7 @@ let printer = object(self:'self) self#attach_std_item_attrs od.popen_attributes @@ makeList ~postSpace:true [ atom ("open" ^ (override od.popen_override)); - self#longident_loc od.popen_lid; + self#moduleExpressionToFormattedApplicationItems od.popen_expr; ] | Pstr_modtype x -> let name = atom x.pmtd_name.txt in @@ -7967,8 +8152,10 @@ let longident_for_arity lid = (* add expilcit_arity to a list of attributes *) let add_explicit_arity loc attributes = - ({txt="explicit_arity"; loc}, PStr []) :: - normalized_attributes "explicit_arity" attributes + { attr_name = { txt="explicit_arity"; loc } + ; attr_payload = PStr [] + ; attr_loc = loc + } :: normalized_attributes "explicit_arity" attributes (* explicit_arity_exists check if expilcit_arity exists *) @@ -8015,7 +8202,8 @@ let add_explicit_arity_mapper super = explicit_arity_not_exists pexp_attributes -> {pexp_desc=Pexp_construct(lid, Some (wrap_expr_with_tuple sp)); pexp_loc; - pexp_attributes=add_explicit_arity pexp_loc pexp_attributes} + pexp_attributes=add_explicit_arity pexp_loc pexp_attributes; + pexp_loc_stack = []} | x -> x in super_expr mapper expr @@ -8031,7 +8219,8 @@ let add_explicit_arity_mapper super = explicit_arity_not_exists ppat_attributes -> {ppat_desc=Ppat_construct(lid, Some (wrap_pat_with_tuple sp)); ppat_loc; - ppat_attributes=add_explicit_arity ppat_loc ppat_attributes} + ppat_attributes=add_explicit_arity ppat_loc ppat_attributes; + ppat_loc_stack = []} | x -> x in super_pat mapper pat diff --git a/src/reason-parser/reason_pprint_ast.mli b/src/reason-parser/reason_pprint_ast.mli index dad5f69db..e40511966 100644 --- a/src/reason-parser/reason_pprint_ast.mli +++ b/src/reason-parser/reason_pprint_ast.mli @@ -1,4 +1,5 @@ -open Migrate_parsetree.Ast_404.Parsetree +open Migrate_parsetree +open Ast_408.Parsetree val configure : width:int -> diff --git a/src/reason-parser/reason_syntax_util.cppo.ml b/src/reason-parser/reason_syntax_util.cppo.ml index 72e883b32..33946529a 100644 --- a/src/reason-parser/reason_syntax_util.cppo.ml +++ b/src/reason-parser/reason_syntax_util.cppo.ml @@ -16,7 +16,7 @@ #ifdef BS_NO_COMPILER_PATCH open Migrate_parsetree -open Ast_404 +open Ast_408 #endif open Asttypes @@ -385,18 +385,23 @@ let map_core_type f typ = | Ptyp_constr (lid, typs) -> Ptyp_constr (map_lident f lid, typs) | Ptyp_object (fields, closed_flag) when !rename_labels -> - Ptyp_object (List.map (fun (s, attrs, typ) -> f s, attrs, typ) fields, closed_flag) + Ptyp_object + (List.map (function + | { pof_desc = Otag (s, typ); _ } as pof -> { pof with pof_desc = Otag ({ s with txt = f s.txt }, typ) } + | other -> other) + fields + , closed_flag) | Ptyp_class (lid, typs) -> Ptyp_class (map_lident f lid, typs) | Ptyp_alias (typ, s) -> Ptyp_alias (typ, f s) | Ptyp_variant (rfs, closed, lbls) -> Ptyp_variant (List.map (function - | Rtag (lbl, attrs, b, cts) -> - Rtag (f lbl, attrs, b, cts) + | { prf_desc = Rtag (lbl, b, cts) } as prf -> + { prf with prf_desc = Rtag ({ lbl with txt = f lbl.txt }, b, cts) } | t -> t) rfs, closed, lbls) | Ptyp_poly (vars, typ) -> - Ptyp_poly (List.map f vars, typ) + Ptyp_poly (List.map (fun li -> { li with txt = f li.txt }) vars, typ) | Ptyp_package (lid, typs) -> Ptyp_package (map_lident f lid, List.map (fun (lid, typ) -> (map_lident f lid, typ)) typs) | other -> other @@ -436,7 +441,7 @@ let map_label label = map_arg_label f label in pexp_desc = Pexp_setfield (e1, map_lid lid, e2) } | { pexp_desc = Pexp_send (e, s) } -> { expr with - pexp_desc = Pexp_send (e, f s) } + pexp_desc = Pexp_send (e, { s with txt = f s.txt }) } | { pexp_desc = Pexp_new lid } -> { expr with pexp_desc = Pexp_new (map_lid lid) } @@ -449,10 +454,7 @@ let map_label label = map_arg_label f label in pexp_desc = Pexp_override name_exp_list } | { pexp_desc = Pexp_newtype (s, e) } -> { expr with - pexp_desc = Pexp_newtype (f s, e) } - | { pexp_desc = Pexp_open (override, lid, e) } -> - { expr with - pexp_desc = Pexp_open (override, map_lid lid, e) } + pexp_desc = Pexp_newtype ({ s with txt = f s.txt }, e) } | _ -> expr in super.expr mapper expr @@ -526,9 +528,9 @@ let map_label label = map_arg_label f label in | Pctf_inherit class_type -> Pctf_inherit (map_class_type f class_type) | Pctf_val (lbl, mut, vf, ct) -> - Pctf_val (f lbl, mut, vf, ct) + Pctf_val ({ lbl with txt = f lbl.txt }, mut, vf, ct) | Pctf_method (lbl, pf, vf, ct) -> - Pctf_method (f lbl, pf, vf, ct) + Pctf_method ({ lbl with txt = f lbl.txt }, pf, vf, ct) | x -> x in super.class_type_field mapper @@ -552,7 +554,7 @@ let map_label label = map_arg_label f label in } let remove_stylistic_attrs_mapper_maker super = - let open Ast_404 in + let open Ast_408 in let open Ast_mapper in { super with expr = begin fun mapper expr -> @@ -580,18 +582,94 @@ let remove_stylistic_attrs_mapper_maker super = let remove_stylistic_attrs_mapper = remove_stylistic_attrs_mapper_maker Ast_mapper.default_mapper +#if OCAML_VERSION >= (4, 8, 0) +let noop_mapper = + let noop = fun _mapper x -> x in + { Ast_mapper.default_mapper with + expr = noop; + structure = noop; + structure_item = noop; + signature = noop; + signature_item = noop; } +(* Don't need to backport past 4.08 *) +let backport_letopt_mapper = noop_mapper +#else +(** This will convert Pexp_letop into a series of `apply`s to simulate 4.08's behavior. + * + * For example, + * + * { + * let+ x = y + * and+ a = b; + * x + a + * } + * + * Will be transformed into: + * + * (let+)((and+)(y, b), ((x, a)) => x + a) + *) +let backport_letopt_mapper_maker super = + let open Ast_408 in + let open Ast_mapper in +{ super with + expr = fun mapper expr -> + match expr.pexp_desc with + | Pexp_letop { let_; ands; body } -> + (* coalesce the initial 'let' and any subsequent 'and's into a final + Pattern (for the argument of the continuation function) and + Expression (the first arg ot the let function) + + let+ a = b + and+ c = d + and+ e = f + and+ g = h + + produces the pattern (a, (c, (e, g))) + and the expression (and+)(b, (and+)(d, (and+)(f, h))) + *) + let rec loop = function + | [] -> assert false + | {pbop_op; pbop_pat; pbop_exp}::[] -> (pbop_pat, pbop_exp, pbop_op) + | {pbop_op; pbop_pat; pbop_exp; pbop_loc}::rest -> + let (pattern, expr, op) = loop rest in + let and_op_ident = Ast_helper.Exp.ident + ~loc:op.loc + (Location.mkloc (Longident.Lident op.txt) op.loc) + in + ( + Ast_helper.Pat.tuple ~loc:pbop_loc [pbop_pat; pattern], + Ast_helper.Exp.apply ~loc:pbop_loc and_op_ident [(Nolabel, pbop_exp); (Nolabel, expr)], + pbop_op + ) + in + let (pattern, expr, _) = loop (let_::ands) in + let let_op_ident = Ast_helper.Exp.ident + ~loc:let_.pbop_op.loc + (Location.mkloc (Longident.Lident let_.pbop_op.txt) let_.pbop_op.loc) + in + super.expr mapper {expr with + pexp_desc = Pexp_apply (let_op_ident, [ + (Nolabel, expr); + (Nolabel, Ast_helper.Exp.fun_ ~loc:let_.pbop_loc Nolabel None pattern body) + ])} + | _ -> super.expr mapper expr +} + +let backport_letopt_mapper = + backport_letopt_mapper_maker Ast_mapper.default_mapper +#endif + +let escape_stars_slashes str = + if String.contains str '/' then + replace_string "/*" "/\\*" @@ + replace_string "*/" "*\\/" @@ + replace_string "//" "/\\/" @@ + str + else + str + (** escape_stars_slashes_mapper escapes all stars and slashes in an AST *) -let escape_stars_slashes_mapper = - let escape_stars_slashes str = - if String.contains str '/' then - replace_string "/*" "/\\*" @@ - replace_string "*/" "*\\/" @@ - replace_string "//" "/\\/" @@ - str - else - str - in - identifier_mapper escape_stars_slashes +let escape_stars_slashes_mapper = identifier_mapper escape_stars_slashes (* To be used in parser, transform a token into an ast node with different identifier *) @@ -604,7 +682,7 @@ let ml_to_reason_swap_operator_mapper = identifier_mapper ml_to_reason_swap (* attribute_equals tests an attribute is txt *) let attribute_equals to_compare = function - | ({txt}, _) -> txt = to_compare + | { attr_name = {txt}; _ } -> txt = to_compare (* attribute_exists tests if an attribute exists in a list *) diff --git a/src/reason-parser/reason_syntax_util.cppo.mli b/src/reason-parser/reason_syntax_util.cppo.mli index 9f7c26bb3..01f13ae62 100644 --- a/src/reason-parser/reason_syntax_util.cppo.mli +++ b/src/reason-parser/reason_syntax_util.cppo.mli @@ -13,7 +13,7 @@ BuckleScript; ping @chenglou and a few others and we'll keep them synced up by patching the right parts, through the power of types(tm) *) -open Migrate_parsetree.Ast_404 +open Migrate_parsetree.Ast_408 val ml_to_reason_swap : string -> string @@ -38,6 +38,10 @@ val isLineComment : string -> bool val remove_stylistic_attrs_mapper : Ast_mapper.mapper +val backport_letopt_mapper : Ast_mapper.mapper + +val escape_stars_slashes : string -> string + val escape_stars_slashes_mapper : Ast_mapper.mapper -> Ast_mapper.mapper @@ -47,14 +51,12 @@ val reason_to_ml_swap_operator_mapper : val ml_to_reason_swap_operator_mapper : Ast_mapper.mapper -> Ast_mapper.mapper -val attribute_exists : 'a -> ('a Asttypes.loc * 'b) list -> bool +val attribute_exists : string -> Parsetree.attributes -> bool val attributes_conflicted : - 'a -> 'a -> ('a Asttypes.loc * 'b) list -> bool + string -> string -> Parsetree.attributes -> bool -val normalized_attributes : - 'a -> - ('a Asttypes.loc * 'b) list -> ('a Asttypes.loc * 'b) list +val normalized_attributes : string -> Parsetree.attributes -> Parsetree.attributes val apply_mapper_to_structure : Parsetree.structure -> Ast_mapper.mapper -> Parsetree.structure diff --git a/src/reason-parser/reason_toolchain.ml b/src/reason-parser/reason_toolchain.ml index 199a9e72d..176254002 100644 --- a/src/reason-parser/reason_toolchain.ml +++ b/src/reason-parser/reason_toolchain.ml @@ -79,6 +79,8 @@ *) open Reason_toolchain_conf +open Migrate_parsetree +open Ast_408 open Location open Lexing diff --git a/src/reason-parser/reason_toolchain_conf.ml b/src/reason-parser/reason_toolchain_conf.ml index d74ed4c1b..99d5dbd04 100644 --- a/src/reason-parser/reason_toolchain_conf.ml +++ b/src/reason-parser/reason_toolchain_conf.ml @@ -1,8 +1,8 @@ open Migrate_parsetree -include Ast_404 +include Ast_408 -module From_current = Convert(OCaml_current)(OCaml_404) -module To_current = Convert(OCaml_404)(OCaml_current) +module From_current = Convert(OCaml_current)(OCaml_408) +module To_current = Convert(OCaml_408)(OCaml_current) module type Toolchain = sig (* Parsing *) diff --git a/src/reason-parser/reason_toolchain_ocaml.ml b/src/reason-parser/reason_toolchain_ocaml.ml index 81b7937d6..249751171 100644 --- a/src/reason-parser/reason_toolchain_ocaml.ml +++ b/src/reason-parser/reason_toolchain_ocaml.ml @@ -8,9 +8,10 @@ let doc_comments_filter () = let open Parsetree in let seen = Hashtbl.create 7 in let attribute mapper = function - | ({ Location. txt = ("ocaml.doc" | "ocaml.text")}, - PStr [{ pstr_desc = Pstr_eval ({ pexp_desc = Pexp_constant (Pconst_string(_text, None)) } , _); - pstr_loc = loc }]) as attribute -> + | { attr_name = { Location. txt = ("ocaml.doc" | "ocaml.text")}; + attr_payload = + PStr [{ pstr_desc = Pstr_eval ({ pexp_desc = Pexp_constant (Pconst_string(_text, None)) } , _); + pstr_loc = loc }]} as attribute -> (* Workaround: OCaml 4.02.3 kept an initial '*' in docstrings. * For other versions, we have to put the '*' back. *) Hashtbl.add seen loc (); @@ -137,6 +138,9 @@ let format_implementation_with_comments (structure, _) formatter = let structure = Reason_syntax_util.(apply_mapper_to_structure structure remove_stylistic_attrs_mapper) in + let structure = + Reason_syntax_util.(apply_mapper_to_structure structure backport_letopt_mapper) + in Pprintast.structure formatter (To_current.copy_structure structure) diff --git a/src/refmt/printer_maker.ml b/src/refmt/printer_maker.ml index ca2dda899..81d7f5170 100644 --- a/src/refmt/printer_maker.ml +++ b/src/refmt/printer_maker.ml @@ -47,10 +47,10 @@ let ocamlBinaryParser use_stdin filename = match Ast_io.from_channel chan with | Result.Error _ -> assert false | Result.Ok (_, Ast_io.Impl ((module Version), ast)) -> - let module Convert = Convert(Version)(OCaml_404) in + let module Convert = Convert(Version)(OCaml_408) in ((Obj.magic (Convert.copy_structure ast), []), true, false) | Result.Ok (_, Ast_io.Intf ((module Version), ast)) -> - let module Convert = Convert(Version)(OCaml_404) in + let module Convert = Convert(Version)(OCaml_408) in ((Obj.magic (Convert.copy_signature ast), []), true, true) let reasonBinaryParser use_stdin filename = diff --git a/src/refmt/reason_implementation_printer.ml b/src/refmt/reason_implementation_printer.ml index ac7a85a3c..1f1f7d88b 100644 --- a/src/refmt/reason_implementation_printer.ml +++ b/src/refmt/reason_implementation_printer.ml @@ -1,5 +1,5 @@ open Migrate_parsetree -open Ast_404 +open Ast_408 type t = Parsetree.structure let err = Printer_maker.err @@ -53,10 +53,16 @@ let print printtype filename parsedAsML output_chan output_formatter = let ast = Reason_syntax_util.(apply_mapper_to_structure ast remove_stylistic_attrs_mapper) in + let ast = + Reason_syntax_util.(apply_mapper_to_structure ast backport_letopt_mapper) + in Ast_io.to_channel output_chan filename (Ast_io.Impl ((module OCaml_current), Reason_toolchain.To_current.copy_structure ast)) | `AST -> fun (ast, _) -> ( + let ast = + Reason_syntax_util.(apply_mapper_to_structure ast backport_letopt_mapper) + in Printast.implementation output_formatter (Reason_toolchain.To_current.copy_structure ast) ) diff --git a/src/refmt/reason_interface_printer.ml b/src/refmt/reason_interface_printer.ml index 49ec3f7a4..581860cc3 100644 --- a/src/refmt/reason_interface_printer.ml +++ b/src/refmt/reason_interface_printer.ml @@ -1,5 +1,5 @@ open Migrate_parsetree -open Ast_404 +open Ast_408 type t = Parsetree.signature let err = Printer_maker.err