├── src ├── refmt │ ├── .gitignore │ ├── reason_interface_printer.mli │ ├── reason_implementation_printer.mli │ ├── package.mli │ ├── git_commit.mli │ ├── package.ml │ ├── end_of_line.mli │ ├── dune │ ├── printer_maker.mli │ └── README.md ├── vendored-omp │ ├── tools │ │ ├── pp.mli │ │ ├── add_special_comments.mli │ │ ├── pp_rewrite.mli │ │ ├── pp.ml │ │ └── dune │ ├── src │ │ ├── migrate_parsetree_52_53.ml │ │ ├── migrate_parsetree_53_52.ml │ │ ├── migrate_parsetree_53_54.ml │ │ ├── migrate_parsetree_54_53.ml │ │ ├── migrate_parsetree_51_52.ml │ │ ├── migrate_parsetree_52_51.ml │ │ ├── migrate_parsetree_driver_main.ml │ │ ├── stdlib0.ml │ │ ├── compiler-functions │ │ │ ├── lt_406.ml │ │ │ ├── ge_410_and_lt_412.ml │ │ │ ├── ge_412.ml │ │ │ ├── ge_406_and_lt_408.ml │ │ │ ├── ge_408_and_lt_410.ml │ │ │ ├── ge_50.ml │ │ │ └── ge_52.ml │ │ ├── dune │ │ ├── migrate_parsetree_409_410.ml │ │ ├── migrate_parsetree_410_411.ml │ │ ├── migrate_parsetree_500_414.ml │ │ ├── migrate_parsetree_51_500.ml │ │ ├── migrate_parsetree_402_403.ml │ │ ├── migrate_parsetree_403_402.ml │ │ ├── migrate_parsetree_403_404.ml │ │ ├── migrate_parsetree_404_403.ml │ │ ├── migrate_parsetree_404_405.ml │ │ ├── migrate_parsetree_405_404.ml │ │ ├── migrate_parsetree_405_406.ml │ │ ├── migrate_parsetree_406_405.ml │ │ ├── migrate_parsetree_406_407.ml │ │ ├── migrate_parsetree_407_406.ml │ │ ├── migrate_parsetree_407_408.ml │ │ ├── migrate_parsetree_408_407.ml │ │ ├── migrate_parsetree_408_409.ml │ │ ├── migrate_parsetree_409_408.ml │ │ ├── migrate_parsetree_410_409.ml │ │ ├── migrate_parsetree_411_410.ml │ │ ├── migrate_parsetree_411_412.ml │ │ ├── migrate_parsetree_412_411.ml │ │ ├── migrate_parsetree_412_413.ml │ │ ├── migrate_parsetree_413_412.ml │ │ ├── migrate_parsetree_413_414.ml │ │ ├── migrate_parsetree_414_413.ml │ │ ├── migrate_parsetree_414_500.ml │ │ └── migrate_parsetree_500_51.ml │ └── Makefile ├── reason-parser │ ├── vendor │ │ └── easy_format │ │ │ ├── VERSION │ │ │ └── dune │ ├── reason_toolchain_ocaml.mli │ ├── reason_toolchain_reason.mli │ ├── reason_declarative_lexer.mli │ ├── reason_parser_explain.mli │ ├── error-handling.md │ ├── reason_config.mli │ ├── reason_config.ml │ ├── reason_comment.mli │ ├── reason_recover_parser.mli │ ├── reason_parser_def.ml │ ├── reason_parser_def.mli │ ├── reason_heuristics.mli │ ├── reason_location.mli │ ├── merlin_recovery_intf.ml │ ├── reason_multi_parser.mli │ ├── reason_single_parser.mli │ ├── merlin_recovery.mli │ ├── reason_lexer.mli │ ├── ocaml_util.cppo.mli │ ├── TODO │ ├── reason_oprint.mli │ ├── reason_pprint_ast.mli │ ├── reason_toolchain.mli │ ├── reason_attributes.mli │ └── reason_comment.ml ├── menhir-recover │ ├── dune │ ├── cost.mli │ ├── emitter.mli │ ├── cost.ml │ ├── recovery_intf.ml │ └── recovery_custom.mli ├── menhir-error-processor │ └── dune └── reason-merlin │ └── dune ├── test ├── singleLineCommentEof.t │ ├── input.re │ └── run.t ├── emptyFileComment.t │ ├── input.re │ └── run.t ├── fdLeak.t │ ├── run.t │ └── input.re ├── reasonComments-rei.t │ ├── input.rei │ └── run.t ├── 4.06 │ ├── dune │ ├── error-syntaxError.t │ ├── error-comments.t │ ├── error-lowercase_module.t │ ├── error-lowercase_module_rec.t │ ├── error-reservedField.t │ ├── error-reservedRecordTypePunned.t │ ├── error-reservedRecordPunned.t │ ├── error-reservedRecord.t │ ├── error-reservedRecordType.t │ ├── typecheck-module-and-class.t │ └── attributes.t ├── pervasive.t │ ├── input.mli │ └── run.t ├── 4.08 │ ├── dune │ ├── error-syntaxError.t │ ├── error-comments.t │ ├── error-lowercase_module.t │ ├── error-lowercase_module_rec.t │ ├── error-reservedField.t │ ├── error-reservedRecordTypePunned.t │ ├── error-reservedRecordType.t │ ├── error-reservedRecord.t │ ├── error-reservedRecordPunned.t │ ├── mlSyntax.t │ │ └── run.t │ └── typecheck-features.t ├── backportSyntax.t │ ├── run.t │ └── input.re ├── arityConversion.t │ ├── arity.txt │ ├── run.t │ └── input.ml ├── version.t ├── mlFunctions.t │ ├── input.ml │ └── run.t ├── trailingSpaces.t │ ├── input.re │ └── run.t ├── testUtils.t │ ├── input.re │ └── run.t ├── inlineRecord.t │ ├── input.re │ └── run.t ├── keyword-operators.t │ ├── input.re │ └── run.t ├── lib │ ├── fdLeak.ml │ └── dune ├── 4.10 │ ├── local-openings.t │ │ ├── input.ml │ │ └── run.t │ ├── dune │ └── typecheck-let-ops.t ├── 4.12 │ ├── local-openings.t │ │ ├── input.ml │ │ └── run.t │ ├── dune │ └── typecheck-let-ops.t ├── fixme.t │ ├── input.re │ └── run.t ├── sharpop.t │ ├── input.re │ └── run.t ├── dune ├── attributes-rei.t │ └── run.t ├── mlVariants.t │ ├── run.t │ └── input.ml ├── comments-ml.t │ └── run.t ├── knownMlIssues.t │ ├── run.t │ └── input.ml ├── uchar-esc.t │ ├── input.re │ └── run.t ├── comments-mli.t │ ├── run.t │ └── input.mli ├── extension-str-in-module.t ├── escapesInStrings.t │ ├── input.re │ └── run.t ├── assert.t │ ├── input.re │ └── run.t ├── class_types.t │ ├── input.re │ └── run.t ├── jsx_functor.t │ ├── input.re │ └── run.t ├── knownReIssues.t │ ├── input.re │ └── run.t ├── lazy.t │ └── input.re ├── print-width-env.t ├── rtopIntegration.t ├── bigarray.t │ ├── input.re │ └── run.t ├── raw-identifiers.t │ ├── input.re │ └── run.t ├── class.t │ ├── run.t │ └── input.re ├── extension-exprs.t │ ├── input.re │ └── run.t ├── generics.t │ ├── input.re │ └── run.t ├── trailing.t │ ├── input.re │ └── run.t ├── bigarraySyntax.t │ └── input.re ├── letop.t │ └── input.re ├── externals.t │ ├── input.re │ └── run.t ├── object.t │ └── input.re └── mutation.t │ └── input.re ├── .npmignore ├── rtop.esy.lock ├── opam │ ├── seq.base │ │ ├── files │ │ │ ├── seq.install │ │ │ └── META.seq │ │ └── opam │ ├── base-unix.base │ │ └── opam │ ├── base-threads.base │ │ └── opam │ ├── base-bytes.base │ │ └── opam │ ├── ocamlfind.1.9.6 │ │ └── files │ │ │ └── 0001-Harden-test-for-OCaml-5.patch │ ├── trie.1.0.0 │ │ └── opam │ ├── mew.0.1.0 │ │ └── opam │ ├── mew_vi.0.5.0 │ │ └── opam │ ├── result.1.5 │ │ └── opam │ ├── ppx_derivers.1.2.1 │ │ └── opam │ ├── fix.20230505 │ │ └── opam │ ├── lwt_react.1.2.0 │ │ └── opam │ ├── menhir.20230608 │ │ └── opam │ ├── sexplib0.v0.16.0 │ │ └── opam │ ├── menhirLib.20230608 │ │ └── opam │ ├── menhirSdk.20230608 │ │ └── opam │ ├── dot-merlin-reader.4.9 │ │ └── opam │ ├── merlin-extend.0.6.1 │ │ └── opam │ ├── uchar.0.0.2 │ │ └── opam │ ├── xdg.3.11.1 │ │ └── opam │ ├── stdlib-shims.0.3.0 │ │ └── opam │ ├── merlin-lib.4.12-501 │ │ └── opam │ ├── ocaml-compiler-libs.v0.12.4 │ │ └── opam │ └── cppo.1.6.9 │ │ └── opam ├── overrides │ ├── opam__s__ocamlbuild_opam__c__0.14.2+win_opam_override │ │ ├── files │ │ │ ├── ocamlbuild-0.14.2.patch │ │ │ └── winpatch.patch │ │ └── package.json │ ├── opam__s__uchar_opam__c__0.0.2_opam_override │ │ ├── package.json │ │ └── files │ │ │ └── winpatch.patch │ └── opam__s__ocamlfind_opam__c__1.9.6_opam_override │ │ ├── files │ │ └── findlib.patch │ │ └── package.json ├── .gitignore └── .gitattributes ├── esy.lock ├── .gitignore ├── .gitattributes ├── opam │ ├── base-unix.base │ │ └── opam │ ├── base-threads.base │ │ └── opam │ ├── base-bytes.base │ │ └── opam │ ├── trie.1.0.0 │ │ └── opam │ ├── mew.0.1.0 │ │ └── opam │ ├── mew_vi.0.5.0 │ │ └── opam │ ├── fix.20250428 │ │ └── opam │ ├── result.1.5 │ │ └── opam │ ├── seq.base │ │ └── opam │ ├── ppx_derivers.1.2.1 │ │ └── opam │ ├── lwt_react.1.2.0 │ │ └── opam │ ├── menhirCST.20240715 │ │ └── opam │ ├── menhir.20240715 │ │ └── opam │ ├── menhirLib.20240715 │ │ └── opam │ ├── menhirSdk.20240715 │ │ └── opam │ ├── sexplib0.v0.17.0 │ │ └── opam │ ├── merlin-extend.0.6.2 │ │ └── opam │ ├── stdlib-shims.0.3.0 │ │ └── opam │ ├── xdg.3.19.1 │ │ └── opam │ ├── ocaml-compiler-libs.v0.12.4 │ │ └── opam │ └── fpath.0.7.3 │ │ └── opam └── overrides │ ├── opam__s__uchar_opam__c__0.0.2_opam_override │ ├── package.json │ └── files │ │ └── winpatch.patch │ └── opam__s__ocamlfind_opam__c__1.9.8_opam_override │ ├── files │ └── findlib.patch │ └── package.json ├── dune ├── .ocamlformat-ignore ├── .gitignore ├── CODE_OF_CONDUCT.md ├── js ├── dune └── testRefmtJs.js ├── nix ├── shell.nix ├── ci.nix └── default.nix ├── .github └── workflows │ └── print-esy-cache.js ├── package.json ├── rtop.json ├── docs └── README.md ├── .ocamlformat ├── rtop └── dune ├── reason.json ├── flake.nix ├── rtop.opam ├── PLAN ├── LICENSE.txt ├── flake.lock └── reason.opam /src/refmt/.gitignore: -------------------------------------------------------------------------------- 1 | git_version.ml 2 | -------------------------------------------------------------------------------- /src/vendored-omp/tools/pp.mli: -------------------------------------------------------------------------------- 1 | (* empty *) 2 | -------------------------------------------------------------------------------- /src/reason-parser/vendor/easy_format/VERSION: -------------------------------------------------------------------------------- 1 | 1.2.0 -------------------------------------------------------------------------------- /test/singleLineCommentEof.t/input.re: -------------------------------------------------------------------------------- 1 | // let x = 1 2 | -------------------------------------------------------------------------------- /src/vendored-omp/tools/add_special_comments.mli: -------------------------------------------------------------------------------- 1 | (* empty *) 2 | -------------------------------------------------------------------------------- /src/refmt/reason_interface_printer.mli: -------------------------------------------------------------------------------- 1 | include Printer_maker.PRINTER 2 | -------------------------------------------------------------------------------- /src/refmt/reason_implementation_printer.mli: -------------------------------------------------------------------------------- 1 | include Printer_maker.PRINTER 2 | -------------------------------------------------------------------------------- /test/emptyFileComment.t/input.re: -------------------------------------------------------------------------------- 1 | // file with just a single line comment 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | _esy 2 | node_modules 3 | _build 4 | .git 5 | refmt.js 6 | refmt.map 7 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/seq.base/files/seq.install: -------------------------------------------------------------------------------- 1 | lib:[ 2 | "META.seq" {"META"} 3 | ] 4 | -------------------------------------------------------------------------------- /test/fdLeak.t/run.t: -------------------------------------------------------------------------------- 1 | 2 | $ ulimit -n 24 3 | $ ../lib/fdLeak.exe 4 | EOL: done 5 | -------------------------------------------------------------------------------- /src/reason-parser/reason_toolchain_ocaml.mli: -------------------------------------------------------------------------------- 1 | include Reason_toolchain_conf.Toolchain_spec 2 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_52_53.ml: -------------------------------------------------------------------------------- 1 | include Migrate_parsetree_52_53_migrate 2 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_53_52.ml: -------------------------------------------------------------------------------- 1 | include Migrate_parsetree_53_52_migrate 2 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_53_54.ml: -------------------------------------------------------------------------------- 1 | include Migrate_parsetree_53_54_migrate 2 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_54_53.ml: -------------------------------------------------------------------------------- 1 | include Migrate_parsetree_54_53_migrate 2 | -------------------------------------------------------------------------------- /test/fdLeak.t/input.re: -------------------------------------------------------------------------------- 1 | 2 | let () = 3 | let x = 1 in 4 | Format.eprintf "X: %d@." x 5 | -------------------------------------------------------------------------------- /src/reason-parser/reason_toolchain_reason.mli: -------------------------------------------------------------------------------- 1 | include Reason_toolchain_conf.Toolchain_spec 2 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_51_52.ml: -------------------------------------------------------------------------------- 1 | 2 | include Migrate_parsetree_51_52_migrate 3 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_52_51.ml: -------------------------------------------------------------------------------- 1 | 2 | include Migrate_parsetree_52_51_migrate 3 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_driver_main.ml: -------------------------------------------------------------------------------- 1 | let () = Reason_omp.Driver.run_main () 2 | -------------------------------------------------------------------------------- /src/vendored-omp/tools/pp_rewrite.mli: -------------------------------------------------------------------------------- 1 | val rewrite : bool -> string -> Lexing.lexbuf -> unit 2 | -------------------------------------------------------------------------------- /esy.lock/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Reset any possible .gitignore, we want all esy.lock to be un-ignored. 3 | !* 4 | -------------------------------------------------------------------------------- /rtop.esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.2+win_opam_override/files/ocamlbuild-0.14.2.patch: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rtop.esy.lock/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Reset any possible .gitignore, we want all esy.lock to be un-ignored. 3 | !* 4 | -------------------------------------------------------------------------------- /src/refmt/package.mli: -------------------------------------------------------------------------------- 1 | val version : string 2 | val git_version : string 3 | val git_short_version : string 4 | -------------------------------------------------------------------------------- /test/reasonComments-rei.t/input.rei: -------------------------------------------------------------------------------- 1 | module JustString : { 2 | include Map.S; /* Comment eol include */ 3 | }; 4 | -------------------------------------------------------------------------------- /test/4.06/dune: -------------------------------------------------------------------------------- 1 | (cram 2 | (enabled_if 3 | (or 4 | (= %{ocaml_version} 4.06.0) 5 | (= %{ocaml_version} 4.06.1)))) 6 | -------------------------------------------------------------------------------- /test/pervasive.t/input.mli: -------------------------------------------------------------------------------- 1 | val ( = ) : 'a -> 'a -> bool 2 | 3 | val ( <> ) : 'a -> 'a -> bool 4 | 5 | val not : bool -> bool -------------------------------------------------------------------------------- /test/emptyFileComment.t/run.t: -------------------------------------------------------------------------------- 1 | Format empty file comment 2 | $ refmt ./input.re 3 | // file with just a single line comment 4 | -------------------------------------------------------------------------------- /test/singleLineCommentEof.t/run.t: -------------------------------------------------------------------------------- 1 | Format single line comment at the end of the file 2 | $ refmt ./input.re 3 | // let x = 1 4 | -------------------------------------------------------------------------------- /esy.lock/.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Set eol to LF so files aren't converted to CRLF-eol on Windows. 3 | * text eol=lf linguist-generated 4 | -------------------------------------------------------------------------------- /dune: -------------------------------------------------------------------------------- 1 | (dirs :standard \ node_modules js) 2 | 3 | ; (install 4 | ; (package reason) 5 | ; (section bin) 6 | ; (files src/refmt/refmt.bc)) 7 | -------------------------------------------------------------------------------- /rtop.esy.lock/.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Set eol to LF so files aren't converted to CRLF-eol on Windows. 3 | * text eol=lf linguist-generated 4 | -------------------------------------------------------------------------------- /src/menhir-recover/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name menhir_recover) 3 | (flags :standard -open StdLabels) 4 | (libraries fix menhirLib menhirSdk)) 5 | -------------------------------------------------------------------------------- /.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | src/vendored-omp/** 2 | src/reason-parser/vendor/** 3 | test/**.cppo.ml 4 | src/**.cppo.ml 5 | src/**.cppo.mli 6 | rtop/**.cppo.ml 7 | -------------------------------------------------------------------------------- /src/menhir-error-processor/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name menhir_error_processor) 3 | (flags :standard -open StdLabels) 4 | (libraries unix menhirSdk)) 5 | -------------------------------------------------------------------------------- /src/refmt/git_commit.mli: -------------------------------------------------------------------------------- 1 | (* Interface file to ensure git_commit is generated properly with dune *) 2 | 3 | val version : string 4 | val short_version : string 5 | -------------------------------------------------------------------------------- /test/4.08/dune: -------------------------------------------------------------------------------- 1 | (cram 2 | (enabled_if 3 | (or 4 | (= %{ocaml_version} 4.08.0) 5 | (= %{ocaml_version} 4.08.1) 6 | (= %{ocaml_version} 4.08.2)))) 7 | -------------------------------------------------------------------------------- /test/backportSyntax.t/run.t: -------------------------------------------------------------------------------- 1 | $ refmt ./input.re --print binary > ./output.bin 2 | 3 | $ ocamlc -impl ./output.bin -o ./out 4 | 5 | $ ./out 6 | Success 7 | -------------------------------------------------------------------------------- /test/arityConversion.t/arity.txt: -------------------------------------------------------------------------------- 1 | And 2 | TupleConstructor 3 | Or 4 | M.TupleConstructorInModule 5 | TupleConstructor2 6 | .TupleConstructor3 7 | M.TupleConstructor3 8 | -------------------------------------------------------------------------------- /test/version.t: -------------------------------------------------------------------------------- 1 | Ensures refmt --version prints the right version 2 | $ refmt --version | cut -d '@' -f 1 | cut -d '-' -f 1 | awk '{$1=$1;print}' 3 | Reason 3.17.2 4 | -------------------------------------------------------------------------------- /test/mlFunctions.t/input.ml: -------------------------------------------------------------------------------- 1 | (* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. *) 2 | 3 | let x = 4 | ignore (fun y -> 5 | let y = 4 in 6 | y) 7 | 8 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/seq.base/files/META.seq: -------------------------------------------------------------------------------- 1 | name="seq" 2 | version="[distributed with OCaml 4.07 or above]" 3 | description="dummy backward-compatibility package for iterators" 4 | requires="" 5 | -------------------------------------------------------------------------------- /esy.lock/opam/base-unix.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "https://github.com/ocaml/opam-repository/issues" 3 | description: """ 4 | Unix library distributed with the OCaml compiler 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /esy.lock/opam/base-threads.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "https://github.com/ocaml/opam-repository/issues" 3 | description: """ 4 | Threads library distributed with the OCaml compiler 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/base-unix.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "https://github.com/ocaml/opam-repository/issues" 3 | description: """ 4 | Unix library distributed with the OCaml compiler 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/base-threads.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "https://github.com/ocaml/opam-repository/issues" 3 | description: """ 4 | Threads library distributed with the OCaml compiler 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /src/reason-parser/reason_declarative_lexer.mli: -------------------------------------------------------------------------------- 1 | type state 2 | 3 | val keyword_table : (string, Reason_parser.token) Hashtbl.t 4 | val make : unit -> state 5 | val token : state -> Lexing.lexbuf -> Reason_parser.token 6 | -------------------------------------------------------------------------------- /src/reason-parser/reason_parser_explain.mli: -------------------------------------------------------------------------------- 1 | (* See the comments in menhir_error_processor.ml *) 2 | 3 | val message : 4 | 'a Reason_parser.MenhirInterpreter.env 5 | -> Reason_parser.token * 'b * 'c 6 | -> string 7 | -------------------------------------------------------------------------------- /src/reason-merlin/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name ocamlmerlin_reason) 3 | (public_name ocamlmerlin-reason) 4 | (package reason) 5 | (flags :standard -open StdLabels) 6 | (libraries compiler-libs.common merlin-extend reason)) 7 | -------------------------------------------------------------------------------- /src/reason-parser/error-handling.md: -------------------------------------------------------------------------------- 1 | Categories of error: 2 | 3 | - Lexer errors, produced by `Reason_lexer` and stored in exception 4 | `Reason_lexer.Error` 5 | - Concrete parsing errors, produced by menhir code when 6 | 7 | -------------------------------------------------------------------------------- /src/vendored-omp/src/stdlib0.ml: -------------------------------------------------------------------------------- 1 | module Int = struct 2 | let to_string = string_of_int 3 | end 4 | 5 | module Option = struct 6 | let map f o = 7 | match o with 8 | | None -> None 9 | | Some v -> Some (f v) 10 | end 11 | -------------------------------------------------------------------------------- /test/4.06/error-syntaxError.t: -------------------------------------------------------------------------------- 1 | Force error for try catch 2 | $ cat >input.re < try (bad); 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 9-10: 8 | Error: Syntax error 9 | [1] 10 | -------------------------------------------------------------------------------- /test/trailingSpaces.t/input.re: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 2 | 3 | module M = Something.Create { 4 | type resource1 = MyModule.MySubmodule.t; 5 | type resource2 = MyModule.MySubmodule.t; 6 | }; 7 | -------------------------------------------------------------------------------- /src/refmt/package.ml: -------------------------------------------------------------------------------- 1 | let version = 2 | match Build_info.V1.version () with 3 | | None -> "n/a" 4 | | Some v -> Build_info.V1.Version.to_string v 5 | 6 | let git_version = Git_commit.version 7 | let git_short_version = Git_commit.short_version 8 | -------------------------------------------------------------------------------- /src/reason-parser/vendor/easy_format/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name reason_easy_format) 3 | (public_name reason.easy_format) 4 | (preprocess 5 | (action 6 | (run %{bin:cppo} -V OCAML:%{ocaml_version} %{input-file}))) 7 | (flags 8 | (:standard -w -9-27-32-50))) 9 | -------------------------------------------------------------------------------- /test/4.06/error-comments.t: -------------------------------------------------------------------------------- 1 | Format ./input.re 2 | $ cat >input.re < /* this is an unterminated comment 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 0-2: 8 | Error: Comment not terminated 9 | [1] 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | .DS_Store 3 | *.log 4 | 5 | # gitignored, but not npmignored. Published by `npm run prepublish` 6 | refmt.js 7 | refmt.map 8 | 9 | # Esy 10 | _esy 11 | _esybuild 12 | _esyinstall 13 | _release 14 | _export/ 15 | 16 | # opam 17 | _opam/ 18 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/base-bytes.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: " " 3 | authors: " " 4 | homepage: " " 5 | depends: [ 6 | "ocaml" {>= "4.02.0"} 7 | "ocamlfind" {>= "1.5.3"} 8 | ] 9 | synopsis: "Bytes library distributed with the OCaml compiler" 10 | -------------------------------------------------------------------------------- /src/refmt/end_of_line.mli: -------------------------------------------------------------------------------- 1 | type t = 2 | | LF 3 | | CRLF 4 | 5 | module Detect : sig 6 | val default : t 7 | val get_eol_for_file : string -> t 8 | end 9 | 10 | module Convert : sig 11 | val get_formatter : out_channel -> t -> Format.formatter 12 | end 13 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated. 4 | -------------------------------------------------------------------------------- /esy.lock/opam/base-bytes.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: " " 3 | authors: " " 4 | homepage: " " 5 | depends: [ 6 | "ocaml" {>= "4.02.0"} 7 | "ocamlfind" {>= "1.5.3"} 8 | ] 9 | synopsis: "Bytes library distributed with the OCaml compiler" 10 | x-maintained: true 11 | -------------------------------------------------------------------------------- /test/testUtils.t/input.re: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 2 | 3 | let printSection(s) { 4 | print_string("\n"); 5 | print_string(s); 6 | print_string("\n---------------------\n"); 7 | }; 8 | 9 | let printLn(s) = print_string(s ++ "\n"); 10 | -------------------------------------------------------------------------------- /test/4.08/error-syntaxError.t: -------------------------------------------------------------------------------- 1 | Force error for type ./input.re 2 | $ cat >input.re < try (bad); 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 9-10: 8 | 1 | try (bad); 9 | ^ 10 | Error: Syntax error 11 | 12 | [1] 13 | -------------------------------------------------------------------------------- /test/inlineRecord.t/input.re: -------------------------------------------------------------------------------- 1 | type t0 = T0 { t0 : int }; 2 | type t1 = 3 | | A { x : int } 4 | | B 5 | | C { c1 : string, c2 : string }; 6 | 7 | /* GADT */ 8 | type t2(_) = 9 | | D { x : int } : t2(int) 10 | | E { f : int => int } : t2(int => int) 11 | | F(unit) : t2(unit); 12 | -------------------------------------------------------------------------------- /test/4.06/error-lowercase_module.t: -------------------------------------------------------------------------------- 1 | Print error for lowercase module 2 | $ cat >input.re < module lowercase = {}; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 7-16: 8 | Error: Module names must start with an uppercase letter. 9 | [1] 10 | -------------------------------------------------------------------------------- /test/keyword-operators.t/input.re: -------------------------------------------------------------------------------- 1 | /* Keyword operators in parentheses should not be escaped with \# */ 2 | let (mod) = mod_float; 3 | let (land) = (land); 4 | let (lor) = (lor); 5 | let (lsl) = (lsl); 6 | let (lsr) = (lsr); 7 | let (lxor) = (lxor); 8 | let (asr) = (asr); 9 | let (or) = (||); 10 | -------------------------------------------------------------------------------- /test/lib/fdLeak.ml: -------------------------------------------------------------------------------- 1 | open Refmt_lib 2 | 3 | let () = 4 | let files = List.init ~len:25 ~f:(fun i -> i) in 5 | let input_file = "./input.re" in 6 | List.iter 7 | ~f:(fun _file -> End_of_line.Detect.get_eol_for_file input_file |> ignore) 8 | files; 9 | Format.eprintf "EOL: done@." 10 | -------------------------------------------------------------------------------- /test/4.10/local-openings.t/input.ml: -------------------------------------------------------------------------------- 1 | module Foo = struct 2 | type t = { name: string } 3 | end 4 | 5 | let foo Foo.{name} = () 6 | 7 | let f = function 8 | | Foo.{name} -> () 9 | | _ -> () 10 | 11 | let x = { Foo.name = "Reason" } 12 | let Foo.{name} = x 13 | 14 | let Foo.{name}, _ = x, () 15 | -------------------------------------------------------------------------------- /test/4.12/local-openings.t/input.ml: -------------------------------------------------------------------------------- 1 | module Foo = struct 2 | type t = { name: string } 3 | end 4 | 5 | let foo Foo.{name} = () 6 | 7 | let f = function 8 | | Foo.{name} -> () 9 | | _ -> () 10 | 11 | let x = { Foo.name = "Reason" } 12 | let Foo.{name} = x 13 | 14 | let Foo.{name}, _ = x, () 15 | -------------------------------------------------------------------------------- /src/reason-parser/reason_config.mli: -------------------------------------------------------------------------------- 1 | (** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is 2 | licensed under the MIT license found in the * LICENSE file in the root 3 | directory of this source tree. *) 4 | 5 | val recoverable : bool ref 6 | val configure : recoverable:bool -> unit 7 | -------------------------------------------------------------------------------- /test/4.06/error-lowercase_module_rec.t: -------------------------------------------------------------------------------- 1 | Print error for lowercase module 2 | $ cat >input.re < module rec lowercase = {}; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 11-20: 8 | Error: Module names must start with an uppercase letter. 9 | [1] 10 | -------------------------------------------------------------------------------- /src/reason-parser/reason_config.ml: -------------------------------------------------------------------------------- 1 | (** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is 2 | licensed under the MIT license found in the * LICENSE file in the root 3 | directory of this source tree. *) 4 | 5 | let recoverable = ref false 6 | let configure ~recoverable:r = recoverable := r 7 | -------------------------------------------------------------------------------- /src/menhir-recover/cost.mli: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | val zero : t 4 | val infinite : t 5 | val compare : t -> t -> int 6 | val add : t -> t -> t 7 | val of_int : int -> t 8 | val to_int : t -> int 9 | val is_infinite : t -> bool 10 | val arg_min : ('a -> t) -> 'a -> 'a -> 'a 11 | val pp : Format.formatter -> t -> unit 12 | -------------------------------------------------------------------------------- /test/trailingSpaces.t/run.t: -------------------------------------------------------------------------------- 1 | Format trailing spaces 2 | $ refmt ./input.re 3 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 4 | 5 | module M = 6 | Something.Create({ 7 | type resource1 = MyModule.MySubmodule.t; 8 | type resource2 = MyModule.MySubmodule.t; 9 | }); 10 | -------------------------------------------------------------------------------- /test/4.08/error-comments.t: -------------------------------------------------------------------------------- 1 | Format ./input.re 2 | $ cat >input.re < /* this is an unterminated comment 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 0-2: 8 | 1 | /* this is an unterminated comment 9 | ^^ 10 | Error: Comment not terminated 11 | 12 | [1] 13 | -------------------------------------------------------------------------------- /esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < winpatch.patch' : 'true' }" 7 | ], 8 | "ocaml pkg/git.ml", 9 | "ocaml pkg/build.ml native=true native-dynlink=true" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /js/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name refmt) 3 | (modes js) 4 | (js_of_ocaml 5 | (flags 6 | --source-map 7 | --debug-info 8 | --pretty 9 | --linkall 10 | +weak.js 11 | +toplevel.js 12 | --opt 13 | 3 14 | --disable 15 | strict)) 16 | (flags :standard -open StdLabels) 17 | (libraries reason js_of_ocaml)) 18 | -------------------------------------------------------------------------------- /rtop.esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < winpatch.patch' : 'true' }" 7 | ], 8 | "ocaml pkg/git.ml", 9 | "ocaml pkg/build.ml native=true native-dynlink=true" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/4.06/error-reservedField.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < let x = {< type >}; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 11-15: 8 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 9 | [1] 10 | -------------------------------------------------------------------------------- /test/inlineRecord.t/run.t: -------------------------------------------------------------------------------- 1 | See the typed tree from ./input.re 2 | $ cat ./input.re | ../lib/outcometreePrinter.exe 3 | type t0 = T0({ t0: int, }); 4 | type t1 = A({ x: int, }) | B | C({ c1: string, c2: string, }); 5 | type t2(_) = 6 | D({ x: int, }): t2(int) 7 | | E({ f: int => int, }): t2(int => int) 8 | | F(unit): t2(unit); 9 | -------------------------------------------------------------------------------- /src/menhir-recover/emitter.mli: -------------------------------------------------------------------------------- 1 | open MenhirSdk.Cmly_api 2 | open Attributes 3 | open Synthesis 4 | open Recovery_intf 5 | 6 | module Make 7 | (G : GRAMMAR) 8 | (_ : ATTRIBUTES with module G := G) 9 | (_ : SYNTHESIZER with module G := G) 10 | (_ : RECOVERY with module G := G) : sig 11 | val emit : Format.formatter -> unit 12 | end 13 | -------------------------------------------------------------------------------- /test/4.06/error-reservedRecordTypePunned.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < type x = { type }; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 11-15: 8 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 9 | [1] 10 | -------------------------------------------------------------------------------- /test/4.12/dune: -------------------------------------------------------------------------------- 1 | ; Disable these tests in windows since their output don't match, and we 2 | ; want to ensure the output works in other systems 3 | 4 | (cram 5 | (enabled_if 6 | (and 7 | (or 8 | (= %{system} "macosx") 9 | (= %{system} "linux")) 10 | (or 11 | (= %{ocaml_version} 4.12.0) 12 | (= %{ocaml_version} 4.12.1))))) 13 | -------------------------------------------------------------------------------- /test/fixme.t/input.re: -------------------------------------------------------------------------------- 1 | /** 2 | * Problem: In thise example, the comment should have a space after it. 3 | */ 4 | let store_attributes(proc_attributes) { 5 | let should_write = 6 | /* only overwrite defined procedures */proc_attributes.ProcAttributes.is_defined || 7 | not (DB.file_exists(attributes_file)); 8 | should_write; 9 | }; 10 | -------------------------------------------------------------------------------- /test/4.06/error-reservedRecordPunned.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < let foo = { ...other, type }; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 22-26: 8 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 9 | [1] 10 | -------------------------------------------------------------------------------- /test/testUtils.t/run.t: -------------------------------------------------------------------------------- 1 | Format test utils 2 | $ refmt ./input.re 3 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 4 | 5 | let printSection = s => { 6 | print_string("\n"); 7 | print_string(s); 8 | print_string("\n---------------------\n"); 9 | }; 10 | 11 | let printLn = s => print_string(s ++ "\n"); 12 | -------------------------------------------------------------------------------- /test/4.06/error-reservedRecord.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < let foo = { foo: "bar", type: "qux" }; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 24-28: 8 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 9 | [1] 10 | -------------------------------------------------------------------------------- /test/4.08/error-lowercase_module.t: -------------------------------------------------------------------------------- 1 | Print error for lowercase module 2 | $ cat >input.re < module lowercase = {}; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 7-16: 8 | 1 | module lowercase = {}; 9 | ^^^^^^^^^ 10 | Error: Module names must start with an uppercase letter. 11 | 12 | [1] 13 | -------------------------------------------------------------------------------- /test/sharpop.t/input.re: -------------------------------------------------------------------------------- 1 | foo#=bar[0]; 2 | 3 | foo##bar[0] = 3; 4 | 5 | foo##bar[0]##baz[1] = 3; 6 | 7 | foo##bar[0]##baz[1]; 8 | 9 | foo##bar#=bar[0]; 10 | 11 | foo##bar##baz #= bar##baz[0]; 12 | 13 | foo[bar + 1]; 14 | 15 | foo.[bar + 1]; 16 | 17 | foo.{bar + 1}; 18 | 19 | foo.[bar + 1] = 1; 20 | 21 | foo.{bar + 1} = 1; 22 | 23 | foo[bar + 1] = 1; 24 | -------------------------------------------------------------------------------- /test/4.06/error-reservedRecordType.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < type x = { type: string }; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 11-15: 8 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 9 | [1] 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/4.08/error-lowercase_module_rec.t: -------------------------------------------------------------------------------- 1 | Print error for lowercase module 2 | $ cat >input.re < module rec lowercase = {}; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 11-20: 8 | 1 | module rec lowercase = {}; 9 | ^^^^^^^^^ 10 | Error: Module names must start with an uppercase letter. 11 | 12 | [1] 13 | -------------------------------------------------------------------------------- /test/dune: -------------------------------------------------------------------------------- 1 | (env 2 | (_ 3 | (env-vars 4 | (REFMT_PRINT_WIDTH 50)))) 5 | 6 | (cram 7 | (applies_to * \ lib rtopIntegration) 8 | (package reason) 9 | (deps 10 | %{bin:ocamlc} 11 | %{bin:refmt} 12 | ./lib/outcometreePrinter.exe 13 | ./lib/fdLeak.exe)) 14 | 15 | (cram 16 | (applies_to rtopIntegration) 17 | (package rtop) 18 | (deps %{bin:ocamlc} %{bin:rtop})) 19 | -------------------------------------------------------------------------------- /src/vendored-omp/src/compiler-functions/lt_406.ml: -------------------------------------------------------------------------------- 1 | let error_of_exn = Location.error_of_exn 2 | 3 | let get_load_paths () = 4 | !Config.load_path 5 | 6 | let load_path_init l = 7 | Config.load_path := l 8 | 9 | let get_unboxed_types () = 10 | false 11 | 12 | let set_unboxed_types _b = 13 | () 14 | 15 | let may_map = Misc.may_map 16 | 17 | let bad_docstring t = Warnings.Bad_docstring t 18 | -------------------------------------------------------------------------------- /test/4.08/error-reservedField.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < let x = {< type >}; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 11-15: 8 | 1 | let x = {< type >}; 9 | ^^^^ 10 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 11 | 12 | [1] 13 | -------------------------------------------------------------------------------- /test/keyword-operators.t/run.t: -------------------------------------------------------------------------------- 1 | Keyword operators in parentheses should not be escaped with \# 2 | $ refmt ./input.re 3 | /* Keyword operators in parentheses should not be escaped with \# */ 4 | let (mod) = mod_float; 5 | let (land) = (land); 6 | let (lor) = (lor); 7 | let (lsl) = (lsl); 8 | let (lsr) = (lsr); 9 | let (lxor) = (lxor); 10 | let (asr) = (asr); 11 | let (or) = (||); 12 | -------------------------------------------------------------------------------- /test/fixme.t/run.t: -------------------------------------------------------------------------------- 1 | Format fixme 2 | $ refmt ./input.re 3 | /** 4 | * Problem: In thise example, the comment should have a space after it. 5 | */ 6 | let store_attributes = proc_attributes => { 7 | let should_write = 8 | /* only overwrite defined procedures */ proc_attributes.ProcAttributes.is_defined 9 | || not(DB.file_exists(attributes_file)); 10 | should_write; 11 | }; 12 | -------------------------------------------------------------------------------- /src/reason-parser/reason_comment.mli: -------------------------------------------------------------------------------- 1 | type category = 2 | | EndOfLine 3 | | SingleLine 4 | | Regular 5 | 6 | type t = 7 | { location : Location.t 8 | ; category : category 9 | ; text : string 10 | } 11 | 12 | val category : t -> category 13 | val location : t -> Location.t 14 | val wrap : t -> string 15 | val make : location:Location.t -> category -> string -> t 16 | val isLineComment : t -> bool 17 | -------------------------------------------------------------------------------- /test/4.08/error-reservedRecordTypePunned.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < type x = { type }; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 11-15: 8 | 1 | type x = { type }; 9 | ^^^^ 10 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 11 | 12 | [1] 13 | -------------------------------------------------------------------------------- /test/attributes-rei.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.rei > ./formatted.rei 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf formatted.rei 6 | 7 | Format the formatted file back 8 | $ refmt --print re ./formatted.rei > ./formatted_back.rei 9 | 10 | Ensure idempotency: first format and second format are the same 11 | $ diff formatted.rei formatted_back.rei 12 | -------------------------------------------------------------------------------- /src/reason-parser/reason_recover_parser.mli: -------------------------------------------------------------------------------- 1 | type 'a parser 2 | 3 | val initial : 4 | (Lexing.position -> 'a Reason_parser.MenhirInterpreter.checkpoint) 5 | -> Lexing.position 6 | -> 'a parser 7 | 8 | type 'a step = 9 | | Intermediate of 'a parser 10 | | Success of 'a * Reason_lexer.invalid_docstrings 11 | | Error 12 | 13 | val step : 'a parser -> Reason_parser.token Reason_lexer.positioned -> 'a step 14 | -------------------------------------------------------------------------------- /test/mlVariants.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.ml > ./formatted.re 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 6 | 7 | Format the formatted file back 8 | $ refmt --print re ./formatted.re > ./formatted_back.re 9 | 10 | Ensure idempotency: first format and second format are the same 11 | $ diff formatted.re formatted_back.re 12 | -------------------------------------------------------------------------------- /test/4.10/dune: -------------------------------------------------------------------------------- 1 | ; Disable these tests in windows since their output don't match, and we 2 | ; want to ensure the output works in other systems 3 | 4 | (cram 5 | (enabled_if 6 | (and 7 | (or 8 | (= %{system} "macosx") 9 | (= %{system} "linux")) 10 | (or 11 | (= %{ocaml_version} 4.10.0) 12 | (= %{ocaml_version} 4.10.1) 13 | (= %{ocaml_version} 4.10.2) 14 | (= %{ocaml_version} 4.10.3))))) 15 | -------------------------------------------------------------------------------- /test/comments-ml.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.ml > ./formatted.re 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 6 | 7 | Format the formatted file back 8 | $ refmt --print re ./formatted.re > ./formatted_back.re 9 | 10 | Ensure idempotency: first format and second format are the same 11 | $ diff formatted.re formatted_back.re 12 | -------------------------------------------------------------------------------- /test/knownMlIssues.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.ml > ./formatted.re 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 6 | 7 | Format the formatted file back 8 | $ refmt --print re ./formatted.re > ./formatted_back.re 9 | 10 | Ensure idempotency: first format and second format are the same 11 | $ diff formatted.re formatted_back.re 12 | -------------------------------------------------------------------------------- /test/uchar-esc.t/input.re: -------------------------------------------------------------------------------- 1 | 2 | 3 | let x = "\u{1F42B}"; 4 | let y = "\u{0}"; 5 | let y = "\u{00}"; 6 | let y = "\u{000}"; 7 | let y = "\u{000000}"; 8 | let y = "\u{0000E9}"; 9 | let y = "\u{10FFFF}"; 10 | 11 | let x = "\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}"; 12 | let () = Format.eprintf ("x: %s@.", x); 13 | 14 | // in a comment 15 | /* "\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}" */ 16 | -------------------------------------------------------------------------------- /nix/shell.nix: -------------------------------------------------------------------------------- 1 | { mkShell 2 | , ocamlPackages 3 | , reason 4 | , cacert 5 | , curl 6 | , git 7 | , release-mode ? false 8 | }: 9 | 10 | mkShell { 11 | inputsFrom = [ reason ]; 12 | nativeBuildInputs = with ocamlPackages; [ 13 | utop 14 | merlin 15 | # odoc 16 | ocamlformat 17 | ]; 18 | buildInputs = 19 | with ocamlPackages; (if release-mode then [ cacert curl dune-release git ] else [ ]); 20 | } 21 | -------------------------------------------------------------------------------- /src/reason-parser/reason_parser_def.ml: -------------------------------------------------------------------------------- 1 | open Ppxlib 2 | 3 | type labelled_parameter = 4 | | Term of Asttypes.arg_label * Parsetree.expression option * Parsetree.pattern 5 | | Type of string 6 | 7 | type let_bindings = 8 | { lbs_bindings : Parsetree.value_binding list 9 | ; lbs_rec : Asttypes.rec_flag 10 | ; lbs_extension : (Parsetree.attributes * string Asttypes.loc) option 11 | ; lbs_loc : Location.t 12 | } 13 | -------------------------------------------------------------------------------- /src/reason-parser/reason_parser_def.mli: -------------------------------------------------------------------------------- 1 | open Ppxlib 2 | 3 | type labelled_parameter = 4 | | Term of Asttypes.arg_label * Parsetree.expression option * Parsetree.pattern 5 | | Type of string 6 | 7 | type let_bindings = 8 | { lbs_bindings : Parsetree.value_binding list 9 | ; lbs_rec : Asttypes.rec_flag 10 | ; lbs_extension : (Parsetree.attributes * string Asttypes.loc) option 11 | ; lbs_loc : Location.t 12 | } 13 | -------------------------------------------------------------------------------- /test/comments-mli.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.mli > ./formatted.rei 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -intf formatted.rei 6 | 7 | Format the formatted file back 8 | $ refmt --print re ./formatted.rei > ./formatted_back.rei 9 | 10 | Ensure idempotency: first format and second format are the same 11 | $ diff formatted.rei formatted_back.rei 12 | -------------------------------------------------------------------------------- /test/pervasive.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.mli > ./formatted.rei 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -intf formatted.rei 6 | 7 | Format the formatted file back 8 | $ refmt --print re ./formatted.rei > ./formatted_back.rei 9 | 10 | Ensure idempotency: first format and second format are the same 11 | $ diff formatted.rei formatted_back.rei 12 | -------------------------------------------------------------------------------- /test/extension-str-in-module.t: -------------------------------------------------------------------------------- 1 | Format extensions in modules 2 | 3 | $ refmt < [%%toplevelExtension "payload"]; 5 | > module X = { 6 | > /* No payload */ 7 | > [%%someExtension]; 8 | > [%%someExtension "payload"]; 9 | > }; 10 | > EOF 11 | [%%toplevelExtension "payload"]; 12 | module X = { 13 | /* No payload */ 14 | [%%someExtension]; 15 | [%%someExtension "payload"]; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /test/reasonComments-rei.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.rei > ./formatted.rei 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -intf formatted.rei 6 | 7 | Format the formatted file back 8 | $ refmt --print re ./formatted.rei > ./formatted_back.rei 9 | 10 | Ensure idempotency: first format and second format are the same 11 | $ diff formatted.rei formatted_back.rei 12 | -------------------------------------------------------------------------------- /test/4.08/error-reservedRecordType.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < type x = { type: string }; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 11-15: 8 | 1 | type x = { type: string }; 9 | ^^^^ 10 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 11 | 12 | [1] 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/4.08/error-reservedRecord.t: -------------------------------------------------------------------------------- 1 | Force error for type ./input.re 2 | $ cat >input.re < let foo = { foo: "bar", type: "qux" }; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 24-28: 8 | 1 | let foo = { foo: "bar", type: "qux" }; 9 | ^^^^ 10 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 11 | 12 | [1] 13 | -------------------------------------------------------------------------------- /test/4.08/error-reservedRecordPunned.t: -------------------------------------------------------------------------------- 1 | Print error for type reserved keyword 2 | $ cat >input.re < let foo = { ...other, type }; 4 | > EOF 5 | 6 | $ refmt ./input.re 7 | File "./input.re", line 1, characters 22-26: 8 | 1 | let foo = { ...other, type }; 9 | ^^^^ 10 | Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead 11 | 12 | [1] 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/arityConversion.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --heuristics-file ./arity.txt --print re ./input.ml > ./formatted.re 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 6 | 7 | Format the formatted file back 8 | $ refmt --print re ./formatted.re > ./formatted_back.re 9 | 10 | Ensure idempotency: first format and second format are the same 11 | $ diff formatted.re formatted_back.re 12 | -------------------------------------------------------------------------------- /test/sharpop.t/run.t: -------------------------------------------------------------------------------- 1 | Format sharp operator 2 | $ refmt ./input.re 3 | foo #= bar[0]; 4 | 5 | foo##bar[0] = 3; 6 | 7 | foo##bar[0]##baz[1] = 3; 8 | 9 | foo##bar[0]##baz[1]; 10 | 11 | foo##bar #= bar[0]; 12 | 13 | foo##bar##baz #= bar##baz[0]; 14 | 15 | foo[bar + 1]; 16 | 17 | foo.[bar + 1]; 18 | 19 | foo.{bar + 1}; 20 | 21 | foo.[bar + 1] = 1; 22 | 23 | foo.{bar + 1} = 1; 24 | 25 | foo[bar + 1] = 1; 26 | -------------------------------------------------------------------------------- /test/escapesInStrings.t/input.re: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 2 | 3 | /* 4 | let str = "@[.... some formatting ....@\n\010@."; 5 | */ 6 | 7 | let str = "@[.... some formatting ....@\n\010@."; 8 | let str = {abcd|@[.... some formatting ....@\n\010@.|abcd}; 9 | 10 | let utf8_string = "😁"; 11 | 12 | let keep_representation = "\n 13 | \t . this should be on a new line\ 14 | ^ this should be aligned with the . 15 | "; 16 | -------------------------------------------------------------------------------- /test/lib/dune: -------------------------------------------------------------------------------- 1 | (rule 2 | (targets outcometreePrinter.ml) 3 | (deps outcometreePrinter.cppo.ml) 4 | (action 5 | (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) 6 | 7 | (executable 8 | (name outcometreePrinter) 9 | (libraries reason) 10 | (flags :standard -open StdLabels) 11 | (modules outcometreePrinter)) 12 | 13 | (executable 14 | (name fdLeak) 15 | (modules fdLeak) 16 | (flags :standard -open StdLabels) 17 | (libraries reason.refmt-lib)) 18 | -------------------------------------------------------------------------------- /src/vendored-omp/tools/pp.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | match Sys.argv with 3 | | [|_; ocaml_version; fname|] -> 4 | let is_current = 5 | (Filename.basename fname = Printf.sprintf "ast_%s.ml" ocaml_version) 6 | in 7 | let ic = open_in_bin fname in 8 | Printf.printf "# 1 %S\n" fname; 9 | Pp_rewrite.rewrite is_current ocaml_version (Lexing.from_channel ic) 10 | | _ -> 11 | Printf.eprintf "%s: \n" 12 | Sys.executable_name; 13 | exit 2 14 | -------------------------------------------------------------------------------- /.github/workflows/print-esy-cache.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const os = require("os"); 3 | const path = require("path"); 4 | 5 | const ESY_FOLDER = process.env.ESY__PREFIX 6 | ? process.env.ESY__PREFIX 7 | : path.join(os.homedir(), ".esy"); 8 | 9 | const someEsy3 = fs 10 | .readdirSync(ESY_FOLDER) 11 | .filter((name) => name.length > 0 && name[0] === "3"); 12 | 13 | const esy3 = someEsy3 14 | .sort() 15 | .pop(); 16 | 17 | console.log(path.join(ESY_FOLDER, esy3, "i")); 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reason", 3 | "version": "3.6.2", 4 | "description": "Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/reasonml/reason.git" 8 | }, 9 | "main": "refmt.js", 10 | "keywords": [ 11 | "reason", 12 | "ocaml", 13 | "react", 14 | "javascript" 15 | ], 16 | "license": "MIT", 17 | "homepage": "https://github.com/reasonml/reason" 18 | } 19 | -------------------------------------------------------------------------------- /src/menhir-recover/cost.ml: -------------------------------------------------------------------------------- 1 | type t = int 2 | 3 | let zero = 0 4 | let infinite = max_int 5 | let compare : t -> t -> int = compare 6 | 7 | let add t1 t2 = 8 | let result = t1 + t2 in 9 | if result < 0 then infinite else result 10 | 11 | let of_int x = 12 | if x < 0 then invalid_arg "Cost.of_int: cost must be positive" else x 13 | 14 | let to_int x = x 15 | let is_infinite x = x = infinite 16 | let arg_min f a b = if compare (f a) (f b) <= 0 then a else b 17 | let pp = Format.pp_print_int 18 | -------------------------------------------------------------------------------- /esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override/files/winpatch.patch: -------------------------------------------------------------------------------- 1 | --- ./pkg/topkg.ml 2 | +++ ./pkg/topkg.ml 3 | @@ -344,7 +344,7 @@ 4 | let build ccomp btool bdir pkg mvs = 5 | let ext_to_string = Exts.ext_to_string ccomp in 6 | let install, exec = build_strings btool bdir ext_to_string mvs in 7 | - let e = Sys.command exec in 8 | + let e = Sys.command ("bash -c '" ^ exec ^ "'") in 9 | if e <> 0 then exit e else 10 | let install_file = pkg ^ ".install" in 11 | try 12 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/seq.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: " " 3 | authors: " " 4 | homepage: " " 5 | depends: [ 6 | "ocaml" {>= "4.07.0"} 7 | ] 8 | dev-repo: "git+https://github.com/ocaml/ocaml.git" 9 | bug-reports: "https://caml.inria.fr/mantis/main_page.php" 10 | synopsis: 11 | "Compatibility package for OCaml's standard iterator type starting from 4.07." 12 | extra-files: [ 13 | ["seq.install" "md5=026b31e1df290373198373d5aaa26e42"] 14 | ["META.seq" "md5=b33c8a1a6c7ed797816ce27df4855107"] 15 | ] 16 | -------------------------------------------------------------------------------- /rtop.esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override/files/winpatch.patch: -------------------------------------------------------------------------------- 1 | --- ./pkg/topkg.ml 2 | +++ ./pkg/topkg.ml 3 | @@ -344,7 +344,7 @@ 4 | let build ccomp btool bdir pkg mvs = 5 | let ext_to_string = Exts.ext_to_string ccomp in 6 | let install, exec = build_strings btool bdir ext_to_string mvs in 7 | - let e = Sys.command exec in 8 | + let e = Sys.command ("bash -c '" ^ exec ^ "'") in 9 | if e <> 0 then exit e else 10 | let install_file = pkg ^ ".install" in 11 | try 12 | -------------------------------------------------------------------------------- /rtop.esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/files/findlib.patch: -------------------------------------------------------------------------------- 1 | --- ./Makefile 2 | +++ ./Makefile 3 | @@ -55,7 +55,7 @@ 4 | export USE_CYGPATH; \ 5 | cat findlib.conf.in | \ 6 | $(SH) tools/patch '@SITELIB@' '$(OCAML_SITELIB)' | \ 7 | - $(SH) tools/patch '@FINDLIB_PATH@' '$(FINDLIB_PATH)' -p >findlib.conf 8 | + $(SH) tools/patch '@FINDLIB_PATH@' '$(FINDLIB_PATH)' >findlib.conf 9 | if ./tools/cmd_from_same_dir ocamlc; then \ 10 | echo 'ocamlc="ocamlc.opt"' >>findlib.conf; \ 11 | fi 12 | -------------------------------------------------------------------------------- /test/assert.t/input.re: -------------------------------------------------------------------------------- 1 | switch(true) { 2 | | true => () 3 | | false => assert(false) 4 | | _ => assert false 5 | }; 6 | 7 | let root = { 8 | let root = Doc.rootNode(doc); 9 | assert (root.type_ == "expression"); 10 | assert (Node.namedChildCount(root) == 1); 11 | assert (Node.childCount(root) == 1); 12 | assert (Point.toString(root.startPoint) == "(Point.t {:row 0 :column 0})"); 13 | assert (Point.toString(root.endPoint) == "(Point.t {:row 0 :column 9})"); 14 | root; 15 | }; 16 | 17 | assert(theTruth()); 18 | -------------------------------------------------------------------------------- /esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.8_opam_override/files/findlib.patch: -------------------------------------------------------------------------------- 1 | --- ./Makefile 2 | +++ ./Makefile 3 | @@ -56,7 +56,7 @@ 4 | export USE_CYGPATH; \ 5 | cat findlib.conf.in | \ 6 | $(SH) tools/patch '@SITELIB@' '$(FINDLIB_OCAML_SITELIB)' | \ 7 | - $(SH) tools/patch '@FINDLIB_PATH@' '$(FINDLIB_PATH)' -p >findlib.conf 8 | + $(SH) tools/patch '@FINDLIB_PATH@' '$(FINDLIB_PATH)' >findlib.conf 9 | if ./tools/cmd_from_same_dir ocamlc; then \ 10 | echo 'ocamlc="ocamlc.opt"' >>findlib.conf; \ 11 | fi 12 | -------------------------------------------------------------------------------- /test/escapesInStrings.t/run.t: -------------------------------------------------------------------------------- 1 | Format escapes in strings 2 | $ refmt ./input.re 3 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 4 | 5 | /* 6 | let str = "@[.... some formatting ....@\n\010@."; 7 | */ 8 | 9 | let str = "@[.... some formatting ....@\n\010@."; 10 | let str = {abcd|@[.... some formatting ....@\n\010@.|abcd}; 11 | 12 | let utf8_string = "😁"; 13 | 14 | let keep_representation = "\n 15 | \t . this should be on a new line\ 16 | ^ this should be aligned with the . 17 | "; 18 | -------------------------------------------------------------------------------- /src/vendored-omp/tools/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name add_special_comments) 3 | (modules add_special_comments) 4 | (libraries compiler-libs.common compiler-libs.bytecomp) 5 | (enabled_if 6 | (>= %{ocaml_version} 4.13))) 7 | 8 | (executable 9 | (name pp) 10 | (modules pp pp_rewrite) 11 | (libraries compiler-libs.common compiler-libs.bytecomp)) 12 | 13 | (ocamllex pp_rewrite) 14 | 15 | (executable 16 | (name gencopy) 17 | (enabled_if 18 | (>= %{ocaml_version} 5.4)) 19 | (modules gencopy) 20 | (libraries compiler-libs.common compiler-libs.bytecomp)) 21 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/ocamlfind.1.9.6/files/0001-Harden-test-for-OCaml-5.patch: -------------------------------------------------------------------------------- 1 | diff a/configure b/configure 2 | --- a/configure 3 | +++ b/configure 4 | @@ -294,7 +294,7 @@ 5 | # If findlib has been configured -sitelib $(ocamlc -where) then there's 6 | # nothing to do, but otherwise we need to put OCaml's Standard Library 7 | # into the path setting. 8 | - if [ ! -e "${ocaml_sitelib}/stdlib/META" ]; then 9 | + if [ ! -e "${ocaml_sitelib}/stdlib.cmi" ]; then 10 | ocamlpath="${ocaml_core_stdlib}${path_sep}${ocamlpath}" 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /src/vendored-omp/src/compiler-functions/ge_410_and_lt_412.ml: -------------------------------------------------------------------------------- 1 | let error_of_exn exn = 2 | match Location.error_of_exn exn with 3 | | Some (`Ok exn) -> Some exn 4 | | Some `Already_displayed -> None 5 | | None -> None 6 | 7 | let get_load_paths () = 8 | Load_path.get_paths () 9 | 10 | let load_path_init l = 11 | Load_path.init l 12 | 13 | let get_unboxed_types () = 14 | !Clflags.unboxed_types 15 | 16 | let set_unboxed_types b = 17 | Clflags.unboxed_types := b 18 | 19 | let may_map = Option.map 20 | 21 | let bad_docstring t = Warnings.Bad_docstring t 22 | -------------------------------------------------------------------------------- /src/vendored-omp/src/compiler-functions/ge_412.ml: -------------------------------------------------------------------------------- 1 | let error_of_exn exn = 2 | match Location.error_of_exn exn with 3 | | Some (`Ok exn) -> Some exn 4 | | Some `Already_displayed -> None 5 | | None -> None 6 | 7 | let get_load_paths () = 8 | Load_path.get_paths () 9 | 10 | let load_path_init l = 11 | Load_path.init l 12 | 13 | let get_unboxed_types () = 14 | !Clflags.unboxed_types 15 | 16 | let set_unboxed_types b = 17 | Clflags.unboxed_types := b 18 | 19 | let may_map = Option.map 20 | 21 | let bad_docstring t = Warnings.Unexpected_docstring t 22 | -------------------------------------------------------------------------------- /test/4.10/local-openings.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.ml > ./formatted.re 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 6 | File "formatted.re", line 10, characters 2-5: 7 | 10 | | _ => (); 8 | ^^^ 9 | Warning 11: this match case is unused. 10 | 11 | Format the formatted file back 12 | $ refmt --print re ./formatted.re > ./formatted_back.re 13 | 14 | Ensure idempotency: first format and second format are the same 15 | $ diff formatted.re formatted_back.re 16 | -------------------------------------------------------------------------------- /src/vendored-omp/src/compiler-functions/ge_406_and_lt_408.ml: -------------------------------------------------------------------------------- 1 | let error_of_exn exn = 2 | match Location.error_of_exn exn with 3 | | Some (`Ok exn) -> Some exn 4 | | Some `Already_displayed -> None 5 | | None -> None 6 | 7 | let get_load_paths () = 8 | !Config.load_path 9 | 10 | let load_path_init l = 11 | Config.load_path := l 12 | 13 | let get_unboxed_types () = 14 | !Clflags.unboxed_types 15 | 16 | let set_unboxed_types b = 17 | Clflags.unboxed_types := b 18 | 19 | let may_map = Misc.may_map 20 | 21 | let bad_docstring t = Warnings.Bad_docstring t 22 | -------------------------------------------------------------------------------- /src/vendored-omp/src/compiler-functions/ge_408_and_lt_410.ml: -------------------------------------------------------------------------------- 1 | let error_of_exn exn = 2 | match Location.error_of_exn exn with 3 | | Some (`Ok exn) -> Some exn 4 | | Some `Already_displayed -> None 5 | | None -> None 6 | 7 | let get_load_paths () = 8 | Load_path.get_paths () 9 | 10 | let load_path_init l = 11 | Load_path.init l 12 | 13 | let get_unboxed_types () = 14 | !Clflags.unboxed_types 15 | 16 | let set_unboxed_types b = 17 | Clflags.unboxed_types := b 18 | 19 | let may_map = Misc.may_map 20 | 21 | let bad_docstring t = Warnings.Bad_docstring t 22 | -------------------------------------------------------------------------------- /test/4.12/local-openings.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.ml > ./formatted.re 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 6 | File "formatted.re", line 10, characters 2-5: 7 | 10 | | _ => (); 8 | ^^^ 9 | Warning 11 [redundant-case]: this match case is unused. 10 | 11 | Format the formatted file back 12 | $ refmt --print re ./formatted.re > ./formatted_back.re 13 | 14 | Ensure idempotency: first format and second format are the same 15 | $ diff formatted.re formatted_back.re 16 | -------------------------------------------------------------------------------- /rtop.esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.2+win_opam_override/files/winpatch.patch: -------------------------------------------------------------------------------- 1 | --- ./Makefile 2 | +++ ./Makefile 3 | @@ -271,7 +271,7 @@ 4 | echo ' "ocamlbuild.byte" {"ocamlbuild.byte"}' >> ocamlbuild.install 5 | ifeq ($(OCAML_NATIVE), true) 6 | echo ' "ocamlbuild.native" {"ocamlbuild.native"}' >> ocamlbuild.install 7 | - echo ' "ocamlbuild.native" {"ocamlbuild"}' >> ocamlbuild.install 8 | + echo " \"ocamlbuild.native\" {\"ocamlbuild${EXE}\"}" >> ocamlbuild.install 9 | else 10 | echo ' "ocamlbuild.byte" {"ocamlbuild"}' >> ocamlbuild.install 11 | endif 12 | -------------------------------------------------------------------------------- /src/reason-parser/reason_heuristics.mli: -------------------------------------------------------------------------------- 1 | open Ppxlib 2 | 3 | val is_punned_labelled_expression : expression -> string -> bool 4 | val isUnderscoreIdent : expression -> bool 5 | val isUnderscoreApplication : expression -> bool 6 | val melExprCanBeUncurried : expression -> bool 7 | val isPipeFirst : expression -> bool 8 | val isPipeFirstWithNonSimpleJSXChild : expression -> bool 9 | val singleTokenPatternOmmitTrail : string -> bool 10 | 11 | val funAppCallbackExceedsWidth : 12 | printWidth:int 13 | -> args:(arg_label * expression) list 14 | -> funExpr:expression 15 | -> unit 16 | -> bool 17 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/trie.1.0.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "zandoye@gmail.com" 3 | authors: [ "ZAN DoYe" ] 4 | homepage: "https://github.com/kandu/trie/" 5 | bug-reports: "https://github.com/kandu/trie/issues" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/kandu/trie.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" {>= "4.02"} 13 | "dune" {>= "1.0"} 14 | ] 15 | synopsis: "Strict impure trie tree" 16 | url { 17 | src: "https://github.com/kandu/trie/archive/1.0.0.tar.gz" 18 | checksum: "md5=84519b5f8bd92490bfc68a52f706ba14" 19 | } 20 | -------------------------------------------------------------------------------- /test/class_types.t/input.re: -------------------------------------------------------------------------------- 1 | class type _module ('provider_impl) = { 2 | 3 | }; 4 | type t; 5 | class type bzz = { 6 | inherit _module(t) 7 | }; 8 | 9 | class type t = { as 'a; 10 | constraint 'a = #s 11 | }; 12 | 13 | /* https://github.com/facebook/reason/issues/2037 */ 14 | class type xt = { as 'a }; 15 | 16 | class x = { 17 | as self 18 | }; 19 | 20 | class type classWithNoArgType { 21 | pub x : int; 22 | pub y : int 23 | }; 24 | 25 | class classWithNoArg { 26 | pub x = 0; 27 | pub y = 0 28 | }; 29 | 30 | class type t = { 31 | open M; 32 | as 'a; 33 | }; 34 | 35 | class type t = { 36 | open M; 37 | }; 38 | -------------------------------------------------------------------------------- /test/comments-mli.t/input.mli: -------------------------------------------------------------------------------- 1 | (* **** comment *) 2 | (*** comment *) 3 | (** docstring *) 4 | (* comment *) 5 | (** docstring *) 6 | (*** comment *) 7 | (**** comment *) 8 | (***** comment *) 9 | 10 | (** *) 11 | (*** *) 12 | (**** *) 13 | 14 | (***) 15 | (****) 16 | 17 | 18 | 19 | (** (** comment *) *) 20 | (** (*** comment *) *) 21 | 22 | (* (** comment *) *) 23 | (* (*** comment *) *) 24 | (* *(*** comment *) *) 25 | 26 | (* comment **) 27 | (* comment ***) 28 | (* comment ****) 29 | (* comment *****) 30 | 31 | (** 32 | * Multiline 33 | *) 34 | 35 | (** Multiline 36 | * 37 | *) 38 | 39 | (** 40 | ** 41 | *) 42 | -------------------------------------------------------------------------------- /src/reason-parser/reason_location.mli: -------------------------------------------------------------------------------- 1 | module Range : sig 2 | type t = 3 | { lnum_start : int 4 | ; lnum_end : int 5 | } 6 | (** [t] represents an interval, including endpoints, * delimited by two 7 | linenumbers. *) 8 | 9 | val makeRangeBetween : Location.t -> Location.t -> t 10 | val containsLoc : t -> Warnings.loc -> bool 11 | 12 | val containsWhitespace : 13 | ?comments:Reason_comment.t list 14 | -> range:t 15 | -> unit 16 | -> bool 17 | end 18 | 19 | val hasSpaceBetween : Location.t -> Location.t -> bool 20 | (** compute if there's space (one or more line) between [loc1] and [loc2] *) 21 | -------------------------------------------------------------------------------- /test/mlFunctions.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | 3 | $ refmt ./input.ml | tee formatted.re 4 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 5 | 6 | let x = 7 | ignore(y => { 8 | let y = 4; 9 | y; 10 | }); 11 | 12 | Format the formatted file back 13 | $ refmt ./formatted.re | tee formatted_back.re 14 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 15 | 16 | let x = 17 | ignore(y => { 18 | let y = 4; 19 | y; 20 | }); 21 | 22 | Ensure idempotency: first format and second format are the same 23 | $ diff formatted.re formatted_back.re 24 | -------------------------------------------------------------------------------- /rtop.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@esy-ocaml/rtop", 3 | "version": "3.8.2", 4 | "license": "MIT", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/reasonml/reason.git" 8 | }, 9 | "dependencies": { 10 | "@esy-ocaml/substs": "^0.0.1", 11 | "@opam/ocamlfind": "*", 12 | "@opam/dune": ">= 2.9.3", 13 | "@opam/reason": "^3.8.0", 14 | "@opam/utop": " >= 1.17.0", 15 | "ocaml": ">= 4.3.0 < 5.2.0" 16 | }, 17 | "devDependencies": { 18 | "@opam/merlin": "*", 19 | "ocaml": "5.x" 20 | }, 21 | "esy": { 22 | "build": [["dune", "build", "-p", "reason", "--disable-promotion"]] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/backportSyntax.t/input.re: -------------------------------------------------------------------------------- 1 | 2 | let (let.opt) = (x, f) => switch x { | None => None | Some(x) => f(x) }; 3 | let (let.&opt) = (x, f) => switch x { | None => None | Some(x) => Some(f(x)) }; 4 | let (and.opt) = (a, b) => switch (a, b) { | (Some(a), Some(b)) => Some((a, b)) | _ => None }; 5 | 6 | let x = { 7 | let.opt a = Some(1); 8 | let.opt b = Some(2) 9 | and.opt c = Some(3) 10 | and.opt d = Some(4); 11 | Some((a, b, c, d)) 12 | } 13 | let y = { 14 | let.opt a = Some(1) 15 | and.opt b = None 16 | and.opt c = Some(4); 17 | Some((a, b, c)) 18 | } 19 | assert(x == Some((1,2,3,4))); 20 | assert(y == None); 21 | print_endline("Success") 22 | -------------------------------------------------------------------------------- /test/assert.t/run.t: -------------------------------------------------------------------------------- 1 | Format assertions 2 | $ refmt ./input.re 3 | switch (true) { 4 | | true => () 5 | | false => assert(false) 6 | | _ => assert(false) 7 | }; 8 | 9 | let root = { 10 | let root = Doc.rootNode(doc); 11 | assert(root.type_ == "expression"); 12 | assert(Node.namedChildCount(root) == 1); 13 | assert(Node.childCount(root) == 1); 14 | assert( 15 | Point.toString(root.startPoint) 16 | == "(Point.t {:row 0 :column 0})", 17 | ); 18 | assert( 19 | Point.toString(root.endPoint) 20 | == "(Point.t {:row 0 :column 9})", 21 | ); 22 | root; 23 | }; 24 | 25 | assert(theTruth()); 26 | -------------------------------------------------------------------------------- /src/reason-parser/merlin_recovery_intf.ml: -------------------------------------------------------------------------------- 1 | module type RECOVERY = sig 2 | module Parser : MenhirLib.IncrementalEngine.EVERYTHING 3 | 4 | val default_value : Location.t -> 'a Parser.symbol -> 'a 5 | 6 | type action = 7 | | Abort 8 | | R of int 9 | | S : 'a Parser.symbol -> action 10 | | Sub of action list 11 | 12 | type decision = 13 | | Nothing 14 | | One of action list 15 | | Select of (int -> action list) 16 | 17 | val depth : int array 18 | val recover : int -> decision 19 | val guide : 'a Parser.symbol -> bool 20 | val token_of_terminal : 'a Parser.terminal -> 'a -> Parser.token 21 | val nullable : 'a Parser.nonterminal -> bool 22 | end 23 | -------------------------------------------------------------------------------- /esy.lock/opam/trie.1.0.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "zandoye@gmail.com" 3 | authors: [ "ZAN DoYe" ] 4 | homepage: "https://github.com/kandu/trie/" 5 | bug-reports: "https://github.com/kandu/trie/issues" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/kandu/trie.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" {>= "4.02"} 13 | "dune" {>= "1.0"} 14 | ] 15 | synopsis: "Strict impure trie tree" 16 | url { 17 | src: "https://github.com/kandu/trie/archive/1.0.0.tar.gz" 18 | checksum: [ 19 | "sha256=c2f8054ea44216e6a3a961b28f7630e0e3dbfbd1b504ae741be230cbe32498ea" 20 | "md5=84519b5f8bd92490bfc68a52f706ba14" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/jsx_functor.t/input.re: -------------------------------------------------------------------------------- 1 | type elt = Text(string) | Group(list(elt)); 2 | 3 | module X = { 4 | let createElement(~children=[], ()) { 5 | Text("x"); 6 | }; 7 | }; 8 | 9 | module Y = { 10 | let createElement(~children=[], ()) { 11 | Text("y"); 12 | }; 13 | }; 14 | 15 | module M(X: (module type of X), Y: (module type of Y)) = { 16 | let createElement(~name="M", ~id=0, ~children=[], ()) { 17 | Group([ 18 | Text(name), 19 | Text(string_of_int(id)), 20 | , 21 | 22 | ] @ children); 23 | }; 24 | }; 25 | 26 | let _ = Group([ 27 | , 28 | 29 | Text("A") 30 | , 31 | 32 | 33 | ]) 34 | -------------------------------------------------------------------------------- /test/knownReIssues.t/input.re: -------------------------------------------------------------------------------- 1 | /** 2 | Issue 940: https://github.com/facebook/reason/issues/940 3 | The parens in the exception match case with an alias, 4 | are required for correct parsing: 5 | i.e. (Sys_error _ as exc) instead of Sys_error _ as exc 6 | The latter doesn't type-check with Error: Unbound value exc. 7 | Warning 11 (unused match case) is also triggered. 8 | */ 9 | let f () = raise(Sys_error("error")); 10 | 11 | switch (f ()) { 12 | | x => () 13 | | exception (Sys_error(_) as exc) => raise(exc) 14 | }; 15 | 16 | exception Foo(string); 17 | 18 | let g () = raise(Foo("bar errors")); 19 | 20 | switch (g ()) { 21 | | x => () 22 | | exception Foo(f) => raise (Foo(f)) 23 | }; 24 | -------------------------------------------------------------------------------- /src/reason-parser/reason_multi_parser.mli: -------------------------------------------------------------------------------- 1 | type 'a parser 2 | 3 | val initial : 4 | (Lexing.position -> 'a Reason_parser.MenhirInterpreter.checkpoint) 5 | -> Lexing.position 6 | -> 'a parser 7 | 8 | type 'a step = 9 | | Intermediate of 'a parser 10 | | Success of 'a * Reason_lexer.invalid_docstrings 11 | | Error 12 | 13 | val step : 'a parser -> Reason_parser.token Reason_lexer.positioned -> 'a step 14 | 15 | (* Interface for recovery *) 16 | 17 | val recover : 18 | 'a Reason_parser.MenhirInterpreter.checkpoint 19 | -> Reason_lexer.invalid_docstrings 20 | -> 'a parser 21 | 22 | val recovery_env : 23 | 'a parser 24 | -> 'a Reason_parser.MenhirInterpreter.env * Reason_lexer.invalid_docstrings 25 | -------------------------------------------------------------------------------- /src/reason-parser/reason_single_parser.mli: -------------------------------------------------------------------------------- 1 | type 'a parser 2 | 3 | val initial : 4 | (Lexing.position -> 'a Reason_parser.MenhirInterpreter.checkpoint) 5 | -> Lexing.position 6 | -> 'a parser 7 | 8 | type 'a step = 9 | | Intermediate of 'a parser 10 | | Success of 'a * Reason_lexer.invalid_docstrings 11 | | Error 12 | 13 | val step : 'a parser -> Reason_parser.token Reason_lexer.positioned -> 'a step 14 | 15 | (* Interface for recovery *) 16 | 17 | val recover : 18 | 'a Reason_parser.MenhirInterpreter.checkpoint 19 | -> Reason_lexer.invalid_docstrings 20 | -> 'a parser 21 | 22 | val recovery_env : 23 | 'a parser 24 | -> 'a Reason_parser.MenhirInterpreter.env * Reason_lexer.invalid_docstrings 25 | -------------------------------------------------------------------------------- /src/reason-parser/merlin_recovery.mli: -------------------------------------------------------------------------------- 1 | module Make 2 | (Parser : MenhirLib.IncrementalEngine.EVERYTHING) 3 | (_ : Merlin_recovery_intf.RECOVERY with module Parser := Parser) : sig 4 | type 'a candidate = 5 | { line : int 6 | ; min_col : int 7 | ; max_col : int 8 | ; env : 'a Parser.env 9 | } 10 | 11 | type 'a candidates = 12 | { shifted : Parser.xsymbol option 13 | ; final : 'a option 14 | ; candidates : 'a candidate list 15 | } 16 | 17 | val attempt : 18 | 'a candidates 19 | -> Parser.token * Lexing.position * Lexing.position 20 | -> [> `Accept of 'a | `Fail | `Ok of 'a Parser.checkpoint * 'a Parser.env ] 21 | 22 | val generate : 'a Parser.env -> 'a candidates 23 | end 24 | -------------------------------------------------------------------------------- /src/reason-parser/reason_lexer.mli: -------------------------------------------------------------------------------- 1 | open Reason_parser 2 | 3 | type t 4 | type 'a positioned = 'a * Lexing.position * Lexing.position 5 | 6 | val init : ?insert_completion_ident:Lexing.position -> Lexing.lexbuf -> t 7 | val token : t -> token positioned 8 | val lexbuf : t -> Lexing.lexbuf 9 | 10 | type comment = string * Location.t 11 | 12 | (* Some docstrings are not accepted by the parser and turned into comments. *) 13 | type invalid_docstrings 14 | 15 | val empty_invalid_docstrings : invalid_docstrings 16 | 17 | val add_invalid_docstring : 18 | string 19 | -> Lexing.position 20 | -> Lexing.position 21 | -> invalid_docstrings 22 | -> invalid_docstrings 23 | 24 | val get_comments : t -> invalid_docstrings -> comment list 25 | -------------------------------------------------------------------------------- /js/testRefmtJs.js: -------------------------------------------------------------------------------- 1 | const refmt = require('../refmt') 2 | console.log(refmt) 3 | 4 | console.log(refmt.printRE(refmt.parseRE(`let f = (a) => a + 1; print_int(f(5))`))) 5 | console.log(refmt.printREI(refmt.parseREI(`let f: (~a: string) => int`))) 6 | console.log(refmt.printML(refmt.parseML(`let f a = a + 1 print_int @@ f 5`))) 7 | console.log(refmt.printMLI(refmt.parseMLI(`val f : a:string -> int`))) 8 | 9 | try { 10 | refmt.parseRE(`let f => =`) 11 | } catch (e) { 12 | console.log(e) 13 | } 14 | try { 15 | refmt.parseMLI(`val f: `) 16 | } catch (e) { 17 | console.log(e) 18 | } 19 | 20 | try { 21 | refmt.parseRE(`type X = Foo`) 22 | } catch (e) { 23 | console.log(e) 24 | } 25 | 26 | console.log("=============== we're good! ===============") 27 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/mew.0.1.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "zandoye@gmail.com" 3 | authors: [ "ZAN DoYe" ] 4 | homepage: "https://github.com/kandu/mew" 5 | bug-reports: "https://github.com/kandu/mew/issues" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/kandu/mew.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" {>= "4.02.3"} 13 | "result" 14 | "trie" {>= "1.0.0"} 15 | "dune" {>= "1.1.0"} 16 | ] 17 | 18 | synopsis: "Modal editing witch" 19 | description: """ 20 | This is the core module of mew, a general modal editing engine generator.""" 21 | 22 | url { 23 | src: "https://github.com/kandu/mew/archive/0.1.0.tar.gz" 24 | checksum: "md5=2298149d1415cd804ab4e01f01ea10a0" 25 | } 26 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/mew_vi.0.5.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "zandoye@gmail.com" 3 | authors: [ "ZAN DoYe" ] 4 | homepage: "https://github.com/kandu/mew_vi" 5 | bug-reports: "https://github.com/kandu/mew_vi/issues" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/kandu/mew_vi.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" {>= "4.02.3"} 13 | "mew" {>= "0.1.0" & < "0.2"} 14 | "react" 15 | "dune" {>= "1.1.0"} 16 | ] 17 | 18 | synopsis: "Modal editing witch, VI interpreter" 19 | description: """ 20 | A vi-like modal editing engine generator.""" 21 | 22 | url { 23 | src: "https://github.com/kandu/mew_vi/archive/0.5.0.tar.gz" 24 | checksum: "md5=341e9a9a20383641015bf503952906bc" 25 | } 26 | -------------------------------------------------------------------------------- /test/4.08/mlSyntax.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.ml > ./formatted.re 3 | 4 | Type-check basics 5 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 6 | File "formatted.re", line 71, characters 8-23: 7 | 71 | let _ = Pervasives.(==); 8 | ^^^^^^^^^^^^^^^ 9 | Alert deprecated: module Stdlib.Pervasives 10 | Use Stdlib instead. 11 | 12 | If you need to stay compatible with OCaml < 4.07, you can use the 13 | stdlib-shims library: https://github.com/ocaml/stdlib-shims 14 | 15 | Format the formatted file back 16 | $ refmt --print re ./formatted.re > ./formatted_back.re 17 | 18 | Ensure idempotency: first format and second format are the same 19 | $ diff formatted.re formatted_back.re 20 | -------------------------------------------------------------------------------- /test/lazy.t/input.re: -------------------------------------------------------------------------------- 1 | let myComputation = lazy { 2 | let tmp = 10; 3 | let tmp2 = 20; 4 | tmp + tmp2; 5 | }; 6 | 7 | type myRecord = {myRecordField: int}; 8 | 9 | let operateOnLazyValue (lazy {myRecordField}) { 10 | let tmp = myRecordField; 11 | tmp + tmp; 12 | }; 13 | 14 | let result = operateOnLazyValue (lazy {myRecordField: 100}); 15 | 16 | type box('a) = Box('a); 17 | 18 | let lazy thisIsActuallyAPatternMatch = lazy (200); 19 | let tmp: int = thisIsActuallyAPatternMatch; 20 | let (lazy (Box(i)), x) = (lazy (Box(200)), 100); 21 | let tmp: int = i; 22 | 23 | let myComputation = lazy (200); 24 | 25 | let reallyLoooooooooooooongIdentifierThatSpansMoreThan50Cols = 200; 26 | 27 | let foo = lazy(reallyLoooooooooooooongIdentifierThatSpansMoreThan50Cols) 28 | -------------------------------------------------------------------------------- /test/print-width-env.t: -------------------------------------------------------------------------------- 1 | Create a file with a long line 2 | $ cat >test.re < let initialState = uiStateFromValidated(~ownership=RemoteData.NotAsked, ~limits=initialLimits, SiteAuditSettings.default); 4 | > EOF 5 | 6 | Set the print width to 120 characters via env "REFMT_PRINT_WIDTH" 7 | $ REFMT_PRINT_WIDTH=120 refmt test.re 8 | let initialState = 9 | uiStateFromValidated(~ownership=RemoteData.NotAsked, ~limits=initialLimits, SiteAuditSettings.default); 10 | 11 | Set the print width to 80 characters via env "REFMT_PRINT_WIDTH" 12 | $ REFMT_PRINT_WIDTH=80 refmt test.re 13 | let initialState = 14 | uiStateFromValidated( 15 | ~ownership=RemoteData.NotAsked, 16 | ~limits=initialLimits, 17 | SiteAuditSettings.default, 18 | ); 19 | -------------------------------------------------------------------------------- /test/class_types.t/run.t: -------------------------------------------------------------------------------- 1 | Format class and class type 2 | $ refmt ./input.re 3 | class type _module ('provider_impl) = {}; 4 | type t; 5 | class type bzz = { 6 | inherit _module(t); 7 | }; 8 | 9 | class type t = { 10 | as 'a; 11 | constraint 'a = #s; 12 | }; 13 | 14 | /* https://github.com/facebook/reason/issues/2037 */ 15 | class type xt = { 16 | as 'a; 17 | }; 18 | 19 | class x = { 20 | as self; 21 | }; 22 | 23 | class type classWithNoArgType = { 24 | pub x: int; 25 | pub y: int; 26 | }; 27 | 28 | class classWithNoArg = { 29 | pub x = 0; 30 | pub y = 0; 31 | }; 32 | 33 | class type t = { 34 | open M; 35 | as 'a; 36 | }; 37 | 38 | class type t = { 39 | open M; 40 | }; 41 | -------------------------------------------------------------------------------- /test/mlVariants.t/input.ml: -------------------------------------------------------------------------------- 1 | (* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. *) 2 | 3 | type polyVariantsInMl = [ 4 | | `IntTuple of (int * int) 5 | | `StillAnIntTuple of (int * int) 6 | ] 7 | 8 | 9 | 10 | let intTuple = `IntTuple (1, 2) 11 | let stillAnIntTuple = `StillAnIntTuple (4, 5) 12 | let sumThem = function 13 | | `IntTuple (x, y) -> x + y 14 | | `StillAnIntTuple (a, b) -> a + b 15 | 16 | type nonrec t = A of int | B of bool 17 | 18 | type s = [ `Poly ] 19 | 20 | let x = (`Poly: s) 21 | 22 | (* There's a bug in ocaml 4.06 resulting in an extra Pexp_constraint on the `Poly, 23 | * duplicating the core_type. 24 | * https://caml.inria.fr/mantis/view.php?id=7758 25 | * https://caml.inria.fr/mantis/view.php?id=7344 *) 26 | let x : s = `Poly 27 | -------------------------------------------------------------------------------- /test/rtopIntegration.t: -------------------------------------------------------------------------------- 1 | Context: https://github.com/reasonml/reason/pull/674 2 | 3 | We can't directly call `rtop -stdin` because it circumvents what we're trying to 4 | test. See rtop.sh for the reason. We want to make sure utop's reason 5 | integration is legit, 6 | 7 | `utop -stdin` wouldn't work because it somehow processes the code before 8 | invoking the reason plugin, so `echo someReasonCode | utop -stdin` would 9 | always error. 10 | 11 | Given the above, we're gonna test that utop integration works by piping code 12 | into it and asserting the existence of some output. 13 | 14 | $ echo "let f = a => a;" | rtop | grep -o "let f: 'a => 'a = ;" 15 | let f: 'a => 'a = ; 16 | 17 | $ echo "let f = (a) => 1 + \"hi\";" | rtop | grep -o "has type" 18 | has type 19 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ### Documentation 2 | 3 | > This directory is not the Reason _User_ documentation. This directory is for 4 | > Reason contributor documentation. **The Reason user docs live online at 5 | > [https://reasonml.github.io](https://reasonml.github.io)**. The repo for 6 | > those Reason docs lives at 7 | > [github.com/reasonml/reasonml.github.io](https://github.com/reasonml/reasonml.github.io) 8 | 9 | **Inside of this directory:** 10 | 11 | 12 | **Getting Started Contributing:** 13 | 14 | [`GETTING_STARTED_CONTRIBUTING.md`](./GETTING_STARTED_CONTRIBUTING.md). 15 | 16 | **Releasing:** 17 | [`RELEASING.md`](./RELEASING.md) 18 | 19 | **Programmatically Using Reason Parser From JavaScript:** 20 | [`USING_PARSER_PROGRAMMATICALLY.md`](./USING_PARSER_PROGRAMMATICALLY.md) 21 | 22 | -------------------------------------------------------------------------------- /src/reason-parser/ocaml_util.cppo.mli: -------------------------------------------------------------------------------- 1 | val print_error : 2 | loc:Location.t 3 | -> f:(Format.formatter -> 'a -> unit) 4 | -> Format.formatter 5 | -> 'a 6 | -> unit 7 | 8 | #if OCAML_VERSION >= (5,3,0) 9 | module Utf8_lexeme = Misc.Utf8_lexeme 10 | #else 11 | module Utf8_lexeme : sig 12 | type t = string 13 | 14 | val normalize : t -> (t, string) result 15 | val is_capitalized : t -> bool 16 | 17 | type validation_result = 18 | | Valid 19 | | Invalid_character of Uchar.t (** Character not allowed *) 20 | | Invalid_beginning of Uchar.t (** Character not allowed as first char *) 21 | 22 | val validate_identifier : ?with_dot:bool -> t -> validation_result 23 | val is_valid_identifier : t -> bool 24 | val is_lowercase : t -> bool 25 | end 26 | #endif 27 | -------------------------------------------------------------------------------- /src/refmt/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (public_name refmt) 3 | (package reason) 4 | (modes exe byte) 5 | (modules refmt) 6 | (flags :standard -open StdLabels) 7 | (libraries refmt_lib)) 8 | 9 | (library 10 | (public_name reason.refmt-lib) 11 | (name refmt_lib) 12 | (modules :standard \ refmt) 13 | (flags :standard -open StdLabels) 14 | (libraries reason cmdliner dune-build-info)) 15 | 16 | (rule 17 | (with-stdout-to 18 | git_commit.ml 19 | (progn 20 | (bash "echo let version = \\\"$(git rev-parse --verify HEAD)\\\"") 21 | (bash "echo let short_version = \\\"$(git rev-parse --short HEAD)\\\"")))) 22 | 23 | (rule 24 | (with-stdout-to 25 | refmt.1 26 | (run %{bin:refmt} --help=groff))) 27 | 28 | (install 29 | (section man) 30 | (package reason) 31 | (files refmt.1)) 32 | -------------------------------------------------------------------------------- /test/bigarray.t/input.re: -------------------------------------------------------------------------------- 1 | my_big_array3.{reallyLongStringThatWillDefinitelyBreakLine}; 2 | 3 | my_big_array3.{reallyLongStringThatWillDefinitelyBreakLine, reallyLongStringThatWillDefinitelyBreakLine}; 4 | 5 | my_big_array3.{reallyLongStringThatWillDefinitelyBreakLine, reallyLongStringThatWillDefinitelyBreakLine, reallyLongStringThatWillDefinitelyBreakLine}; 6 | 7 | my_big_array3.{reallyLongString, reallyLongString, reallyLongString, reallyLongString, reallyLongString}; 8 | 9 | my_big_array3.{reallyLongStringThatWillDefinitelyBreakLine} = 3.0; 10 | 11 | my_big_array3.{reallyLongStringThatWillDefinitelyBreakLine, reallyLongStringThatWillDefinitelyBreakLine} = 3.0; 12 | 13 | my_big_array3.{reallyLongString, reallyLongString, reallyLongString, reallyLongString, reallyLongString} = 3.0; 14 | -------------------------------------------------------------------------------- /src/reason-parser/TODO: -------------------------------------------------------------------------------- 1 | Recovery (Urgent): 2 | * Not clear what the pipeline for errors should be 3 | * Find better names for the many modules 4 | * If necessary, tune performance 5 | * What is the licensing situation? 6 | 7 | Error messages (Medium-term): 8 | * Agree on a strategy with other people: what should messages look like? 9 | What should they do: describe the context? suggest common corrections? 10 | Point people to grammar documentation? 11 | * To learn what correct files look like we can probably data-mine public reason 12 | repositories. 13 | * To learn what incorrect files look like, we need some way to collect common 14 | errors!!!! 15 | 16 | Completion (Long-term): 17 | * Introduce merlin.location when there is ambiguity between concrete and 18 | abstract locations 19 | -------------------------------------------------------------------------------- /test/raw-identifiers.t/input.re: -------------------------------------------------------------------------------- 1 | 2 | let \#let = 2; 3 | let \#let = \#let 4 | and \#and = \#let; 5 | 6 | /* labeled arguments */ 7 | let \#let = (~\#let) => { 8 | \#let; 9 | }; 10 | 11 | let \#let = (~\#let: \#let = \#let) => { 12 | \#let; 13 | }; 14 | 15 | /* Types */ 16 | type \#type = \#type; 17 | 18 | module type \#module = \#module; 19 | 20 | class \#class = \#class; 21 | 22 | class type \#class = \#class; 23 | 24 | type x = [ | `\#module ] 25 | type y = [ | \#module ] 26 | let x = `\#module 27 | 28 | external \#external: unit => unit = "external"; 29 | 30 | type \#rec = { 31 | \#type: \#type, 32 | \#module: module_ 33 | }; 34 | 35 | let \#rec = { 36 | \#type: \#type, 37 | \#module: module_ 38 | } 39 | 40 | let true = x => x; 41 | 42 | let \#true = x => x; 43 | 44 | -------------------------------------------------------------------------------- /test/4.10/typecheck-let-ops.t: -------------------------------------------------------------------------------- 1 | $ cat > input.ml < open struct 3 | > type t = string 4 | > end 5 | > 6 | > let (let+) x f = List.map f x 7 | > 8 | > let (and+) = List.map2 (fun x y -> x,y) 9 | > 10 | > let x = 11 | > let+ x = [2] 12 | > and+ y = [3] 13 | > in 14 | > x, y 15 | > 16 | > let y = 17 | > let+ x = [2] in 18 | > x 19 | > EOF 20 | 21 | Format basic 22 | $ refmt --print re ./input.ml > ./formatted.re 23 | 24 | Type-check basics 25 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 26 | 27 | Format the formatted file back 28 | $ refmt --print re ./formatted.re > ./formatted_back.re 29 | 30 | Ensure idempotency: first format and second format are the same 31 | $ diff formatted.re formatted_back.re 32 | -------------------------------------------------------------------------------- /test/4.12/typecheck-let-ops.t: -------------------------------------------------------------------------------- 1 | $ cat > input.ml < open struct 3 | > type t = string 4 | > end 5 | > 6 | > let (let+) x f = List.map f x 7 | > 8 | > let (and+) = List.map2 (fun x y -> x,y) 9 | > 10 | > let x = 11 | > let+ x = [2] 12 | > and+ y = [3] 13 | > in 14 | > x, y 15 | > 16 | > let y = 17 | > let+ x = [2] in 18 | > x 19 | > EOF 20 | 21 | Format basic 22 | $ refmt --print re ./input.ml > ./formatted.re 23 | 24 | Type-check basics 25 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 26 | 27 | Format the formatted file back 28 | $ refmt --print re ./formatted.re > ./formatted_back.re 29 | 30 | Ensure idempotency: first format and second format are the same 31 | $ diff formatted.re formatted_back.re 32 | -------------------------------------------------------------------------------- /rtop.esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.2+win_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < winpatch.patch' : 'true'}" 7 | ], 8 | [ 9 | "make", 10 | "-f", 11 | "configure.make", 12 | "all", 13 | "OCAMLBUILD_PREFIX=#{self.install}", 14 | "OCAMLBUILD_BINDIR=#{self.bin}", 15 | "OCAMLBUILD_LIBDIR=#{self.lib}", 16 | "OCAMLBUILD_MANDIR=#{self.man}", 17 | "OCAMLBUILD_NATIVE=true", 18 | "OCAMLBUILD_NATIVE_TOOLS=true", 19 | "EXE=#{os == 'windows' ? '.exe': ''}" 20 | ], 21 | [ 22 | "make", 23 | "check-if-preinstalled", 24 | "all", 25 | "EXE=#{os == 'windows' ? '.exe': ''}", 26 | "opam-install" 27 | ] 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/vendored-omp/src/compiler-functions/ge_50.ml: -------------------------------------------------------------------------------- 1 | let error_of_exn exn = 2 | match Location.error_of_exn exn with 3 | | Some (`Ok exn) -> Some exn 4 | | Some `Already_displayed -> None 5 | | None -> None 6 | 7 | let get_load_paths () = 8 | Load_path.get_paths () 9 | 10 | let load_path_init l = 11 | let auto_include find_in_dir fn = 12 | if !Clflags.no_std_include then 13 | raise Not_found 14 | else 15 | let alert = Location.auto_include_alert in 16 | Load_path.auto_include_otherlibs alert find_in_dir fn 17 | in 18 | Load_path.init ~auto_include l 19 | 20 | let get_unboxed_types () = 21 | !Clflags.unboxed_types 22 | 23 | let set_unboxed_types b = 24 | Clflags.unboxed_types := b 25 | 26 | let may_map = Option.map 27 | 28 | let bad_docstring t = Warnings.Unexpected_docstring t 29 | -------------------------------------------------------------------------------- /.ocamlformat: -------------------------------------------------------------------------------- 1 | break-infix = fit-or-vertical 2 | break-infix-before-func = false 3 | break-fun-decl = fit-or-vertical 4 | break-separators = before 5 | break-sequences = true 6 | cases-exp-indent = 2 7 | dock-collection-brackets = false 8 | field-space = loose 9 | if-then-else = keyword-first 10 | indicate-multiline-delimiters = no 11 | infix-precedence = parens 12 | leading-nested-match-parens = true 13 | let-and = sparse 14 | let-module = sparse 15 | ocp-indent-compat = true 16 | parens-tuple = multi-line-only 17 | parse-docstrings = true 18 | sequence-blank-line = preserve-one 19 | sequence-style = terminator 20 | single-case = sparse 21 | space-around-arrays= true 22 | space-around-lists= true 23 | space-around-records= true 24 | space-around-variants= true 25 | type-decl = sparse 26 | wrap-comments = true 27 | wrap-fun-args = false 28 | -------------------------------------------------------------------------------- /rtop/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name rtoplib) 3 | (public_name rtop) 4 | (modules reason_util reason_utop reason_toploop) 5 | (modes byte) 6 | (flags :standard -open StdLabels) 7 | (libraries 8 | menhirLib 9 | reason.easy_format 10 | reason 11 | utop 12 | reason.ocaml-migrate-parsetree)) 13 | 14 | (rule 15 | (targets reason_toploop.ml) 16 | (deps reason_toploop.cppo.ml) 17 | (action 18 | (run cppo -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) 19 | 20 | (rule 21 | (targets reason_utop.ml) 22 | (deps reason_utop.cppo.ml) 23 | (action 24 | (run cppo -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) 25 | 26 | (executable 27 | (name rtop) 28 | (public_name rtop) 29 | (package rtop) 30 | (modules rtop) 31 | (link_flags -linkall) 32 | (modes byte) 33 | (flags :standard -open StdLabels) 34 | (libraries rtop)) 35 | -------------------------------------------------------------------------------- /src/reason-parser/reason_oprint.mli: -------------------------------------------------------------------------------- 1 | open Format 2 | open Reason_omp.Ast_414.Outcometree 3 | 4 | val print_ident : formatter -> out_ident -> unit 5 | val print_out_value : formatter -> out_value -> unit 6 | val print_out_label : formatter -> string * bool * out_type -> unit 7 | val print_out_type : formatter -> out_type -> unit 8 | val print_out_constr : formatter -> out_constructor -> unit 9 | val print_out_class_type : formatter -> out_class_type -> unit 10 | val print_out_module_type : formatter -> out_module_type -> unit 11 | val print_out_sig_item : formatter -> out_sig_item -> unit 12 | val print_out_signature : formatter -> out_sig_item list -> unit 13 | val print_out_type_extension : formatter -> out_type_extension -> unit 14 | val print_out_phrase : formatter -> out_phrase -> unit 15 | val parenthesized_ident : string -> bool 16 | -------------------------------------------------------------------------------- /test/4.08/typecheck-features.t: -------------------------------------------------------------------------------- 1 | $ cat > input.mli < module X : sig 3 | > type t 4 | > end 5 | > 6 | > module M := X 7 | > 8 | > module N := X [@@attr] 9 | > 10 | > type y = int 11 | > 12 | > type z = int 13 | > 14 | > type t = int 15 | > 16 | > type x := y 17 | > 18 | > type y := z [@@attr1] 19 | > and w := t [@@attr2] 20 | > 21 | > type x' = | and y' = | 22 | > EOF 23 | 24 | Format basic 25 | $ refmt --print re ./input.mli > ./formatted.rei 26 | 27 | Type-check basics 28 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -intf formatted.rei 29 | 30 | Format the formatted file back 31 | $ refmt --print re ./formatted.rei > ./formatted_back.rei 32 | 33 | Ensure idempotency: first format and second format are the same 34 | $ diff formatted.rei formatted_back.rei 35 | -------------------------------------------------------------------------------- /src/vendored-omp/src/compiler-functions/ge_52.ml: -------------------------------------------------------------------------------- 1 | let error_of_exn exn = 2 | match Location.error_of_exn exn with 3 | | Some (`Ok exn) -> Some exn 4 | | Some `Already_displayed -> None 5 | | None -> None 6 | 7 | let get_load_paths () = 8 | Load_path.get_paths () 9 | 10 | let load_path_init l = 11 | let auto_include find_in_dir fn = 12 | if !Clflags.no_std_include then 13 | raise Not_found 14 | else 15 | let alert = Location.auto_include_alert in 16 | Load_path.auto_include_otherlibs alert find_in_dir fn 17 | in 18 | Load_path.init ~auto_include ~visible:l ~hidden:[] 19 | 20 | let get_unboxed_types () = 21 | !Clflags.unboxed_types 22 | 23 | let set_unboxed_types b = 24 | Clflags.unboxed_types := b 25 | 26 | let may_map = Option.map 27 | 28 | let bad_docstring t = Warnings.Unexpected_docstring t 29 | -------------------------------------------------------------------------------- /esy.lock/opam/mew.0.1.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "zandoye@gmail.com" 3 | authors: [ "ZAN DoYe" ] 4 | homepage: "https://github.com/kandu/mew" 5 | bug-reports: "https://github.com/kandu/mew/issues" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/kandu/mew.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" {>= "4.02.3"} 13 | "result" 14 | "trie" {>= "1.0.0"} 15 | "dune" {>= "1.1.0"} 16 | ] 17 | 18 | synopsis: "Modal editing witch" 19 | description: """ 20 | This is the core module of mew, a general modal editing engine generator.""" 21 | 22 | url { 23 | src: "https://github.com/kandu/mew/archive/0.1.0.tar.gz" 24 | checksum: [ 25 | "sha256=64d38ceb52ef574cb314bdd693f7e4a9c9e483e80a58595db22f2df76a8a59e6" 26 | "md5=2298149d1415cd804ab4e01f01ea10a0" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /esy.lock/opam/mew_vi.0.5.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "zandoye@gmail.com" 3 | authors: [ "ZAN DoYe" ] 4 | homepage: "https://github.com/kandu/mew_vi" 5 | bug-reports: "https://github.com/kandu/mew_vi/issues" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/kandu/mew_vi.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" {>= "4.02.3"} 13 | "mew" {>= "0.1.0" & < "0.2"} 14 | "react" 15 | "dune" {>= "1.1.0"} 16 | ] 17 | 18 | synopsis: "Modal editing witch, VI interpreter" 19 | description: """ 20 | A vi-like modal editing engine generator.""" 21 | 22 | url { 23 | src: "https://github.com/kandu/mew_vi/archive/0.5.0.tar.gz" 24 | checksum: [ 25 | "sha256=a692fa7cdcc9e80fd9387c4f61677776b9fc15f9f7175b4220fcd1a73d1bafda" 26 | "md5=341e9a9a20383641015bf503952906bc" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/result.1.5/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Jane Street developers" 3 | authors: ["Jane Street Group, LLC"] 4 | homepage: "https://github.com/janestreet/result" 5 | dev-repo: "git+https://github.com/janestreet/result.git" 6 | bug-reports: "https://github.com/janestreet/result/issues" 7 | license: "BSD-3-Clause" 8 | build: [["dune" "build" "-p" name "-j" jobs]] 9 | depends: [ 10 | "ocaml" 11 | "dune" {>= "1.0"} 12 | ] 13 | synopsis: "Compatibility Result module" 14 | description: """ 15 | Projects that want to use the new result type defined in OCaml >= 4.03 16 | while staying compatible with older version of OCaml should use the 17 | Result module defined in this library.""" 18 | url { 19 | src: 20 | "https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz" 21 | checksum: "md5=1b82dec78849680b49ae9a8a365b831b" 22 | } 23 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/ppx_derivers.1.2.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "jeremie@dimino.org" 3 | authors: ["Jérémie Dimino"] 4 | license: "BSD-3-Clause" 5 | homepage: "https://github.com/ocaml-ppx/ppx_derivers" 6 | bug-reports: "https://github.com/ocaml-ppx/ppx_derivers/issues" 7 | dev-repo: "git+https://github.com/ocaml-ppx/ppx_derivers.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" 13 | "dune" 14 | ] 15 | synopsis: "Shared [@@deriving] plugin registry" 16 | description: """ 17 | Ppx_derivers is a tiny package whose sole purpose is to allow 18 | ppx_deriving and ppx_type_conv to inter-operate gracefully when linked 19 | as part of the same ocaml-migrate-parsetree driver.""" 20 | url { 21 | src: "https://github.com/ocaml-ppx/ppx_derivers/archive/1.2.1.tar.gz" 22 | checksum: "md5=5dc2bf130c1db3c731fe0fffc5648b41" 23 | } 24 | -------------------------------------------------------------------------------- /src/reason-parser/reason_pprint_ast.mli: -------------------------------------------------------------------------------- 1 | open Ppxlib 2 | 3 | val configure : 4 | width:int 5 | -> assumeExplicitArity:bool 6 | -> constructorLists:string list 7 | -> unit 8 | 9 | val createFormatter : 10 | unit 11 | -> < case_list : Format.formatter -> Parsetree.case list -> unit 12 | ; core_type : Format.formatter -> Parsetree.core_type -> unit 13 | ; expression : Format.formatter -> Parsetree.expression -> unit 14 | ; pattern : Format.formatter -> Parsetree.pattern -> unit 15 | ; signature : 16 | Reason_comment.t list 17 | -> Format.formatter 18 | -> Parsetree.signature 19 | -> unit 20 | ; structure : 21 | Reason_comment.t list 22 | -> Format.formatter 23 | -> Parsetree.structure 24 | -> unit 25 | ; toplevel_phrase : Format.formatter -> Parsetree.toplevel_phrase -> unit > 26 | -------------------------------------------------------------------------------- /test/class.t/run.t: -------------------------------------------------------------------------------- 1 | See the typed tree from ./input.re 2 | $ cat ./input.re | ../lib/outcometreePrinter.exe 3 | class aClass1 : 4 | ('a) => 5 | { 6 | pub a1: int; 7 | pub a2: unit => int; 8 | pub a3: (int, int) => int; 9 | pub a4: (int, int) => int 10 | }; 11 | class aClass2 : ('a) => { }; 12 | class aClass3 : (int, int) => { }; 13 | class aClass4 : (int, int, int) => { }; 14 | class aClass5 : (int, int, int) => { }; 15 | class aClass6 : (int => int, int) => { }; 16 | class aClass7 : (int, int, int) => { }; 17 | class labeledClass1 : ('a) => { }; 18 | class labeledClass2 : (~x: int, int) => { }; 19 | class labeledClass3 : (~x: int, int, int) => { }; 20 | class labeledClass4 : (~x: int, int, int) => { }; 21 | class labeledClass5 : ((~y: int) => int, int) => { }; 22 | class labeledClass6 : (~x: (int, int), int) => { }; 23 | -------------------------------------------------------------------------------- /test/extension-exprs.t/input.re: -------------------------------------------------------------------------------- 1 | /* Extension with pexp_apply */ 2 | 3 | [%defer 4 | cleanup(); 5 | ]; 6 | 7 | /* Extension with comment with pexp_apply */ 8 | 9 | [%defer 10 | /* 2. comment attached to expr in extension */ 11 | cleanup(); 12 | ]; 13 | 14 | /* Let sequence + extension with pexp_apply */ 15 | 16 | let () = { 17 | /* random let binding */ 18 | let x = 1; 19 | /* 1. comment attached to extension */ 20 | [%defer cleanup()]; 21 | /* 3. comment attached to next expr */ 22 | something_else(); 23 | }; 24 | 25 | /* Let sequence + extension with comment with pexp_apply */ 26 | 27 | let () = { 28 | /* random let binding */ 29 | let x = 1; 30 | /* 1. comment attached to extension */ 31 | [%defer 32 | /* 2. comment attached to expr in extension */ 33 | cleanup() 34 | ]; 35 | /* 3. comment attached to next expr */ 36 | something_else(); 37 | }; 38 | -------------------------------------------------------------------------------- /test/generics.t/input.re: -------------------------------------------------------------------------------- 1 | type t = A { a : int } | B; 2 | 3 | let f = fun 4 | | B => 0 5 | | A { a } => a; 6 | 7 | type nonrec u('a) = Box('a); 8 | 9 | type expr('a) = 10 | | Val {value: 'a} :expr('a) 11 | | Add {left: expr(int), right: expr(int)} :expr(int) 12 | | Is0 {test: expr(int)} :expr(bool) 13 | | If {pred: expr(bool), true_branch: expr('a), false_branch: expr('a)} :expr('a); 14 | 15 | let rec eval: type a. (expr(a)) => a = 16 | fun(e) => 17 | switch (e) { 18 | | Is0 {test} => eval(test) == 0 19 | | Val {value} => value 20 | | Add {left, right} => eval(left) + eval(right) 21 | | If {pred, true_branch, false_branch} => 22 | if (eval(pred)) { 23 | eval(true_branch) 24 | } else { 25 | eval(false_branch) 26 | } 27 | }; 28 | 29 | type hlist = 30 | | [] : hlist; 31 | 32 | let foo (type a, type b) = 5; 33 | -------------------------------------------------------------------------------- /esy.lock/opam/fix.20250428/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | ] 7 | homepage: "https://gitlab.inria.fr/fpottier/fix" 8 | dev-repo: "git+https://gitlab.inria.fr/fpottier/fix.git" 9 | bug-reports: "francois.pottier@inria.fr" 10 | license: "LGPL-2.0-only" 11 | build: [ 12 | ["dune" "build" "-p" name "-j" jobs] 13 | ] 14 | depends: [ 15 | "ocaml" { >= "4.03" } 16 | "dune" { >= "1.3" } 17 | ] 18 | synopsis: "Algorithmic building blocks for memoization, recursion, and more" 19 | url { 20 | src: 21 | "https://gitlab.inria.fr/fpottier/fix/-/archive/20250428/archive.tar.gz" 22 | checksum: [ 23 | "md5=75aeb28e58d5a2c8b8c2590d23d1122d" 24 | "sha512=744b08403beb22d8d960976792dd2f80ee9b47c9b3d3977d98e09aa127c3e21531acb305ab42c734ad1067b0ababa43b251afd3e111d296e3b07fbe2c187b082" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/fix.20230505/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | ] 7 | homepage: "https://gitlab.inria.fr/fpottier/fix" 8 | dev-repo: "git+https://gitlab.inria.fr/fpottier/fix.git" 9 | bug-reports: "francois.pottier@inria.fr" 10 | license: "LGPL-2.0-only" 11 | build: [ 12 | ["dune" "build" "-p" name "-j" jobs] 13 | ] 14 | depends: [ 15 | "ocaml" { >= "4.03" } 16 | "dune" { >= "1.3" } 17 | ] 18 | synopsis: "Algorithmic building blocks for memoization, recursion, and more" 19 | url { 20 | src: 21 | "https://gitlab.inria.fr/fpottier/fix/-/archive/20230505/archive.tar.gz" 22 | checksum: [ 23 | "md5=2a4afa633128c5010677222f7b3c9451" 24 | "sha512=30d446ba6c19aef78b52d9831eb26f8f6ac10e88bd1eff36d16fbbfb32278b2637e31e63a160aec4abbbfdb1e7612ed25d68c936f4cbf2073e51d713ff3a8adf" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /test/4.06/typecheck-module-and-class.t: -------------------------------------------------------------------------------- 1 | $ cat > input.ml < module EM = struct 3 | > (** Exception *) 4 | > exception E of int * int 5 | > end 6 | > 7 | > (* Pcl_open *) 8 | > class x = let open EM in object (self) end 9 | > 10 | > module OM = struct 11 | > type t 12 | > end 13 | > 14 | > class y = let open EM in let open OM in object (self) end 15 | > 16 | > module type S = sig 17 | > type t = private .. 18 | > type t += Foo 19 | > end 20 | > EOF 21 | 22 | Format basic 23 | $ refmt --print re ./input.ml > ./formatted.re 24 | 25 | Type-check basics 26 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 27 | 28 | Format the formatted file back 29 | $ refmt --print re ./formatted.re > ./formatted_back.re 30 | 31 | Ensure idempotency: first format and second format are the same 32 | $ diff formatted.re formatted_back.re 33 | -------------------------------------------------------------------------------- /src/reason-parser/reason_toolchain.mli: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Reason *) 4 | (* *) 5 | (***********************************************************************) 6 | (* 7 | * Copyright (c) 2015-present, Facebook, Inc. 8 | * 9 | * This source code is licensed under the MIT license found in the 10 | * LICENSE file in the root directory of this source tree. 11 | *) 12 | 13 | (* open Ppxlib *) 14 | 15 | module ML : Reason_toolchain_conf.Toolchain 16 | module RE : Reason_toolchain_conf.Toolchain 17 | module From_current = Reason_toolchain_conf.From_current 18 | module To_current = Reason_toolchain_conf.To_current 19 | 20 | val setup_lexbuf : use_stdin:bool -> string -> Lexing.lexbuf 21 | -------------------------------------------------------------------------------- /test/trailing.t/input.re: -------------------------------------------------------------------------------- 1 | 2 | let x = { 3 | "obj": obj, 4 | }; 5 | 6 | let x = { 7 | "key", 8 | "keyTwo", 9 | }; 10 | 11 | let x = { 12 | ...x, 13 | "key", 14 | }; 15 | 16 | let x = { 17 | ...x, 18 | "key", 19 | "keyTwo", 20 | }; 21 | 22 | type t = {. 23 | "x": int, 24 | }; 25 | 26 | type t('a) = {.. 27 | "x": int, 28 | } as 'a; 29 | 30 | type t = {. 31 | "x": (int, int), 32 | }; 33 | 34 | type t('a) = {.. 35 | "x": (int, int), 36 | } as 'a; 37 | 38 | 39 | let x = { 40 | "obj": 0, 41 | }; 42 | 43 | let x = { 44 | "key": 0, 45 | "keyTwo": 1, 46 | }; 47 | 48 | let x = { 49 | ...x, 50 | "key": 0, 51 | }; 52 | 53 | let x = { 54 | ...x, 55 | "key": 0, 56 | "keyTwo": 1, 57 | }; 58 | 59 | type t = {. 60 | "x": int, 61 | }; 62 | 63 | type t('a) = {.. 64 | "x": int, 65 | } as 'a; 66 | 67 | type t = {. 68 | "x": (int, int), 69 | }; 70 | 71 | type t('a) = {.. 72 | "x": (int, int), 73 | } as 'a; 74 | -------------------------------------------------------------------------------- /src/menhir-recover/recovery_intf.ml: -------------------------------------------------------------------------------- 1 | module type RECOVERY = sig 2 | module G : MenhirSdk.Cmly_api.GRAMMAR 3 | 4 | type item = G.lr1 * G.production * int 5 | 6 | type recovery = 7 | { prefix : int 8 | ; cases : (G.lr1 option * item list) list 9 | } 10 | (** [prefix] is the size of the known prefix of the stack. It means that in 11 | the kernel of current state, there is an item whose dot is at position 12 | [prefix]. (we know the incoming symbols for these stack frames and we can 13 | enumerate the possible state numbers). 14 | 15 | [cases] is a mapping that associates to each possible state found at 16 | stack.[-prefix] (or None if the stack is empty) a list of reductions to 17 | execute. 18 | 19 | The actual list of actions to reduce an item [(state, prod, pos)] is given 20 | by [Synthesizer.solution (Trail (state, prod, pos))] *) 21 | 22 | val recover : G.lr1 -> recovery 23 | end 24 | -------------------------------------------------------------------------------- /esy.lock/opam/result.1.5/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Jane Street developers" 3 | authors: ["Jane Street Group, LLC"] 4 | homepage: "https://github.com/janestreet/result" 5 | dev-repo: "git+https://github.com/janestreet/result.git" 6 | bug-reports: "https://github.com/janestreet/result/issues" 7 | license: "BSD-3-Clause" 8 | build: [["dune" "build" "-p" name "-j" jobs]] 9 | depends: [ 10 | "ocaml" 11 | "dune" {>= "1.0"} 12 | ] 13 | synopsis: "Compatibility Result module" 14 | description: """ 15 | Projects that want to use the new result type defined in OCaml >= 4.03 16 | while staying compatible with older version of OCaml should use the 17 | Result module defined in this library.""" 18 | url { 19 | src: 20 | "https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz" 21 | checksum: [ 22 | "sha256=7c3a5e238558f4c1a4f5acca816bc705a0e12f68dc0005c61ddbf2e6cab8ee32" 23 | "md5=1b82dec78849680b49ae9a8a365b831b" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /esy.lock/opam/seq.base/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: " " 3 | authors: " " 4 | homepage: " " 5 | depends: [ 6 | "ocaml" {>= "4.07.0"} 7 | ] 8 | dev-repo: "git+https://github.com/ocaml/ocaml.git" 9 | bug-reports: "https://caml.inria.fr/mantis/main_page.php" 10 | synopsis: 11 | "Compatibility package for OCaml's standard iterator type starting from 4.07." 12 | extra-source "seq.install" { 13 | src: 14 | "https://raw.githubusercontent.com/ocaml/opam-source-archives/main/patches/seq/seq.install" 15 | checksum: [ 16 | "sha256=fff926c2c4d5a82b6c94c60c4c35eb06e3d39975893ebe6b1f0e6557cbe34904" 17 | "md5=026b31e1df290373198373d5aaa26e42" 18 | ] 19 | } 20 | extra-source "META.seq" { 21 | src: 22 | "https://raw.githubusercontent.com/ocaml/opam-source-archives/main/patches/seq/META.seq" 23 | checksum: [ 24 | "sha256=e95062b4d0519ef8335c02f7d0f1952d11b814c7ab7e6d566a206116162fa2be" 25 | "md5=b33c8a1a6c7ed797816ce27df4855107" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/jsx_functor.t/run.t: -------------------------------------------------------------------------------- 1 | Format JSX functors 2 | $ refmt ./input.re 3 | type elt = 4 | | Text(string) 5 | | Group(list(elt)); 6 | 7 | module X = { 8 | let createElement = (~children=[], ()) => { 9 | Text("x"); 10 | }; 11 | }; 12 | 13 | module Y = { 14 | let createElement = (~children=[], ()) => { 15 | Text("y"); 16 | }; 17 | }; 18 | 19 | module M = 20 | ( 21 | X: (module type of X), 22 | Y: (module type of Y), 23 | ) => { 24 | let createElement = 25 | (~name="M", ~id=0, ~children=[], ()) => { 26 | Group( 27 | [ 28 | Text(name), 29 | Text(string_of_int(id)), 30 | , 31 | , 32 | ] 33 | @ children, 34 | ); 35 | }; 36 | }; 37 | 38 | let _ = 39 | Group([ 40 | , 41 | {Text("A")} , 42 | , 43 | ]); 44 | -------------------------------------------------------------------------------- /esy.lock/opam/ppx_derivers.1.2.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "jeremie@dimino.org" 3 | authors: ["Jérémie Dimino"] 4 | license: "BSD-3-Clause" 5 | homepage: "https://github.com/ocaml-ppx/ppx_derivers" 6 | bug-reports: "https://github.com/ocaml-ppx/ppx_derivers/issues" 7 | dev-repo: "git+https://github.com/ocaml-ppx/ppx_derivers.git" 8 | build: [ 9 | ["dune" "build" "-p" name "-j" jobs] 10 | ] 11 | depends: [ 12 | "ocaml" 13 | "dune" 14 | ] 15 | synopsis: "Shared [@@deriving] plugin registry" 16 | description: """ 17 | Ppx_derivers is a tiny package whose sole purpose is to allow 18 | ppx_deriving and ppx_type_conv to inter-operate gracefully when linked 19 | as part of the same ocaml-migrate-parsetree driver.""" 20 | url { 21 | src: "https://github.com/ocaml-ppx/ppx_derivers/archive/1.2.1.tar.gz" 22 | checksum: [ 23 | "sha256=b6595ee187dea792b31fc54a0e1524ab1e48bc6068d3066c45215a138cc73b95" 24 | "md5=5dc2bf130c1db3c731fe0fffc5648b41" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /reason.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@esy-ocaml/reason", 3 | "version": "3.8.2", 4 | "license": "MIT", 5 | "description": "Native Compiler Support for Reason: Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/reasonml/reason.git" 9 | }, 10 | "dependencies": { 11 | "ocaml": ">= 4.2.0 < 5.1.0", 12 | "@opam/fix": "*", 13 | "@opam/ocamlfind": "*", 14 | "@opam/menhir": " >= 20180523.0.0", 15 | "@opam/merlin-extend": " >= 0.6", 16 | "@opam/ppxlib": "> 0.28.x", 17 | "@opam/dune": ">= 2.9.3", 18 | "@opam/dune-build-info": ">= 2.9.3" 19 | }, 20 | "devDependencies": { 21 | "@opam/merlin": "*", 22 | "ocaml": "~4.14.0" 23 | }, 24 | "esy": { 25 | "build": [ 26 | [ 27 | "dune", 28 | "build", 29 | "-p", 30 | "reason", 31 | "--disable-promotion" 32 | ] 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/trailing.t/run.t: -------------------------------------------------------------------------------- 1 | Format trailing 2 | $ refmt ./input.re 3 | let x = { "obj": obj }; 4 | 5 | let x = { 6 | "key": key, 7 | "keyTwo": keyTwo, 8 | }; 9 | 10 | let x = { 11 | ...x, 12 | "key": key, 13 | }; 14 | 15 | let x = { 16 | ...x, 17 | "key": key, 18 | "keyTwo": keyTwo, 19 | }; 20 | 21 | type t = {. "x": int }; 22 | 23 | type t('a) = {.. "x": int } as 'a; 24 | 25 | type t = {. "x": (int, int) }; 26 | 27 | type t('a) = {.. "x": (int, int) } as 'a; 28 | 29 | let x = { "obj": 0 }; 30 | 31 | let x = { 32 | "key": 0, 33 | "keyTwo": 1, 34 | }; 35 | 36 | let x = { 37 | ...x, 38 | "key": 0, 39 | }; 40 | 41 | let x = { 42 | ...x, 43 | "key": 0, 44 | "keyTwo": 1, 45 | }; 46 | 47 | type t = {. "x": int }; 48 | 49 | type t('a) = {.. "x": int } as 'a; 50 | 51 | type t = {. "x": (int, int) }; 52 | 53 | type t('a) = {.. "x": (int, int) } as 'a; 54 | -------------------------------------------------------------------------------- /test/bigarraySyntax.t/input.re: -------------------------------------------------------------------------------- 1 | /* https://github.com/facebook/reason/issues/2038 */ 2 | let my_big_array1 = 3 | Bigarray.Array1.create(Bigarray.float32, Bigarray.c_layout, 20); 4 | 5 | my_big_array1.{1}; 6 | 7 | my_big_array1.{1} = 1.0; 8 | 9 | let my_big_array2 = 10 | Bigarray.Array2.create(Bigarray.float32, Bigarray.c_layout, 20, 20); 11 | 12 | my_big_array2.{1, 2}; 13 | 14 | my_big_array2.{1, 2} = 1.0; 15 | 16 | let my_big_array3 = 17 | Bigarray.Array3.create(Bigarray.float32, Bigarray.c_layout, 20, 20, 20); 18 | 19 | my_big_array3.{1, 2, 3}; 20 | 21 | my_big_array3.{1, 2, 3} = 1.0; 22 | 23 | let reallyLongStringThatWillDefinitelyBreakLine = 0; 24 | 25 | my_big_array3.{reallyLongStringThatWillDefinitelyBreakLine, reallyLongStringThatWillDefinitelyBreakLine, reallyLongStringThatWillDefinitelyBreakLine}; 26 | 27 | my_big_array3.{reallyLongStringThatWillDefinitelyBreakLine, reallyLongStringThatWillDefinitelyBreakLine, reallyLongStringThatWillDefinitelyBreakLine} = 3.0; 28 | -------------------------------------------------------------------------------- /test/class.t/input.re: -------------------------------------------------------------------------------- 1 | class aClass1(x) { 2 | /* one value parameter x */ 3 | pub a1 = 0; 4 | pub a2() = 0; 5 | pub a3(x,y) = x + y; 6 | pub a4(x,y) { 7 | let result = x + y; 8 | print_endline(" x + y = " ++ string_of_int(x) ++ " + " ++ string_of_int(y) ++ " = " ++ string_of_int(result)); 9 | result 10 | }; 11 | }; 12 | class aClass2(x) { 13 | }; 14 | class aClass3(x: (int => int)) { 15 | }; 16 | class aClass4(x: (int => int => int)) { 17 | }; 18 | class aClass5(x: (int => (int => int))) { 19 | }; 20 | class aClass6(x: ((int => int) => int)) { 21 | }; 22 | class aClass7(x: ((int, int) => int)) { 23 | }; 24 | 25 | class labeledClass1(~x) { 26 | }; 27 | class labeledClass2(~x: ((~y:int) => int)) { 28 | }; 29 | class labeledClass3(~x: ((~y:int) => int => int)) { 30 | }; 31 | class labeledClass4(~x: ((~y:int) => (int => int))) { 32 | }; 33 | class labeledClass5(~x: (((~y:int) => int) => int)) { 34 | }; 35 | class labeledClass6(~x: ((~y:(int, int)) => int)) { 36 | }; 37 | -------------------------------------------------------------------------------- /esy.lock/opam/lwt_react.1.2.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | 3 | synopsis: "Helpers for using React with Lwt" 4 | license: "MIT" 5 | homepage: "https://github.com/ocsigen/lwt" 6 | doc: "https://ocsigen.org/lwt/dev/api/Lwt_react" 7 | bug-reports: "https://github.com/ocsigen/lwt/issues" 8 | 9 | authors: [ 10 | "Jérémie Dimino" 11 | ] 12 | maintainer: [ 13 | "Anton Bachin " 14 | ] 15 | dev-repo: "git+https://github.com/ocsigen/lwt.git" 16 | 17 | depends: [ 18 | "dune" {>= "1.8.0"} 19 | "lwt" {>= "3.0.0"} 20 | "ocaml" {>= "4.08"} 21 | "react" {>= "1.0.0"} 22 | "cppo" {build & >= "1.1.0"} 23 | ] 24 | 25 | build: [ 26 | ["dune" "build" "-p" name "-j" jobs] 27 | ] 28 | url { 29 | src: "https://github.com/ocsigen/lwt/archive/5.6.0.tar.gz" 30 | checksum: [ 31 | "md5=e63979ee40a80d5b9e9e5545f33323b4" 32 | "sha512=d616389bc9e0da11f25843ab7541ac2d40c9543700a89455f14115b339bbe58cef2b8acf0ae97fd54e15a4cb93149cfe1ebfda301aa93933045f76b7d9344160" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /test/extension-exprs.t/run.t: -------------------------------------------------------------------------------- 1 | 2 | Format extensions 3 | $ refmt ./input.re 4 | /* Extension with pexp_apply */ 5 | 6 | [%defer cleanup()]; 7 | 8 | /* Extension with comment with pexp_apply */ 9 | 10 | [%defer 11 | /* 2. comment attached to expr in extension */ 12 | cleanup() 13 | ]; 14 | 15 | /* Let sequence + extension with pexp_apply */ 16 | 17 | let () = { 18 | /* random let binding */ 19 | let x = 1; 20 | /* 1. comment attached to extension */ 21 | [%defer cleanup()]; 22 | /* 3. comment attached to next expr */ 23 | something_else(); 24 | }; 25 | 26 | /* Let sequence + extension with comment with pexp_apply */ 27 | 28 | let () = { 29 | /* random let binding */ 30 | let x = 1; 31 | /* 1. comment attached to extension */ 32 | [%defer 33 | /* 2. comment attached to expr in extension */ 34 | cleanup() 35 | ]; 36 | /* 3. comment attached to next expr */ 37 | something_else(); 38 | }; 39 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/lwt_react.1.2.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | 3 | synopsis: "Helpers for using React with Lwt" 4 | license: "MIT" 5 | homepage: "https://github.com/ocsigen/lwt" 6 | doc: "https://ocsigen.org/lwt/dev/api/Lwt_react" 7 | bug-reports: "https://github.com/ocsigen/lwt/issues" 8 | 9 | authors: [ 10 | "Jérémie Dimino" 11 | ] 12 | maintainer: [ 13 | "Anton Bachin " 14 | ] 15 | dev-repo: "git+https://github.com/ocsigen/lwt.git" 16 | 17 | depends: [ 18 | "dune" {>= "1.8.0"} 19 | "lwt" {>= "3.0.0"} 20 | "ocaml" {>= "4.08"} 21 | "react" {>= "1.0.0"} 22 | "cppo" {build & >= "1.1.0"} 23 | ] 24 | 25 | build: [ 26 | ["dune" "build" "-p" name "-j" jobs] 27 | ] 28 | url { 29 | src: "https://github.com/ocsigen/lwt/archive/5.6.0.tar.gz" 30 | checksum: [ 31 | "md5=e63979ee40a80d5b9e9e5545f33323b4" 32 | "sha512=d616389bc9e0da11f25843ab7541ac2d40c9543700a89455f14115b339bbe58cef2b8acf0ae97fd54e15a4cb93149cfe1ebfda301aa93933045f76b7d9344160" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /test/uchar-esc.t/run.t: -------------------------------------------------------------------------------- 1 | Test uchar escape lexing 2 | 3 | $ refmt ./input.re 4 | let x = "\u{1F42B}"; 5 | let y = "\u{0}"; 6 | let y = "\u{00}"; 7 | let y = "\u{000}"; 8 | let y = "\u{000000}"; 9 | let y = "\u{0000E9}"; 10 | let y = "\u{10FFFF}"; 11 | 12 | let x = "\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}"; 13 | let () = Format.eprintf("x: %s@.", x); 14 | 15 | // in a comment 16 | /* "\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}\u{1F42B}" */ 17 | 18 | check internal translation 19 | 20 | $ ocamlc -dsource -pp 'refmt --print binary' -intf-suffix .rei -impl input.re -o test 21 | let x = "\240\159\144\171" 22 | let y = "\000" 23 | let y = "\000" 24 | let y = "\000" 25 | let y = "\000" 26 | let y = "\195\169" 27 | let y = "\244\143\191\191" 28 | let x = 29 | "\240\159\144\171\240\159\144\171\240\159\144\171\240\159\144\171\240\159\144\171\240\159\144\171" 30 | let () = Format.eprintf "x: %s@." x 31 | 32 | $ ./test 33 | x: 🐫🐫🐫🐫🐫🐫 34 | -------------------------------------------------------------------------------- /test/raw-identifiers.t/run.t: -------------------------------------------------------------------------------- 1 | Test raw identifiers in Reason syntax 2 | 3 | $ refmt ./input.re | tee input2.re 4 | let \#let = 2; 5 | let \#let = \#let 6 | and \#and = \#let; 7 | 8 | /* labeled arguments */ 9 | let \#let = (~\#let) => { 10 | \#let; 11 | }; 12 | 13 | let \#let = (~\#let: \#let=\#let) => { 14 | \#let; 15 | }; 16 | 17 | /* Types */ 18 | type \#type = \#type; 19 | 20 | module type \#module = \#module; 21 | 22 | class \#class = class \#class; 23 | 24 | class type \#class = \#class; 25 | 26 | type x = [ | `\#module]; 27 | type y = [ \#module]; 28 | let x = `\#module; 29 | 30 | external \#external: unit => unit = "external"; 31 | 32 | type \#rec = { 33 | \#type, 34 | \#module: module_, 35 | }; 36 | 37 | let \#rec = { 38 | \#type, 39 | \#module: module_, 40 | }; 41 | 42 | let true = x => x; 43 | 44 | let \#true = x => x; 45 | 46 | Check idempotency 47 | 48 | $ refmt ./input2.re > out.re 49 | 50 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/menhir.20230608/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | "Yann Régis-Gianas " 7 | ] 8 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 9 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 10 | bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" 11 | license: "GPL-2.0-only" 12 | build: [ 13 | ["dune" "build" "-p" name "-j" jobs] 14 | ] 15 | depends: [ 16 | "ocaml" {>= "4.03.0"} 17 | "dune" {>= "2.8.0"} 18 | "menhirLib" {= version} 19 | "menhirSdk" {= version} 20 | ] 21 | synopsis: "An LR(1) parser generator" 22 | url { 23 | src: 24 | "https://gitlab.inria.fr/fpottier/menhir/-/archive/20230608/archive.tar.gz" 25 | checksum: [ 26 | "md5=8ff26b1e3685c472b7b3aba2fe938a43" 27 | "sha512=334b9dcb1283a28b8547082a89536b1d439ff588290b8eaecdf4802c5f74dbc8d16ad6fc6c0820036183518d83e2cc273a75787a8b41137424c8e7ee82e2b50a" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /esy.lock/opam/menhirCST.20240715/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | ] 7 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 8 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 9 | bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" 10 | license: "LGPL-2.0-only WITH OCaml-LGPL-linking-exception" 11 | build: [ 12 | ["dune" "build" "-p" name "-j" jobs] 13 | ] 14 | depends: [ 15 | "ocaml" { >= "4.08" } 16 | "dune" { >= "2.8.0" } 17 | ] 18 | conflicts: [ 19 | "menhir" { != version } 20 | ] 21 | synopsis: "Runtime support library for parsers generated by Menhir" 22 | url { 23 | src: 24 | "https://gitlab.inria.fr/fpottier/menhir/-/archive/20240715/archive.tar.gz" 25 | checksum: [ 26 | "md5=d39a8943fe1be28199e5ec1f4133504c" 27 | "sha512=4f933cfc9026f5f2ffda9b0e626862560a233c35ecf097d179edd926d9009bdf46b6611294aea02b63c34427348568f37376a033fbe8cf98a7746fa6f1354dbd" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/reason-parser/reason_attributes.mli: -------------------------------------------------------------------------------- 1 | open Ppxlib 2 | 3 | type attributesPartition = 4 | { arityAttrs : attributes 5 | ; docAttrs : attributes 6 | ; stdAttrs : attributes 7 | ; jsxAttrs : attributes 8 | ; stylisticAttrs : attributes 9 | ; uncurried : bool 10 | } 11 | (** Kinds of attributes *) 12 | 13 | val partitionAttributes : 14 | ?partDoc:bool 15 | -> ?allowUncurry:bool 16 | -> attribute list 17 | -> attributesPartition 18 | (** Partition attributes into kinds *) 19 | 20 | val extract_raw_literal : attribute list -> label option * attribute list 21 | 22 | val maybe_remove_stylistic_attrs : 23 | attribute list 24 | -> should_preserve:bool 25 | -> attribute list 26 | 27 | val without_stylistic_attrs : attribute list -> attribute list 28 | val has_open_notation_attr : attribute list -> bool 29 | val has_jsx_attributes : attribute list -> bool 30 | val has_preserve_braces_attrs : attribute list -> bool 31 | val has_quoted_extension_attrs : attribute list -> bool 32 | val extractStdAttrs : attribute list -> attributes 33 | -------------------------------------------------------------------------------- /esy.lock/opam/menhir.20240715/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | "Yann Régis-Gianas " 7 | ] 8 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 9 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 10 | bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" 11 | license: "GPL-2.0-only" 12 | build: [ 13 | ["dune" "build" "-p" name "-j" jobs] 14 | ] 15 | depends: [ 16 | "ocaml" {>= "4.03.0"} 17 | "dune" {>= "2.8.0"} 18 | "menhirLib" {= version} 19 | "menhirSdk" {= version} 20 | "menhirCST" {= version} 21 | ] 22 | synopsis: "An LR(1) parser generator" 23 | url { 24 | src: 25 | "https://gitlab.inria.fr/fpottier/menhir/-/archive/20240715/archive.tar.gz" 26 | checksum: [ 27 | "md5=d39a8943fe1be28199e5ec1f4133504c" 28 | "sha512=4f933cfc9026f5f2ffda9b0e626862560a233c35ecf097d179edd926d9009bdf46b6611294aea02b63c34427348568f37376a033fbe8cf98a7746fa6f1354dbd" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Nix Flake for ReasonML"; 3 | 4 | inputs.nixpkgs.url = "github:nix-ocaml/nix-overlays"; 5 | 6 | outputs = { self, nixpkgs }: 7 | let 8 | forAllSystems = f: nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (system: 9 | let 10 | pkgs = nixpkgs.legacyPackages.${system}.extend (self: super: { 11 | ocamlPackages = super.ocaml-ng.ocamlPackages_5_4; 12 | }); 13 | in 14 | f pkgs); 15 | in 16 | { 17 | packages = forAllSystems (pkgs: 18 | let packages = pkgs.callPackage ./nix { }; in 19 | { inherit packages; default = packages.reason; } 20 | ); 21 | 22 | devShells = forAllSystems (pkgs: { 23 | default = pkgs.callPackage ./nix/shell.nix { 24 | reason = self.packages.${pkgs.system}.default; 25 | }; 26 | release = pkgs.callPackage ./nix/shell.nix { 27 | reason = self.packages.${pkgs.system}.default; 28 | release-mode = true; 29 | }; 30 | }); 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /rtop.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "3.17.2" 4 | synopsis: "Reason toplevel" 5 | description: 6 | "rtop is the toplevel (or REPL) for Reason, based on utop (https://github.com/ocaml-community/utop)." 7 | maintainer: [ 8 | "Jordan Walke " 9 | "Antonio Nuno Monteiro " 10 | ] 11 | authors: ["Jordan Walke "] 12 | license: "MIT" 13 | homepage: "https://reasonml.github.io/" 14 | bug-reports: "https://github.com/reasonml/reason/issues" 15 | depends: [ 16 | "dune" {>= "3.18"} 17 | "ocaml" {>= "4.08" & < "5.5"} 18 | "reason" {= version} 19 | "utop" {>= "2.0"} 20 | "cppo" 21 | "odoc" {with-doc} 22 | ] 23 | build: [ 24 | ["dune" "subst"] {dev} 25 | [ 26 | "dune" 27 | "build" 28 | "-p" 29 | name 30 | "-j" 31 | jobs 32 | "@install" 33 | "@runtest" {with-test} 34 | "@doc" {with-doc} 35 | ] 36 | ] 37 | dev-repo: "git+https://github.com/reasonml/reason.git" 38 | x-maintenance-intent: ["(latest)"] 39 | -------------------------------------------------------------------------------- /test/letop.t/input.re: -------------------------------------------------------------------------------- 1 | let (let.opt) = (x, f) => switch x { | None => None | Some(x) => f(x) }; 2 | let (let.&opt) = (x, f) => switch x { | None => None | Some(x) => Some(f(x)) }; 3 | 4 | let z = { 5 | let.opt a = Some(2); 6 | let.&opt b = Some(5); 7 | a + b 8 | } 9 | 10 | let (let./\/) = (x, f) => switch x { | None => None | Some(x) => f(x) }; 11 | let (let.&/\*) = (x, f) => switch x { | None => None | Some(x) => Some(f(x)) }; 12 | 13 | /* Test syntax that could potentially conflict with comments */ 14 | let z = { 15 | let./\/ a = Some(2); 16 | let.&/\* b = Some(5); 17 | a + b 18 | } 19 | 20 | let _ = { 21 | let.opt _ = Some("a"); 22 | 23 | let.opt _ = Some("c"); 24 | 25 | // hello 26 | 27 | None; 28 | }; 29 | 30 | // test that the type annotation prints with parenthesis 31 | let _ = { 32 | let.opt (x : string) as _y = Some ("a"); 33 | None 34 | }; 35 | 36 | let x = { 37 | [@foo] 38 | let.opt _ = Some("foo"); 39 | None 40 | }; 41 | 42 | let x = { 43 | /** 44 | * A doc comment 45 | */ 46 | let.opt _ = Some("foo"); 47 | None 48 | }; 49 | -------------------------------------------------------------------------------- /test/bigarray.t/run.t: -------------------------------------------------------------------------------- 1 | Format bigarray 2 | $ refmt ./input.re 3 | my_big_array3.{ 4 | reallyLongStringThatWillDefinitelyBreakLine 5 | }; 6 | 7 | my_big_array3.{ 8 | reallyLongStringThatWillDefinitelyBreakLine, 9 | reallyLongStringThatWillDefinitelyBreakLine 10 | }; 11 | 12 | my_big_array3.{ 13 | reallyLongStringThatWillDefinitelyBreakLine, 14 | reallyLongStringThatWillDefinitelyBreakLine, 15 | reallyLongStringThatWillDefinitelyBreakLine 16 | }; 17 | 18 | my_big_array3.{ 19 | reallyLongString, 20 | reallyLongString, 21 | reallyLongString, 22 | reallyLongString, 23 | reallyLongString 24 | }; 25 | 26 | my_big_array3.{ 27 | reallyLongStringThatWillDefinitelyBreakLine 28 | } = 3.0; 29 | 30 | my_big_array3.{ 31 | reallyLongStringThatWillDefinitelyBreakLine, 32 | reallyLongStringThatWillDefinitelyBreakLine 33 | } = 3.0; 34 | 35 | my_big_array3.{ 36 | reallyLongString, 37 | reallyLongString, 38 | reallyLongString, 39 | reallyLongString, 40 | reallyLongString 41 | } = 3.0; 42 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/sexplib0.v0.16.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Jane Street developers" 3 | authors: ["Jane Street Group, LLC"] 4 | homepage: "https://github.com/janestreet/sexplib0" 5 | bug-reports: "https://github.com/janestreet/sexplib0/issues" 6 | dev-repo: "git+https://github.com/janestreet/sexplib0.git" 7 | doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/sexplib0/index.html" 8 | license: "MIT" 9 | build: [ 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "ocaml" {>= "4.08.0"} 14 | "dune" {>= "2.0.0"} 15 | ] 16 | synopsis: "Library containing the definition of S-expressions and some base converters" 17 | description: " 18 | Part of Jane Street's Core library 19 | The Core suite of libraries is an industrial strength alternative to 20 | OCaml's standard library that was developed by Jane Street, the 21 | largest industrial user of OCaml. 22 | " 23 | url { 24 | src: "https://ocaml.janestreet.com/ocaml-core/v0.16/files/sexplib0-v0.16.0.tar.gz" 25 | checksum: "sha256=86dba26468194512f789f2fb709063515a9cb4e5c4461c021c239a369590701d" 26 | } 27 | -------------------------------------------------------------------------------- /esy.lock/opam/menhirLib.20240715/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | "Yann Régis-Gianas " 7 | ] 8 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 9 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 10 | bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" 11 | license: "LGPL-2.0-only WITH OCaml-LGPL-linking-exception" 12 | build: [ 13 | ["dune" "build" "-p" name "-j" jobs] 14 | ] 15 | depends: [ 16 | "ocaml" { >= "4.03.0" } 17 | "dune" { >= "2.8.0" } 18 | ] 19 | conflicts: [ 20 | "menhir" { != version } 21 | ] 22 | synopsis: "Runtime support library for parsers generated by Menhir" 23 | url { 24 | src: 25 | "https://gitlab.inria.fr/fpottier/menhir/-/archive/20240715/archive.tar.gz" 26 | checksum: [ 27 | "md5=d39a8943fe1be28199e5ec1f4133504c" 28 | "sha512=4f933cfc9026f5f2ffda9b0e626862560a233c35ecf097d179edd926d9009bdf46b6611294aea02b63c34427348568f37376a033fbe8cf98a7746fa6f1354dbd" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /esy.lock/opam/menhirSdk.20240715/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | "Yann Régis-Gianas " 7 | ] 8 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 9 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 10 | bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" 11 | license: "LGPL-2.0-only WITH OCaml-LGPL-linking-exception" 12 | build: [ 13 | ["dune" "build" "-p" name "-j" jobs] 14 | ] 15 | depends: [ 16 | "ocaml" { >= "4.03.0" } 17 | "dune" { >= "2.8.0" } 18 | ] 19 | conflicts: [ 20 | "menhir" { != version } 21 | ] 22 | synopsis: "Compile-time library for auxiliary tools related to Menhir" 23 | url { 24 | src: 25 | "https://gitlab.inria.fr/fpottier/menhir/-/archive/20240715/archive.tar.gz" 26 | checksum: [ 27 | "md5=d39a8943fe1be28199e5ec1f4133504c" 28 | "sha512=4f933cfc9026f5f2ffda9b0e626862560a233c35ecf097d179edd926d9009bdf46b6611294aea02b63c34427348568f37376a033fbe8cf98a7746fa6f1354dbd" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/menhirLib.20230608/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | "Yann Régis-Gianas " 7 | ] 8 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 9 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 10 | bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" 11 | license: "LGPL-2.0-only with OCaml-LGPL-linking-exception" 12 | build: [ 13 | ["dune" "build" "-p" name "-j" jobs] 14 | ] 15 | depends: [ 16 | "ocaml" { >= "4.03.0" } 17 | "dune" { >= "2.8.0" } 18 | ] 19 | conflicts: [ 20 | "menhir" { != version } 21 | ] 22 | synopsis: "Runtime support library for parsers generated by Menhir" 23 | url { 24 | src: 25 | "https://gitlab.inria.fr/fpottier/menhir/-/archive/20230608/archive.tar.gz" 26 | checksum: [ 27 | "md5=8ff26b1e3685c472b7b3aba2fe938a43" 28 | "sha512=334b9dcb1283a28b8547082a89536b1d439ff588290b8eaecdf4802c5f74dbc8d16ad6fc6c0820036183518d83e2cc273a75787a8b41137424c8e7ee82e2b50a" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/menhirSdk.20230608/opam: -------------------------------------------------------------------------------- 1 | 2 | opam-version: "2.0" 3 | maintainer: "francois.pottier@inria.fr" 4 | authors: [ 5 | "François Pottier " 6 | "Yann Régis-Gianas " 7 | ] 8 | homepage: "http://gitlab.inria.fr/fpottier/menhir" 9 | dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" 10 | bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" 11 | license: "LGPL-2.0-only with OCaml-LGPL-linking-exception" 12 | build: [ 13 | ["dune" "build" "-p" name "-j" jobs] 14 | ] 15 | depends: [ 16 | "ocaml" { >= "4.03.0" } 17 | "dune" { >= "2.8.0" } 18 | ] 19 | conflicts: [ 20 | "menhir" { != version } 21 | ] 22 | synopsis: "Compile-time library for auxiliary tools related to Menhir" 23 | url { 24 | src: 25 | "https://gitlab.inria.fr/fpottier/menhir/-/archive/20230608/archive.tar.gz" 26 | checksum: [ 27 | "md5=8ff26b1e3685c472b7b3aba2fe938a43" 28 | "sha512=334b9dcb1283a28b8547082a89536b1d439ff588290b8eaecdf4802c5f74dbc8d16ad6fc6c0820036183518d83e2cc273a75787a8b41137424c8e7ee82e2b50a" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /PLAN: -------------------------------------------------------------------------------- 1 | Fix error recovery & error reporting 2 | 3 | Step 1: remove existing implementation 4 | 5 | OK * Put reason parser in its own file 6 | OK * Remove menhir error management: 7 | OK - remove "error" token 8 | OK - remove error messages infrastructure 9 | OK Now message defaults to "Syntax error" 10 | * Fix reported error location (when recovering or not) 11 | 12 | Step 2: reintroduce recovery 13 | * Preprocess grammar: 14 | - check exhaustivity of recovery 15 | - produce a mapping of automaton states to automaton-items suitable for 16 | recovery 17 | * Instrument parser: 18 | - first, always complete the AST and drop user input (":'(") 19 | - second, introduce an heuristic for recovering based on location 20 | 21 | Step 3: reintroduce error messages 22 | * Ask the crowd: 23 | What should messages look like? 24 | Which situations are tricky or counter-intuitive? 25 | * Make a testsuite representative of common syntax errors 26 | * ... Design an analysis sufficient to produce the messages automatically 27 | :P 28 | -------------------------------------------------------------------------------- /src/vendored-omp/Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of the migrate-parsetree package. It is released under the 2 | # terms of the LGPL 2.1 license (see LICENSE file). 3 | # Copyright 2017 Frédéric Bour 4 | # 2017 Jérémie Dimino 5 | 6 | INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),) 7 | 8 | .PHONY: all 9 | all: 10 | dune build @install 11 | 12 | .PHONY: install 13 | install: 14 | dune install $(INSTALL_ARGS) 15 | 16 | .PHONY: uninstall 17 | uninstall: 18 | dune uninstall $(INSTALL_ARGS) 19 | 20 | .PHONY: reinstall 21 | reinstall: 22 | $(MAKE) uninstall 23 | $(MAKE) install 24 | 25 | .PHONY: test 26 | test: 27 | dune runtest 28 | 29 | .PHONY: all-supported-ocaml-versions 30 | all-supported-ocaml-versions: 31 | dune runtest --workspace dune-workspace.dev 32 | 33 | .PHONY: cinaps 34 | cinaps: 35 | cinaps -styler ocp-indent -i src/migrate_parsetree_versions.ml* 36 | cinaps -styler ocp-indent -i src/migrate_parsetree_4??_4??.ml* 37 | cinaps -styler ocp-indent -i src/migrate_parsetree.ml 38 | 39 | .PHONY: clean 40 | clean: 41 | rm -rf _build *.install 42 | find . -name .merlin -delete 43 | -------------------------------------------------------------------------------- /test/externals.t/input.re: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests external formatting. 3 | */ 4 | external foo : type_ = "%caml_something_or_other"; 5 | 6 | external multilineStringExtern : int => int = {| 7 | Did you know you can put whatver you want inside 8 | of an extern? Good luck with the linker though! 9 | |}; 10 | 11 | module Nested = { 12 | external multilineStringExtern : int => int = {| 13 | Did you know you can put whatver you want inside 14 | of an extern? Good luck with the linker though! 15 | |}; 16 | external multilineStringExternWithTag : int => int = {js| 17 | Did you know you can put whatver you want inside 18 | of an extern? Good luck with the linker though! 19 | |js}; 20 | external multilineStringExtern : int => int = " 21 | And this has a newline in it, so will be formatted with { | | } style string"; 22 | external containsQuote : int => int = "This has a quote in it \" so will be formatted as { | | } style string"; 23 | external noIndentation : int => int = {| 24 | Did you know you can put whatver you want inside 25 | of an extern? Good luck with the linker though! 26 | |}; 27 | }; 28 | -------------------------------------------------------------------------------- /test/generics.t/run.t: -------------------------------------------------------------------------------- 1 | Format features from OCaml 4.03 2 | $ refmt ./input.re 3 | type t = 4 | | A({a: int}) 5 | | B; 6 | 7 | let f = 8 | fun 9 | | B => 0 10 | | A({ a }) => a; 11 | 12 | type nonrec u('a) = 13 | | Box('a); 14 | 15 | type expr('a) = 16 | | Val({value: 'a}): expr('a) 17 | | Add({ 18 | left: expr(int), 19 | right: expr(int), 20 | }) 21 | : expr(int) 22 | | Is0({test: expr(int)}): expr(bool) 23 | | If({ 24 | pred: expr(bool), 25 | true_branch: expr('a), 26 | false_branch: expr('a), 27 | }) 28 | : expr('a); 29 | 30 | let rec eval: type a. expr(a) => a = e => 31 | switch (e) { 32 | | Is0({ test }) => eval(test) == 0 33 | | Val({ value }) => value 34 | | Add({ left, right }) => 35 | eval(left) + eval(right) 36 | | If({ pred, true_branch, false_branch }) => 37 | if (eval(pred)) { 38 | eval(true_branch); 39 | } else { 40 | eval(false_branch); 41 | } 42 | }; 43 | 44 | type hlist = 45 | | []: hlist; 46 | 47 | let foo = (type a, type b) => 5; 48 | -------------------------------------------------------------------------------- /src/menhir-recover/recovery_custom.mli: -------------------------------------------------------------------------------- 1 | module type RECOVERY = sig 2 | module G : MenhirSdk.Cmly_api.GRAMMAR 3 | 4 | type item = G.lr1 * G.production * int 5 | 6 | type recovery = 7 | { prefix : int 8 | ; cases : (G.lr1 option * item list) list 9 | } 10 | (** [prefix] is the size of the known prefix of the stack. It means that in 11 | the kernel of current state, there is an item whose dot is at position 12 | [prefix]. (we know the incoming symbols for these stack frames and we can 13 | enumerate the possible state numbers). 14 | 15 | [cases] is a mapping that associates to each possible state found at 16 | stack.[-prefix] (or None if the stack is empty) a list of reductions to 17 | execute. 18 | 19 | The actual list of actions to reduce an item [(state, prod, pos)] is given 20 | by [Synthesizer.solution (Trail (state, prod, pos))] *) 21 | 22 | val recover : G.lr1 -> recovery 23 | val report : Format.formatter -> unit 24 | end 25 | 26 | module Recover 27 | (G : MenhirSdk.Cmly_api.GRAMMAR) 28 | (_ : Synthesis.SYNTHESIZER with module G := G) : RECOVERY with module G := G 29 | -------------------------------------------------------------------------------- /test/arityConversion.t/input.ml: -------------------------------------------------------------------------------- 1 | Some (1, 2, 3) 2 | 3 | type bcd = TupleConstructor of (int * int) | MultiArgumentsConstructor of int * int 4 | 5 | let a = TupleConstructor(1, 2) 6 | let b = MultiArgumentsConstructor(1, 2) 7 | 8 | module Test = struct 9 | type a = | And of (int * int) | Or of (int * int) 10 | end;; 11 | 12 | let _ = Test.And (1, 2) 13 | let _ = Test.Or (1, 2) 14 | let _ = Some 1;; 15 | 16 | Test.And (1, 2);; 17 | Test.Or (1, 2);; 18 | Some 1;; 19 | 20 | module M = struct 21 | type t = TupleConstructorInModule of (int * int) 22 | type t2 = TupleConstructor2 of (int * int) 23 | type t3 = TupleConstructor3 of (int * int) 24 | end 25 | 26 | type t2 = TupleConstructor2 of (int * int) 27 | type t3 = TupleConstructor3 of (int * int) 28 | 29 | let _ = M.TupleConstructorInModule (1,2) 30 | 31 | let _ = M.TupleConstructor2 (1,2) 32 | let _ = TupleConstructor2 (1,2) 33 | 34 | let _ = M.TupleConstructor3 (1,2) 35 | let _ = TupleConstructor3 (1,2);; 36 | 37 | M.TupleConstructorInModule (1,2);; 38 | 39 | M.TupleConstructor2 (1,2);; 40 | TupleConstructor2 (1,2);; 41 | 42 | M.TupleConstructor3 (1,2);; 43 | TupleConstructor3 (1,2);; 44 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2015-present, Facebook, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/dot-merlin-reader.4.9/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "defree@gmail.com" 3 | authors: "The Merlin team" 4 | synopsis: "Reads config files for merlin" 5 | homepage: "https://github.com/ocaml/merlin" 6 | bug-reports: "https://github.com/ocaml/merlin/issues" 7 | dev-repo: "git+https://github.com/ocaml/merlin.git" 8 | license: "MIT" 9 | build: [ 10 | ["dune" "subst"] {dev} 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ] 13 | depends: [ 14 | "ocaml" {>= "4.08" & < "6.0"} 15 | "dune" {>= "2.9.0"} 16 | "merlin-lib" {>= "4.9"} 17 | "ocamlfind" {>= "1.6.0"} 18 | ] 19 | description: 20 | "Helper process: reads .merlin files and outputs the normalized content to 21 | stdout." 22 | url { 23 | src: 24 | "https://github.com/ocaml/merlin/releases/download/v4.9-414/merlin-4.9-414.tbz" 25 | checksum: [ 26 | "sha256=e23fc47813591269ff9d27c820988e520a662c89dd0af7ea652b21517499cbfd" 27 | "sha512=2199f963368597d10cc197e41ebb883f6a166018c9da3fe259c354550df41b713781003598a2fe5956b0a4ae96f8c07ba33831d3cf6f9d494b731944f87e491e" 28 | ] 29 | } 30 | x-commit-hash: "df75a4550704c113ac29505fd68ef9b7893d4bf5" 31 | -------------------------------------------------------------------------------- /src/refmt/printer_maker.mli: -------------------------------------------------------------------------------- 1 | open Reason 2 | 3 | type 'a parser_result = 4 | { ast : 'a 5 | ; comments : Reason_comment.t list 6 | ; parsed_as_ml : bool 7 | ; parsed_as_intf : bool 8 | } 9 | 10 | type parse_itype = 11 | [ `ML 12 | | `Reason 13 | | `Binary 14 | | `BinaryReason 15 | | `Auto 16 | ] 17 | 18 | type print_itype = 19 | [ `ML 20 | | `Reason 21 | | `Binary 22 | | `BinaryReason 23 | | `AST 24 | | `None 25 | ] 26 | 27 | exception Invalid_config of string 28 | 29 | module type PRINTER = sig 30 | type t 31 | 32 | val parse : 33 | use_stdin:bool 34 | -> parse_itype 35 | -> string 36 | -> (t * Reason_comment.t list) * bool 37 | 38 | val print : 39 | print_itype 40 | -> string 41 | -> bool 42 | -> out_channel 43 | -> Format.formatter 44 | -> t * Reason_comment.t list 45 | -> unit 46 | end 47 | 48 | val err : string -> 'a 49 | val ocamlBinaryParser : bool -> string -> 'a parser_result 50 | val reasonBinaryParser : bool -> string -> 'a parser_result 51 | val prepare_output_file : string option -> out_channel 52 | val close_output_file : string option -> out_channel -> unit 53 | -------------------------------------------------------------------------------- /src/refmt/README.md: -------------------------------------------------------------------------------- 1 | # Reason (For Native Compilers) 2 | 3 | Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems. 4 | 5 | This package provides support for using Reason with native OCaml compilers. 6 | 7 | [![Build Status](https://dev.azure.com/reasonml/reason/_apis/build/status/facebook.reason?branchName=master)](https://dev.azure.com/reasonml/reason/_build/latest?definitionId=2?branchName=master) [![Build Status](https://travis-ci.org/facebook/reason.svg?branch=master)](https://travis-ci.org/facebook/reason) [![CircleCI](https://circleci.com/gh/facebook/reason/tree/master.svg?style=svg)](https://circleci.com/gh/facebook/reason/tree/master) 8 | 9 | ## [Native Quick Start With Esy](https://reasonml.github.io/docs/en/quickstart-ocaml) 10 | 11 | ## [Community](https://reasonml.github.io/docs/en/community.html) 12 | 13 | ## [Roadmap & Contribution](https://reasonml.github.io/docs/en/roadmap) 14 | 15 | ### Documentations 16 | 17 | Go to https://github.com/reasonml/reasonml.github.io to contribute to the Reason documentation. 18 | 19 | ### Contributing 20 | 21 | See the [docs folder's `GETTING_STARTED_CONTRIBUTING.md`](../docs/GETTING_STARTED_CONTRIBUTING.md). 22 | -------------------------------------------------------------------------------- /src/vendored-omp/src/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name reason_omp) 3 | (public_name reason.ocaml-migrate-parsetree) 4 | (wrapped true) 5 | (libraries ppxlib.astlib) 6 | (modules :standard \ migrate_parsetree_driver_main) 7 | (preprocess 8 | (action 9 | (run %{exe:../tools/pp.exe} %{read:ast-version} %{input-file}))) 10 | ; (ppx.driver 11 | ; (main Migrate_parsetree.Driver.run_main) 12 | ; (flags --dump-ast) 13 | ; (lint_flags --null)) 14 | ) 15 | 16 | (rule 17 | (targets caml_format_doc.ml) 18 | (deps caml_format_doc.cppo.ml) 19 | (action 20 | (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) 21 | 22 | ; Not needed for reason repo (vendored) 23 | ; (library 24 | ; (name reason.migrate_parsetree_driver_main) 25 | ; (public_name reason.ocaml-migrate-parsetree.driver-main) 26 | ; (modules reason.migrate_parsetree_driver_main) 27 | ; (library_flags -linkall) 28 | ; (libraries reason_migrate_parsetree)) 29 | 30 | (rule 31 | (copy# compiler-functions/%{read:compiler-functions-file} 32 | migrate_parsetree_compiler_functions.ml)) 33 | 34 | (rule 35 | (targets ast-version compiler-functions-file) 36 | (action 37 | (run %{ocaml} %{dep:config/gen.ml} %{ocaml_version}))) 38 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_409_410.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_409_410_migrate 17 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_410_411.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_410_411_migrate 17 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_500_414.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_500_414_migrate 17 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_51_500.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_51_500_migrate 17 | -------------------------------------------------------------------------------- /test/knownReIssues.t/run.t: -------------------------------------------------------------------------------- 1 | Format basic 2 | $ refmt --print re ./input.re > ./formatted.re 3 | 4 | Print the formatted file 5 | $ cat ./formatted.re 6 | /** 7 | Issue 940: https://github.com/facebook/reason/issues/940 8 | The parens in the exception match case with an alias, 9 | are required for correct parsing: 10 | i.e. (Sys_error _ as exc) instead of Sys_error _ as exc 11 | The latter doesn't type-check with Error: Unbound value exc. 12 | Warning 11 (unused match case) is also triggered. 13 | */ 14 | let f = () => raise(Sys_error("error")); 15 | 16 | switch (f()) { 17 | | x => () 18 | | exception (Sys_error(_) as exc) => raise(exc) 19 | }; 20 | 21 | exception Foo(string); 22 | 23 | let g = () => raise(Foo("bar errors")); 24 | 25 | switch (g()) { 26 | | x => () 27 | | exception (Foo(f)) => raise(Foo(f)) 28 | }; 29 | 30 | Type-check basics 31 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 32 | 33 | Format the formatted file back 34 | $ refmt --print re ./formatted.re > ./formatted_back.re 35 | 36 | Ensure idempotency: first format and second format are the same 37 | $ diff formatted.re formatted_back.re 38 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_402_403.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_402_403_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_403_402.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_403_402_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_403_404.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_403_404_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_404_403.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_404_403_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_404_405.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_404_405_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_405_404.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_405_404_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_405_406.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_405_406_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_406_405.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_406_405_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_406_407.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_406_407_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_407_406.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_407_406_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_407_408.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_407_408_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_408_407.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_408_407_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_408_409.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_408_409_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_409_408.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_409_408_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_410_409.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_410_409_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_411_410.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_411_410_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_411_412.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_411_412_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_412_411.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_412_411_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_412_413.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_412_413_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_413_412.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_413_412_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_413_414.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_413_414_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_414_413.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_414_413_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_414_500.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_414_500_migrate 17 | 18 | -------------------------------------------------------------------------------- /src/vendored-omp/src/migrate_parsetree_500_51.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml Migrate Parsetree *) 4 | (* *) 5 | (* Frédéric Bour *) 6 | (* *) 7 | (* Copyright 2017 Institut National de Recherche en Informatique et *) 8 | (* en Automatique (INRIA). *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | include Migrate_parsetree_500_51_migrate 17 | 18 | -------------------------------------------------------------------------------- /esy.lock/opam/sexplib0.v0.17.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Jane Street developers" 3 | authors: ["Jane Street Group, LLC"] 4 | homepage: "https://github.com/janestreet/sexplib0" 5 | bug-reports: "https://github.com/janestreet/sexplib0/issues" 6 | dev-repo: "git+https://github.com/janestreet/sexplib0.git" 7 | doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/sexplib0/index.html" 8 | license: "MIT" 9 | build: [ 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "ocaml" {>= "4.14.0"} 14 | "dune" {>= "3.11.0"} 15 | ] 16 | available: arch != "x86_32" 17 | synopsis: "Library containing the definition of S-expressions and some base converters" 18 | description: " 19 | Part of Jane Street's Core library 20 | The Core suite of libraries is an industrial strength alternative to 21 | OCaml's standard library that was developed by Jane Street, the 22 | largest industrial user of OCaml. 23 | " 24 | url { 25 | src: 26 | "https://github.com/janestreet/sexplib0/archive/refs/tags/v0.17.0.tar.gz" 27 | checksum: [ 28 | "md5=abafe8fd1d6302e55a315f4d78960d2a" 29 | "sha512=ad387e40789fe70a11473db7e85fe017b801592624414e9030730b2e92ea08f98095fb6e9236430f33c801605ebee0a2a6284e0f618a26a7da4599d4fd9d395d" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.8_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < findlib.patch' : 'true'}" 7 | ], 8 | [ 9 | "./configure", 10 | "-bindir", 11 | "#{self.bin}", 12 | "-sitelib", 13 | "#{self.lib}", 14 | "-mandir", 15 | "#{self.man}", 16 | "-config", 17 | "#{self.lib}/findlib.conf", 18 | "-no-custom", 19 | "-no-topfind" 20 | ], 21 | [ 22 | "make", 23 | "all" 24 | ], 25 | [ 26 | "make", 27 | "opt" 28 | ] 29 | ], 30 | "install": [ 31 | [ 32 | "make", 33 | "install" 34 | ], 35 | [ 36 | "install", 37 | "-m", 38 | "0755", 39 | "ocaml-stub", 40 | "#{self.bin}/ocaml" 41 | ], 42 | [ 43 | "mkdir", 44 | "-p", 45 | "#{self.toplevel}" 46 | ], 47 | [ 48 | "install", 49 | "-m", 50 | "0644", 51 | "src/findlib/topfind", 52 | "#{self.toplevel}/topfind" 53 | ] 54 | ], 55 | "exportedEnv": { 56 | "OCAML_TOPLEVEL_PATH": { 57 | "val": "#{self.toplevel}", 58 | "scope": "global" 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /test/knownMlIssues.t/input.ml: -------------------------------------------------------------------------------- 1 | (* [x] fixed *) 2 | type t2 = 3 | int * int (* attributed to entire type not binding *) 4 | 5 | type color = 6 | | Red of int (* After red *) 7 | | Black of int (* After black *) 8 | | Green of int (* Does not remain here *) 9 | 10 | 11 | let blahCurriedX x = 12 | function 13 | | Red 10 14 | | Black 20 15 | | Green 10 -> 1 (* After or pattern green *) 16 | | Red x -> 0 (* After red *) 17 | | Black x -> 0 (* After black *) 18 | | Green x -> 0 (* After second green *) 19 | (* On next line after blahCurriedX def *) 20 | 21 | 22 | (* EOL comments wrap because other elements break first (in this example 23 | "mutable" causes breaks. We either need: 24 | 1. To prevent wrapping of anything inside of eol comments attachments. 25 | 2. Losslessly wrap eol comments. 26 | *) 27 | (* This example illustrates the above issue, but isn't een idempotent due to the issue. *) 28 | (* type cfg = { *) 29 | (* node_id : int ref; *) 30 | (* node_list : int list ref; *) 31 | (* name_pdesc_tbl : (int, (int, int) Hashtbl.t) Hashtbl.t; (** Map proc name to procdesc *) *) 32 | (* mutable priority_set : (int, int) Hashtbl.t (** set of function names to be analyzed first *) *) 33 | (* } *) 34 | (* *) 35 | (* *) 36 | -------------------------------------------------------------------------------- /rtop.esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": [ 3 | [ 4 | "bash", 5 | "-c", 6 | "#{os == 'windows' ? 'patch -p1 < findlib.patch' : 'true'}" 7 | ], 8 | [ 9 | "./configure", 10 | "-bindir", 11 | "#{self.bin}", 12 | "-sitelib", 13 | "#{self.lib}", 14 | "-mandir", 15 | "#{self.man}", 16 | "-config", 17 | "#{self.lib}/findlib.conf", 18 | "-no-custom", 19 | "-no-topfind" 20 | ], 21 | [ 22 | "make", 23 | "all" 24 | ], 25 | [ 26 | "make", 27 | "opt" 28 | ] 29 | ], 30 | "install": [ 31 | [ 32 | "make", 33 | "install" 34 | ], 35 | [ 36 | "install", 37 | "-m", 38 | "0755", 39 | "ocaml-stub", 40 | "#{self.bin}/ocaml" 41 | ], 42 | [ 43 | "mkdir", 44 | "-p", 45 | "#{self.toplevel}" 46 | ], 47 | [ 48 | "install", 49 | "-m", 50 | "0644", 51 | "src/findlib/topfind", 52 | "#{self.toplevel}/topfind" 53 | ] 54 | ], 55 | "exportedEnv": { 56 | "OCAML_TOPLEVEL_PATH": { 57 | "val": "#{self.toplevel}", 58 | "scope": "global" 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "inputs": { 5 | "nixpkgs": "nixpkgs_2" 6 | }, 7 | "locked": { 8 | "lastModified": 1762719030, 9 | "narHash": "sha256-n5Qk1rJX1z3BEPRO/HgLX4qnK3Wmv+37UgJwxwdFSqg=", 10 | "owner": "nix-ocaml", 11 | "repo": "nix-overlays", 12 | "rev": "c788fc60538f0b633d4c70778c2c463dbb48f01c", 13 | "type": "github" 14 | }, 15 | "original": { 16 | "owner": "nix-ocaml", 17 | "repo": "nix-overlays", 18 | "type": "github" 19 | } 20 | }, 21 | "nixpkgs_2": { 22 | "locked": { 23 | "lastModified": 1762659928, 24 | "narHash": "sha256-EJPiL5r7EIhU/eaI7Hz0VcBP3FwpKMstcIuhXRNjxxo=", 25 | "owner": "NixOS", 26 | "repo": "nixpkgs", 27 | "rev": "00e0caf5d5daab6f1b6135c4882fd8ef6c340243", 28 | "type": "github" 29 | }, 30 | "original": { 31 | "owner": "NixOS", 32 | "repo": "nixpkgs", 33 | "rev": "00e0caf5d5daab6f1b6135c4882fd8ef6c340243", 34 | "type": "github" 35 | } 36 | }, 37 | "root": { 38 | "inputs": { 39 | "nixpkgs": "nixpkgs" 40 | } 41 | } 42 | }, 43 | "root": "root", 44 | "version": 7 45 | } 46 | -------------------------------------------------------------------------------- /test/externals.t/run.t: -------------------------------------------------------------------------------- 1 | Format externals 2 | $ refmt ./input.re 3 | /** 4 | * Tests external formatting. 5 | */ 6 | external foo: type_ = "%caml_something_or_other"; 7 | 8 | external multilineStringExtern: int => int = 9 | {| 10 | Did you know you can put whatver you want inside 11 | of an extern? Good luck with the linker though! 12 | |}; 13 | 14 | module Nested = { 15 | external multilineStringExtern: int => int = 16 | {| 17 | Did you know you can put whatver you want inside 18 | of an extern? Good luck with the linker though! 19 | |}; 20 | external multilineStringExternWithTag: 21 | int => int = 22 | {| 23 | Did you know you can put whatver you want inside 24 | of an extern? Good luck with the linker though! 25 | |}; 26 | external multilineStringExtern: int => int = 27 | {| 28 | And this has a newline in it, so will be formatted with { | | } style string|}; 29 | external containsQuote: int => int = 30 | {|This has a quote in it " so will be formatted as { | | } style string|}; 31 | external noIndentation: int => int = 32 | {| 33 | Did you know you can put whatver you want inside 34 | of an extern? Good luck with the linker though! 35 | |}; 36 | }; 37 | -------------------------------------------------------------------------------- /nix/ci.nix: -------------------------------------------------------------------------------- 1 | { ocamlVersion }: 2 | 3 | let 4 | lock = builtins.fromJSON (builtins.readFile ./../flake.lock); 5 | pkgs = 6 | let 7 | src = fetchGit { 8 | url = with lock.nodes.nixpkgs.locked;"https://github.com/${owner}/${repo}"; 9 | inherit (lock.nodes.nixpkgs.locked) rev; 10 | allRefs = true; 11 | }; 12 | in 13 | import src { 14 | extraOverlays = [ 15 | (self: super: { 16 | ocamlPackages = super.ocaml-ng."ocamlPackages_${ocamlVersion}".overrideScope (oself: osuper: { 17 | pp = osuper.pp.overrideAttrs (_: { 18 | doCheck = false; 19 | }); 20 | ppxlib = osuper.ppxlib.overrideAttrs (_: { 21 | src = 22 | if super.lib.versionOlder "5.4" osuper.ocaml.version then 23 | osuper.ppxlib.src 24 | else 25 | builtins.fetchurl { 26 | url = "https://github.com/ocaml-ppx/ppxlib/releases/download/0.36.0/ppxlib-0.36.0.tbz"; 27 | sha256 = "0d54j19vi1khzmw0ffngs8xzjjq07n20q49h85hhhcf52k71pfjs"; 28 | }; 29 | }); 30 | }); 31 | }) 32 | ]; 33 | }; 34 | in 35 | 36 | pkgs.callPackage ./. { doCheck = true; } 37 | -------------------------------------------------------------------------------- /test/object.t/input.re: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 2 | 3 | type t = {.}; 4 | 5 | type t = { 6 | . 7 | u: int, 8 | v: int 9 | }; 10 | 11 | type t = {.. u: int}; 12 | 13 | type t = {.. u: int}; 14 | 15 | type t = { 16 | .. 17 | }; 18 | 19 | type t = {..}; 20 | 21 | let (<..>)(a,b) = a + b; 22 | let five = 2 <..> 3; 23 | 24 | type closedObjSugar = Js.t({. foo: bar, baz: int}); 25 | 26 | type openObjSugar = Js.t({.. x: int, y: int}); 27 | 28 | type x = Js.t({.}); 29 | 30 | type y = Js.t({..}); 31 | 32 | /* #1595: always break object rows (>= 2) for readability */ 33 | type o = { 34 | . 35 | a: int, 36 | b: int 37 | }; 38 | 39 | type o2 = { 40 | .. 41 | a: int, 42 | b: int 43 | }; 44 | 45 | let obj = {as _; [@foo] val a = 1}; 46 | 47 | /* Oinherit (https://github.com/ocaml/ocaml/pull/1118) */ 48 | type t1 = { 49 | . 50 | n: string, 51 | ...t, 52 | }; 53 | 54 | type t1 = { 55 | .. 56 | n: string, 57 | ...t, 58 | }; 59 | 60 | type g1 = { 61 | . 62 | n: string, 63 | ...t, 64 | ...y, 65 | }; 66 | 67 | type g2 = { 68 | . 69 | n: string, 70 | ...t, 71 | ...y, 72 | }; 73 | 74 | type m1 = { 75 | . 76 | ...M.t, 77 | }; 78 | type m2('a) = { 79 | . 80 | n: string, 81 | ...M.t('a), 82 | }; 83 | -------------------------------------------------------------------------------- /esy.lock/opam/merlin-extend.0.6.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Frederic Bour " 3 | authors: "Frederic Bour " 4 | homepage: "https://github.com/let-def/merlin-extend" 5 | bug-reports: "https://github.com/let-def/merlin-extend" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/let-def/merlin-extend.git" 8 | build: [ 9 | ["dune" "subst"] {dev} 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "dune" {>= "1.0"} 14 | "cppo" {build & >= "1.1.0"} 15 | "ocaml" {>= "4.02.3"} 16 | ] 17 | synopsis: "A protocol to provide custom frontend to Merlin" 18 | description: """ 19 | This protocol allows to replace the OCaml frontend of Merlin. 20 | It extends what used to be done with the `-pp' flag to handle a few more cases.""" 21 | doc: "https://let-def.github.io/merlin-extend" 22 | url { 23 | src: 24 | "https://github.com/let-def/merlin-extend/releases/download/v0.6.2/merlin-extend-0.6.2.tbz" 25 | checksum: [ 26 | "sha256=47558e7f30b64462f2b9c82fb7f787133acfa0d5132452b6ad7848e0b0f4d779" 27 | "sha512=50696cb2099b84d4a5497fb778c969ca446e5639a91bcde6e2177588fbf72fe4f7a3c27b62384292ad873291719c5893673f1acce4755e81b5e05f9fd3e45b65" 28 | ] 29 | } 30 | x-commit-hash: "098988ee19502645cf039b41027ec4f5e89197ab" 31 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/merlin-extend.0.6.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Frederic Bour " 3 | authors: "Frederic Bour " 4 | homepage: "https://github.com/let-def/merlin-extend" 5 | bug-reports: "https://github.com/let-def/merlin-extend" 6 | license: "MIT" 7 | dev-repo: "git+https://github.com/let-def/merlin-extend.git" 8 | build: [ 9 | ["dune" "subst"] {dev} 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "dune" {>= "1.0"} 14 | "cppo" {build & >= "1.1.0"} 15 | "ocaml" {>= "4.02.3"} 16 | ] 17 | synopsis: "A protocol to provide custom frontend to Merlin" 18 | description: """ 19 | This protocol allows to replace the OCaml frontend of Merlin. 20 | It extends what used to be done with the `-pp' flag to handle a few more cases.""" 21 | doc: "https://let-def.github.io/merlin-extend" 22 | url { 23 | src: 24 | "https://github.com/let-def/merlin-extend/releases/download/v0.6.1/merlin-extend-0.6.1.tbz" 25 | checksum: [ 26 | "sha256=5ec84b355ddb2d129a5948b132bfacc93adcbde2158c7de695f7bfc3650bead7" 27 | "sha512=631fc96aab2f35e12a078c9b4907ca7b0db9f1e3a4026040e6c23b82e0171c256a89fb5d4c887f1d156eb9e3152783cdf7a546b2496051007a1bcf5777417396" 28 | ] 29 | } 30 | x-commit-hash: "cf2707bbe8e034c6ecf5d0fecd3fd889f6ab14bf" 31 | -------------------------------------------------------------------------------- /reason.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "3.17.2" 4 | synopsis: "Reason: Syntax & Toolchain for OCaml" 5 | description: """ 6 | Reason gives OCaml a new syntax that is remniscient of languages like 7 | JavaScript. It's also the umbrella project for a set of tools for the OCaml & 8 | JavaScript ecosystem.""" 9 | maintainer: [ 10 | "Jordan Walke " 11 | "Antonio Nuno Monteiro " 12 | ] 13 | authors: ["Jordan Walke "] 14 | license: "MIT" 15 | homepage: "https://reasonml.github.io/" 16 | bug-reports: "https://github.com/reasonml/reason/issues" 17 | depends: [ 18 | "dune" {>= "3.18"} 19 | "ocaml" {>= "4.08" & < "5.5"} 20 | "ocamlfind" {build} 21 | "cmdliner" {>= "1.1.0"} 22 | "dune-build-info" {>= "2.9.3"} 23 | "menhir" {>= "20180523"} 24 | "merlin-extend" {>= "0.6.2"} 25 | "fix" 26 | "cppo" 27 | "ppxlib" {>= "0.36"} 28 | "odoc" {with-doc} 29 | ] 30 | build: [ 31 | ["dune" "subst"] {dev} 32 | [ 33 | "dune" 34 | "build" 35 | "-p" 36 | name 37 | "-j" 38 | jobs 39 | "@install" 40 | "@runtest" {with-test} 41 | "@doc" {with-doc} 42 | ] 43 | ] 44 | dev-repo: "git+https://github.com/reasonml/reason.git" 45 | x-maintenance-intent: ["(latest)"] 46 | -------------------------------------------------------------------------------- /test/mutation.t/input.re: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ 2 | 3 | /** 4 | * Testing mutations. 5 | */ 6 | let holdsAUnit = ref(); 7 | 8 | let holdsABool = ref(false); 9 | 10 | let holdsAnInt = ref(0); 11 | 12 | let holdsAHoldsABool = ref(ref(true)); 13 | 14 | let () = holdsAUnit := holdsABool := false; 15 | 16 | /* Should be parsed as: */ 17 | /* And so they should both be printed the same */ 18 | let () = holdsAUnit := (holdsABool := false); 19 | 20 | /* 21 | * The following: 22 | * 23 | * something = x := e 24 | * 25 | * Should be parsed as: 26 | * 27 | * something = (x := e) 28 | */ 29 | holdsAUnit.contents = holdsAnInt := 0; 30 | 31 | holdsABool.contents = holdsAnInt.contents == 100; 32 | 33 | let numberToSwitchOn = 100; 34 | 35 | switch (numberToSwitchOn) { 36 | | -3 37 | | -2 38 | | -1 => () 39 | | 0 => holdsAUnit.contents = () 40 | | 1 => holdsAUnit.contents = holdsAnInt := 0 41 | | 2 => true ? holdsAUnit.contents = () : holdsABool.contents ? () : () 42 | | 3 => true ? holdsAUnit := () : holdsABool.contents ? () : () 43 | | 4 => true ? holdsAnInt := 40 : () 44 | | 5 => holdsAnInt := 40 45 | | _ => () 46 | }; 47 | 48 | let mutativeFunction = fun | Some(x) => holdsAUnit.contents = () 49 | | None => holdsAUnit := (); 50 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/uchar.0.0.2/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["Daniel Bünzli "] 4 | homepage: "http://ocaml.org" 5 | doc: "https://ocaml.github.io/uchar/" 6 | dev-repo: "git+https://github.com/ocaml/uchar.git" 7 | bug-reports: "https://github.com/ocaml/uchar/issues" 8 | tags: [ "text" "character" "unicode" "compatibility" "org:ocaml.org" ] 9 | license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" 10 | depends: [ 11 | "ocaml" {>= "3.12.0"} 12 | "ocamlbuild" {build} 13 | ] 14 | build: [ 15 | ["ocaml" "pkg/git.ml"] 16 | [ 17 | "ocaml" 18 | "pkg/build.ml" 19 | "native=%{ocaml:native}%" 20 | "native-dynlink=%{ocaml:native-dynlink}%" 21 | ] 22 | ] 23 | synopsis: "Compatibility library for OCaml's Uchar module" 24 | description: """ 25 | The `uchar` package provides a compatibility library for the 26 | [`Uchar`][1] module introduced in OCaml 4.03. 27 | 28 | The `uchar` package is distributed under the license of the OCaml 29 | compiler. See [LICENSE](LICENSE) for details. 30 | 31 | [1]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Uchar.html""" 32 | url { 33 | src: 34 | "https://github.com/ocaml/uchar/releases/download/v0.0.2/uchar-0.0.2.tbz" 35 | checksum: "md5=c9ba2c738d264c420c642f7bb1cf4a36" 36 | } 37 | -------------------------------------------------------------------------------- /src/reason-parser/reason_comment.ml: -------------------------------------------------------------------------------- 1 | type category = 2 | | EndOfLine 3 | | SingleLine 4 | | Regular 5 | 6 | type t = 7 | { location : Location.t 8 | ; category : category 9 | ; text : string 10 | } 11 | 12 | let category t = t.category 13 | let location t = t.location 14 | 15 | let wrap t = 16 | match t.text with 17 | | "" | "*" -> "/***/" 18 | | txt when Reason_syntax_util.isLineComment txt -> 19 | "//" 20 | (* single line comments of the form `// comment` have a `\n` at the end *) 21 | ^ String.sub txt ~pos:0 ~len:(String.length txt - 1) 22 | ^ Reason_syntax_util.EOLMarker.string 23 | | txt when txt.[0] = '*' && txt.[1] <> '*' -> 24 | (* CHECK: this comment printing seems fishy. 25 | * It apply to invalid docstrings. 26 | * In this case, it will add a spurious '*'. 27 | * E.g. /** 28 | * * bla */ 29 | * In an invalid context is turned into 30 | * /*** 31 | * * bla */ 32 | * I think this case should be removed. 33 | *) 34 | "/**" ^ txt ^ "*/" 35 | | txt -> "/*" ^ txt ^ "*/" 36 | 37 | let make ~location category text = { text; category; location } 38 | 39 | let isLineComment { category; text; _ } = 40 | match category with 41 | | SingleLine -> Reason_syntax_util.isLineComment text 42 | | EndOfLine | Regular -> false 43 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/xdg.3.11.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "XDG Base Directory Specification" 3 | description: 4 | "https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html" 5 | maintainer: ["Jane Street Group, LLC "] 6 | authors: ["Jane Street Group, LLC "] 7 | license: "MIT" 8 | homepage: "https://github.com/ocaml/dune" 9 | doc: "https://dune.readthedocs.io/" 10 | bug-reports: "https://github.com/ocaml/dune/issues" 11 | depends: [ 12 | "dune" {>= "3.5"} 13 | "ocaml" {>= "4.08"} 14 | "odoc" {with-doc} 15 | ] 16 | dev-repo: "git+https://github.com/ocaml/dune.git" 17 | build: [ 18 | ["dune" "subst"] {dev} 19 | ["rm" "-rf" "vendor/csexp"] 20 | ["rm" "-rf" "vendor/pp"] 21 | [ 22 | "dune" 23 | "build" 24 | "-p" 25 | name 26 | "-j" 27 | jobs 28 | "@install" 29 | "@doc" {with-doc} 30 | ] 31 | ] 32 | url { 33 | src: 34 | "https://github.com/ocaml/dune/releases/download/3.11.1/dune-3.11.1.tbz" 35 | checksum: [ 36 | "sha256=866f2307adadaf7604f3bf9d98bb4098792baa046953a6726c96c40fc5ed3f71" 37 | "sha512=c888153b204a16bcfed2636de776bbd5f9ca84484e716cc1e9ef3ba3c904e9dd15a2609ae943cddb6097912623ec54618c58386d6730ff742d746850400fb3cc" 38 | ] 39 | } 40 | x-commit-hash: "7cbb0e7277c6cacd1ccf7941cac5a03c25fc63cf" 41 | -------------------------------------------------------------------------------- /esy.lock/opam/stdlib-shims.0.3.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "The stdlib-shims programmers" 3 | authors: "The stdlib-shims programmers" 4 | homepage: "https://github.com/ocaml/stdlib-shims" 5 | doc: "https://ocaml.github.io/stdlib-shims/" 6 | dev-repo: "git+https://github.com/ocaml/stdlib-shims.git" 7 | bug-reports: "https://github.com/ocaml/stdlib-shims/issues" 8 | tags: ["stdlib" "compatibility" "org:ocaml"] 9 | license: ["LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] 10 | depends: [ 11 | "dune" 12 | "ocaml" {>= "4.02.3"} 13 | ] 14 | build: [ "dune" "build" "-p" name "-j" jobs ] 15 | synopsis: "Backport some of the new stdlib features to older compiler" 16 | description: """ 17 | Backport some of the new stdlib features to older compiler, 18 | such as the Stdlib module. 19 | 20 | This allows projects that require compatibility with older compiler to 21 | use these new features in their code. 22 | """ 23 | x-commit-hash: "fb6815e5d745f07fd567c11671149de6ef2e74c8" 24 | url { 25 | src: 26 | "https://github.com/ocaml/stdlib-shims/releases/download/0.3.0/stdlib-shims-0.3.0.tbz" 27 | checksum: [ 28 | "sha256=babf72d3917b86f707885f0c5528e36c63fccb698f4b46cf2bab5c7ccdd6d84a" 29 | "sha512=1151d7edc8923516e9a36995a3f8938d323aaade759ad349ed15d6d8501db61ffbe63277e97c4d86149cf371306ac23df0f581ec7e02611f58335126e1870980" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/stdlib-shims.0.3.0/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "The stdlib-shims programmers" 3 | authors: "The stdlib-shims programmers" 4 | homepage: "https://github.com/ocaml/stdlib-shims" 5 | doc: "https://ocaml.github.io/stdlib-shims/" 6 | dev-repo: "git+https://github.com/ocaml/stdlib-shims.git" 7 | bug-reports: "https://github.com/ocaml/stdlib-shims/issues" 8 | tags: ["stdlib" "compatibility" "org:ocaml"] 9 | license: ["LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] 10 | depends: [ 11 | "dune" 12 | "ocaml" {>= "4.02.3"} 13 | ] 14 | build: [ "dune" "build" "-p" name "-j" jobs ] 15 | synopsis: "Backport some of the new stdlib features to older compiler" 16 | description: """ 17 | Backport some of the new stdlib features to older compiler, 18 | such as the Stdlib module. 19 | 20 | This allows projects that require compatibility with older compiler to 21 | use these new features in their code. 22 | """ 23 | x-commit-hash: "fb6815e5d745f07fd567c11671149de6ef2e74c8" 24 | url { 25 | src: 26 | "https://github.com/ocaml/stdlib-shims/releases/download/0.3.0/stdlib-shims-0.3.0.tbz" 27 | checksum: [ 28 | "sha256=babf72d3917b86f707885f0c5528e36c63fccb698f4b46cf2bab5c7ccdd6d84a" 29 | "sha512=1151d7edc8923516e9a36995a3f8938d323aaade759ad349ed15d6d8501db61ffbe63277e97c4d86149cf371306ac23df0f581ec7e02611f58335126e1870980" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /esy.lock/opam/xdg.3.19.1/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "XDG Base Directory Specification" 3 | description: 4 | "https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html" 5 | maintainer: ["Jane Street Group, LLC "] 6 | authors: ["Jane Street Group, LLC "] 7 | license: "MIT" 8 | homepage: "https://github.com/ocaml/dune" 9 | doc: "https://dune.readthedocs.io/" 10 | bug-reports: "https://github.com/ocaml/dune/issues" 11 | depends: [ 12 | "dune" {>= "3.18"} 13 | "ocaml" {>= "4.08"} 14 | "odoc" {with-doc} 15 | ] 16 | dev-repo: "git+https://github.com/ocaml/dune.git" 17 | x-maintenance-intent: ["(latest)"] 18 | build: [ 19 | ["dune" "subst"] {dev} 20 | ["rm" "-rf" "vendor/csexp"] 21 | ["rm" "-rf" "vendor/pp"] 22 | [ 23 | "dune" 24 | "build" 25 | "-p" 26 | name 27 | "-j" 28 | jobs 29 | "@install" 30 | "@doc" {with-doc} 31 | ] 32 | ] 33 | url { 34 | src: 35 | "https://github.com/ocaml/dune/releases/download/3.19.1/dune-3.19.1.tbz" 36 | checksum: [ 37 | "sha256=a10386f980cda9417d1465466bed50dd2aef9c93b9d06a0f7feeedb0a1541158" 38 | "sha512=d1622939713133a1f28617229896298d6ef194c48a47d011e4b752490fc83893cc920a8395d7ac60bc384a6c9b233ebf0665f38f74f2774a983e9d3b241a7746" 39 | ] 40 | } 41 | x-commit-hash: "76c0c3941798f81dcc13a305d7abb120c191f5fa" 42 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/merlin-lib.4.12-501/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "defree@gmail.com" 3 | authors: "The Merlin team" 4 | homepage: "https://github.com/ocaml/merlin" 5 | bug-reports: "https://github.com/ocaml/merlin/issues" 6 | dev-repo: "git+https://github.com/ocaml/merlin.git" 7 | license: "MIT" 8 | build: [ 9 | ["dune" "subst"] {dev} 10 | ["dune" "build" "-p" name "-j" jobs] 11 | ] 12 | depends: [ 13 | "ocaml" {>= "5.1" & < "5.2"} 14 | "dune" {>= "2.9.0"} 15 | "csexp" {>= "1.5.1"} 16 | "menhir" {dev & >= "20201216"} 17 | "menhirLib" {dev & >= "20201216"} 18 | "menhirSdk" {dev & >= "20201216"} 19 | ] 20 | synopsis: 21 | "Merlin's libraries" 22 | description: 23 | "These libraries provides access to low-level compiler interfaces and the 24 | standard higher-level merlin protocol. The library is provided as-is, is not 25 | thoroughly documented, and its public API might break with any new release." 26 | url { 27 | src: 28 | "https://github.com/ocaml/merlin/releases/download/v4.12-501/merlin-4.12-501.tbz" 29 | checksum: [ 30 | "sha256=cccc33235497403590f4f68a2f8a3727a265463984b3b9645ebc1abb2f9088c0" 31 | "sha512=95ece87b42316824cc5c847bada2bb1f2131a2b75b00a79d561f1ff801d107146df6d2732cf340d5000a0de373a03d09714a35f75b0ec1e6ab869b2cdaf065e8" 32 | ] 33 | } 34 | x-commit-hash: "fcc3157ab0b2ecccf6ac530d8add326fdbf9fb1c" 35 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "OCaml compiler libraries repackaged" 3 | description: """ 4 | This packages exposes the OCaml compiler libraries repackages under 5 | the toplevel names Ocaml_common, Ocaml_bytecomp, Ocaml_optcomp, ...""" 6 | maintainer: ["Jane Street developers"] 7 | authors: ["Jane Street Group, LLC"] 8 | license: "MIT" 9 | homepage: "https://github.com/janestreet/ocaml-compiler-libs" 10 | bug-reports: "https://github.com/janestreet/ocaml-compiler-libs/issues" 11 | depends: [ 12 | "dune" {>= "2.8"} 13 | "ocaml" {>= "4.04.1"} 14 | "odoc" {with-doc} 15 | ] 16 | build: [ 17 | ["dune" "subst"] {dev} 18 | [ 19 | "dune" 20 | "build" 21 | "-p" 22 | name 23 | "-j" 24 | jobs 25 | "@install" 26 | "@runtest" {with-test} 27 | "@doc" {with-doc} 28 | ] 29 | ] 30 | dev-repo: "git+https://github.com/janestreet/ocaml-compiler-libs.git" 31 | url { 32 | src: 33 | "https://github.com/janestreet/ocaml-compiler-libs/releases/download/v0.12.4/ocaml-compiler-libs-v0.12.4.tbz" 34 | checksum: [ 35 | "sha256=4ec9c9ec35cc45c18c7a143761154ef1d7663036a29297f80381f47981a07760" 36 | "sha512=978dba8dfa61f98fa24fda7a9c26c2e837081f37d1685fe636dc19cfc3278a940cf01a10293504b185c406706bc1008bc54313d50f023bcdea6d5ac6c0788b35" 37 | ] 38 | } 39 | x-commit-hash: "8cd12f18bb7171c2b67d661868c4271fae528d93" 40 | -------------------------------------------------------------------------------- /esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "OCaml compiler libraries repackaged" 3 | description: """ 4 | This packages exposes the OCaml compiler libraries repackages under 5 | the toplevel names Ocaml_common, Ocaml_bytecomp, Ocaml_optcomp, ...""" 6 | maintainer: ["Jane Street developers"] 7 | authors: ["Jane Street Group, LLC"] 8 | license: "MIT" 9 | homepage: "https://github.com/janestreet/ocaml-compiler-libs" 10 | bug-reports: "https://github.com/janestreet/ocaml-compiler-libs/issues" 11 | depends: [ 12 | "dune" {>= "2.8"} 13 | "ocaml" {>= "4.04.1" & < "5.2.0"} 14 | "odoc" {with-doc} 15 | ] 16 | build: [ 17 | ["dune" "subst"] {dev} 18 | [ 19 | "dune" 20 | "build" 21 | "-p" 22 | name 23 | "-j" 24 | jobs 25 | "@install" 26 | "@runtest" {with-test} 27 | "@doc" {with-doc} 28 | ] 29 | ] 30 | dev-repo: "git+https://github.com/janestreet/ocaml-compiler-libs.git" 31 | url { 32 | src: 33 | "https://github.com/janestreet/ocaml-compiler-libs/releases/download/v0.12.4/ocaml-compiler-libs-v0.12.4.tbz" 34 | checksum: [ 35 | "sha256=4ec9c9ec35cc45c18c7a143761154ef1d7663036a29297f80381f47981a07760" 36 | "sha512=978dba8dfa61f98fa24fda7a9c26c2e837081f37d1685fe636dc19cfc3278a940cf01a10293504b185c406706bc1008bc54313d50f023bcdea6d5ac6c0788b35" 37 | ] 38 | } 39 | x-commit-hash: "8cd12f18bb7171c2b67d661868c4271fae528d93" 40 | -------------------------------------------------------------------------------- /test/4.06/attributes.t: -------------------------------------------------------------------------------- 1 | $ cat > input.re < /* Pexp_letexception with attributes */ 3 | > let () = { 4 | > [@attribute] exception E; 5 | > raise(E) 6 | > }; 7 | > 8 | > /** Different payloads **/ 9 | > 10 | > /* Empty signature */ 11 | > 12 | > [@haha: ] 13 | > let x = 5; 14 | > 15 | > /* signature_item */ 16 | > [@haha: let x : option(int)] 17 | > let x = 5; 18 | > 19 | > /* Signature */ 20 | > [@haha: type t; let x : option(t)] 21 | > let x = 5; 22 | > EOF 23 | 24 | Format basic 25 | $ refmt --print re ./input.re > ./formatted.re 26 | 27 | Print the formatted file 28 | $ cat ./formatted.re 29 | /* Pexp_letexception with attributes */ 30 | let () = { 31 | [@attribute] 32 | exception E; 33 | raise(E); 34 | }; 35 | 36 | /** Different payloads **/ 37 | 38 | /* Empty signature */ 39 | 40 | [@haha:] 41 | let x = 5; 42 | 43 | /* signature_item */ 44 | [@haha: let x: option(int)] 45 | let x = 5; 46 | 47 | /* Signature */ 48 | [@haha: type t; let x: option(t)] 49 | let x = 5; 50 | 51 | Type-check basics 52 | $ ocamlc -c -pp 'refmt --print binary' -intf-suffix .rei -impl formatted.re 53 | 54 | Format the formatted file back 55 | $ refmt --print re ./formatted.re > ./formatted_back.re 56 | 57 | Ensure idempotency: first format and second format are the same 58 | $ diff formatted.re formatted_back.re 59 | -------------------------------------------------------------------------------- /esy.lock/opam/fpath.0.7.3/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "Daniel Bünzli " 3 | authors: ["The fpath programmers"] 4 | homepage: "https://erratique.ch/software/fpath" 5 | doc: "https://erratique.ch/software/fpath/doc" 6 | dev-repo: "git+https://erratique.ch/repos/fpath.git" 7 | bug-reports: "https://github.com/dbuenzli/fpath/issues" 8 | tags: [ "file" "system" "path" "org:erratique" ] 9 | license: "ISC" 10 | depends: [ 11 | "ocaml" {>= "4.03.0"} 12 | "ocamlfind" {build} 13 | "ocamlbuild" {build} 14 | "topkg" {build & >= "0.9.0"} 15 | "astring" 16 | ] 17 | build: [[ 18 | "ocaml" "pkg/pkg.ml" "build" 19 | "--dev-pkg=true" {dev} ]] 20 | 21 | synopsis: """File system paths for OCaml""" 22 | description: """\ 23 | 24 | Fpath is an OCaml module for handling file system paths with POSIX or 25 | Windows conventions. Fpath processes paths without accessing the file 26 | system and is independent from any system library. 27 | 28 | Fpath depends on [Astring][astring] and is distributed under the ISC 29 | license. 30 | 31 | [astring]: http://erratique.ch/software/astring 32 | """ 33 | url { 34 | src: "https://erratique.ch/software/fpath/releases/fpath-0.7.3.tbz" 35 | checksum: [ 36 | "sha256=12b08ff192d037d9b6d69e9ca19d1d385184f20b3237c27231e437ac81ace70f" 37 | "md5=0740b530e8fed5b0adc5eee8463cfc2f" 38 | ] 39 | } 40 | 41 | x-maintenance-intent: ["(latest)"] -------------------------------------------------------------------------------- /nix/default.nix: -------------------------------------------------------------------------------- 1 | { lib, ocamlPackages, doCheck ? false }: 2 | 3 | rec { 4 | reason = ocamlPackages.buildDunePackage { 5 | pname = "reason"; 6 | version = "0.0.1-dev"; 7 | 8 | src = 9 | let fs = lib.fileset; in 10 | fs.toSource { 11 | root = ./..; 12 | fileset = fs.unions [ 13 | ../dune-project 14 | ../dune 15 | ../reason.opam 16 | ../scripts 17 | ../src 18 | ../test 19 | ]; 20 | }; 21 | 22 | inherit doCheck; 23 | 24 | nativeBuildInputs = with ocamlPackages; [ cppo menhir ]; 25 | propagatedBuildInputs = with ocamlPackages; [ 26 | cmdliner 27 | merlin-extend 28 | menhirSdk 29 | menhirLib 30 | fix 31 | ppxlib 32 | dune-build-info 33 | ]; 34 | 35 | }; 36 | 37 | rtop = ocamlPackages.buildDunePackage { 38 | pname = "rtop"; 39 | version = "0.0.1-dev"; 40 | 41 | src = 42 | let fs = lib.fileset; in 43 | fs.toSource { 44 | root = ./..; 45 | fileset = fs.unions [ 46 | ../dune-project 47 | ../dune 48 | ../rtop.opam 49 | ../scripts 50 | ../rtop 51 | ../test 52 | ]; 53 | }; 54 | 55 | inherit doCheck; 56 | 57 | nativeBuildInputs = with ocamlPackages; [ cppo ]; 58 | propagatedBuildInputs = [ reason ocamlPackages.utop ]; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /rtop.esy.lock/opam/cppo.1.6.9/opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | synopsis: "Code preprocessor like cpp for OCaml" 3 | description: """\ 4 | Cppo is an equivalent of the C preprocessor for OCaml programs. 5 | It allows the definition of simple macros and file inclusion. 6 | 7 | Cppo is: 8 | 9 | * more OCaml-friendly than cpp 10 | * easy to learn without consulting a manual 11 | * reasonably fast 12 | * simple to install and to maintain""" 13 | maintainer: [ 14 | "Martin Jambon " "Yishuai Li " 15 | ] 16 | authors: "Martin Jambon" 17 | license: "BSD-3-Clause" 18 | homepage: "https://github.com/ocaml-community/cppo" 19 | doc: "https://ocaml-community.github.io/cppo" 20 | bug-reports: "https://github.com/ocaml-community/cppo/issues" 21 | depends: [ 22 | "ocaml" {>= "4.02.3"} 23 | "dune" {>= "1.10"} 24 | "base-unix" 25 | ] 26 | build: [ 27 | ["dune" "subst"] {dev} 28 | ["dune" "build" "-p" name "-j" jobs] 29 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 30 | ["dune" "build" "-p" name "@doc"] {with-doc} 31 | ] 32 | dev-repo: "git+https://github.com/ocaml-community/cppo.git" 33 | url { 34 | src: "https://github.com/ocaml-community/cppo/archive/v1.6.9.tar.gz" 35 | checksum: [ 36 | "md5=d23ffe85ac7dc8f0afd1ddf622770d09" 37 | "sha512=26ff5a7b7f38c460661974b23ca190f0feae3a99f1974e0fd12ccf08745bd7d91b7bc168c70a5385b837bfff9530e0e4e41cf269f23dd8cf16ca658008244b44" 38 | ] 39 | } --------------------------------------------------------------------------------