-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1037c7d
Showing
111 changed files
with
20,729 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.native | ||
reasonfmt_merlin_impl.sh | ||
*.byte | ||
*.docdir | ||
_build | ||
*.install | ||
pkg/META | ||
src_gen/confusables.txt | ||
src_test/_tags | ||
.paths | ||
.settings | ||
.project | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Changelog | ||
========= | ||
|
||
1.0 | ||
--- | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
BSD License | ||
|
||
For Reason software | ||
|
||
Copyright (c) 2015-present, Facebook, Inc. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name Facebook nor the names of its contributors may be used to | ||
endorse or promote products derived from this software without specific | ||
prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Portions Copyright (c) 2015-present, Facebook, Inc. All rights reserved. | ||
build: | ||
cp pkg/META.in pkg/META | ||
ocaml pkg/build.ml native=true native-dynlink=true utop=true | ||
chmod +x $(shell pwd)/_build/src/reasonfmt_merlin_impl.sh | ||
ln -fs $(shell pwd)/_build/src/reasonfmt_merlin_impl.sh reasonfmt_merlin_impl.sh | ||
|
||
install: | ||
opam pin add reason . -y | ||
|
||
run: build | ||
rlwrap ocaml \ | ||
$(shell ocamlfind query -predicates byte,toploop -r -a-format \ | ||
findlib compiler-libs.common unix) \ | ||
_build/src/reason.cma _build/src/reason_toploop.cmo | ||
|
||
run_utop: build | ||
utop \ | ||
$(shell ocamlfind query -predicates byte,toploop -r -a-format \ | ||
compiler-libs.common) \ | ||
_build/src/reason.cma _build/src/reason_utop.cmo | ||
|
||
test: build | ||
cd formatTest; ./test.sh | ||
|
||
clean: | ||
ocamlbuild -clean | ||
|
||
.PHONY: build clean | ||
|
||
VERSION := $$(opam query --version) | ||
NAME_VERSION := $$(opam query --name-version) | ||
ARCHIVE := $$(opam query --archive) | ||
|
||
release: | ||
git tag -a v$(VERSION) -m "Version $(VERSION)." | ||
git push origin v$(VERSION) | ||
opam publish prepare $(NAME_VERSION) $(ARCHIVE) | ||
opam publish submit $(NAME_VERSION) | ||
rm -rf $(NAME_VERSION) | ||
|
||
.PHONY: release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
This repo was forked from [m17n](https://github.com/whitequark/ocaml-m17n), which is licensed under MIT. | ||
|
||
Copyright (c) 2014 Peter Zotov <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
--- | ||
|
||
`./formatTest/` is entirely original content (by @jordwalke/Facebook) | ||
|
||
--- | ||
|
||
`./editorSupport/emacs/reason-mode` was forked from [rust-mode](https://github.com/rust-lang/rust-mode) and is dual licensed under MIT/Apache. We've only made minor changes, and we've added a file `./editorSupport/emacs/reason-mode.el` which was forked from a BSD (w/ non-attribution) licensed project. | ||
|
||
Copyright (c) 2015 The Rust Project Developers | ||
|
||
Permission is hereby granted, free of charge, to any | ||
person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the | ||
Software without restriction, including without | ||
limitation the rights to use, copy, modify, merge, | ||
publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software | ||
is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice | ||
shall be included in all copies or substantial portions | ||
of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF | ||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR | ||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. | ||
|
||
--- | ||
|
||
`./editorSupport/language-reason` was forked from the MIT licensed [Atom-Rust](https://github.com/zargony/atom-language-rust) | ||
|
||
The MIT License (MIT) | ||
===================== | ||
|
||
Copyright © `2013` `Andreas Neuhaus` `http://zargony.com/` | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the “Software”), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
--- | ||
|
||
`./editorSupport/sublime-reason` was forked from the MIT licensed [sublime-rust](https://github.com/jhasse/sublime-rust) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
--- | ||
|
||
`./editorSupport/VimReason` was forked from the dual MIT/Apache licensed [rust.vim](https://github.com/rust-lang/rust.vim) | ||
|
||
Copyright (c) 2015 The Rust Project Developers | ||
|
||
Permission is hereby granted, free of charge, to any | ||
person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the | ||
Software without restriction, including without | ||
limitation the rights to use, copy, modify, merge, | ||
publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software | ||
is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice | ||
shall be included in all copies or substantial portions | ||
of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF | ||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR | ||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. | ||
|
||
--- | ||
|
||
`./editorSupport/NuclideReason` (coming soon) is forked from Facebook's own [Nuclide](https://github.com/facebook/nuclide) (the flow plugin). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Additional Grant of Patent Rights Version 2 | ||
|
||
"Software" means the Reason software distributed by Facebook, Inc. | ||
|
||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software | ||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable | ||
(subject to the termination provision below) license under any Necessary | ||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise | ||
transfer the Software. For avoidance of doubt, no license is granted under | ||
Facebook’s rights in any patent claims that are infringed by (i) modifications | ||
to the Software made by you or any third party or (ii) the Software in | ||
combination with any software or other technology. | ||
|
||
The license granted hereunder will terminate, automatically and without notice, | ||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate | ||
directly or indirectly, or take a direct financial interest in, any Patent | ||
Assertion: (i) against Facebook or any of its subsidiaries or corporate | ||
affiliates, (ii) against any party if such Patent Assertion arises in whole or | ||
in part from any software, technology, product or service of Facebook or any of | ||
its subsidiaries or corporate affiliates, or (iii) against any party relating | ||
to the Software. Notwithstanding the foregoing, if Facebook or any of its | ||
subsidiaries or corporate affiliates files a lawsuit alleging patent | ||
infringement against you in the first instance, and you respond by filing a | ||
patent infringement counterclaim in that lawsuit against that party that is | ||
unrelated to the Software, the license granted hereunder will not terminate | ||
under section (i) of this paragraph due to such counterclaim. | ||
|
||
A "Necessary Claim" is a claim of a patent owned by Facebook that is | ||
necessarily infringed by the Software standing alone. | ||
|
||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, | ||
or contributory infringement or inducement to infringe any patent, including a | ||
cross-claim or counterclaim. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
Reason: Meta Language Utility | ||
========================================= | ||
|
||
- Approachable ES6 style syntax. | ||
- Powerful, automatic source code formatting. | ||
- Adopt Incrementally with straightforward `JavaScript/C` interop. | ||
- Bare metal compilation - *No Virtual Machine*. | ||
- Type inference, pattern matching, immutable by default. | ||
|
||
|
||
Install/Build | ||
---------- | ||
See [ReasonDocs](http://facebook.github.io/Reason/#reason-install) | ||
|
||
Integrating with Existing Languages. | ||
------------------------ | ||
|
||
**`JavaScript` and `CommonJS`**: | ||
|
||
See the [ReasonDocs](http://facebook.github.io/Reason/javaScriptCompared.html) | ||
|
||
|
||
**`clang`/`ocamlc`/`ocamlopt`**: | ||
|
||
Though the easiest way to use `Reason` with `ocamlc/opt` is by running the compiler with the following flags: | ||
```sh | ||
# intf-suffix tells the compiler where to look for corresponding interface files | ||
ocamlopt -pp reasonfmt -intf-suffix rei -impl myFile.re | ||
ocamlopt -pp reasonfmt -intf myFile.rei | ||
``` | ||
|
||
`Reason` can also be activated using `ocamlfind`. | ||
|
||
``` sh | ||
ocamlfind ocamlc -package reason ... | ||
``` | ||
|
||
Convert Your Project to Reason: | ||
------------------------------------------------------------ | ||
`Reason` includes a program `reasonfmt` which will parse and print and | ||
convert various syntaxes. You can specify which syntax to parse, and | ||
which to print via that flags `-parse` and `-print` flags. For example, | ||
you can convert your `ocaml` project to `Reason` by processing each file | ||
with the command `reasonfmt -parse ml -print re yourFile.ml`. Execute | ||
`reasonfmt -help` for more options. | ||
|
||
|
||
Upgrading Existing Source Code After Changing Parse/Printing: | ||
------------------------------------------------------------ | ||
To upgrade existing `Reason` syntax to a new version of the `Reason` parser | ||
you should parse the code in the old version of the parser, and print it with | ||
the new version of the printer. The easiest way to do this is to build the new | ||
version locally, while the old one is pinned globally, but any way that you | ||
have two versions installed locally will work. | ||
|
||
The script `upgradeSyntax.sh` will execute reformattings for the entire | ||
subdirectory repo across two separate builds of `Reason`. It expects you to | ||
supply the path/command to the old build of Reason, the path/command for the | ||
new build of Reason, and the print width (use `110`). For example, if you had | ||
an old version of `Reason` globally pinned as `reasonfmt`, and a local build of | ||
`Reason` at `~/github/Reason/reasonfmt_impl.native`: | ||
|
||
```sh | ||
# Run from whichever directory you want to search | ||
~/github/Reason/upgradeSyntax.sh reasonfmt ~/github/Reason/reasonfmt_impl.native 110 | ||
``` | ||
|
||
Deeper OCaml integration | ||
--------------------------- | ||
|
||
If you are using `ocamlbuild`, add the following to your `_tags` file, but | ||
this likely won't be enough because `ocamlc`/`ocamlopt` will need the | ||
`-intf/-impl/-intf-suffix` flags: | ||
|
||
``` | ||
<**/*.{re,.rei}>: package(reason), syntax(utf8) | ||
``` | ||
|
||
[ReasonDocs](http://facebook.github.io/Reason/index.html#reason-repl) explains how to use | ||
`Reason` with the top level or with `utop`, but it can be manually activated | ||
from any top level by: | ||
|
||
``` | ||
#require "reason";; | ||
``` | ||
|
||
Additionally, the OCaml compiler exports its internals, including the parser, | ||
in a package `compiler-libs`. This allows us to parse *directly* into the | ||
`OCaml` AST, instead of having an additional AST -> AST conversion step. | ||
|
||
Findlib provides an interface that allows registering a preprocessor. | ||
Additionally, it will pass all package include paths to such a preprocessor. | ||
|
||
Debugging Yacc Grammar Conflicts: | ||
------------------------- | ||
Run the main parser through yacc with the `-v` flag to have it print out | ||
details about the conflict. `ocamlyacc -v src/reason_parser.mly`. The debug | ||
information can be found at `src/reason_parser.output`. | ||
|
||
Testing: | ||
------------------ | ||
Run the tests in the `./formatTest/` directory and observe differences in | ||
output. The test files contain the most obscure syntax forms intentionally. | ||
|
||
Credit: | ||
------- | ||
The general structure of this project's organization and build/packaging | ||
process was taken from @whitequark's m17n project, including parts of the | ||
`README` that instruct how to use this with the OPAM toolchain. | ||
|
||
License | ||
------- | ||
|
||
New content is licensed under the MIT license, works that are forked from other | ||
projects are under their original licenses. | ||
[MIT license](LICENSE.txt) | ||
|
||
Editor plugins (which have also been forked) in the `editorSupport/` directory | ||
include their own licenses. | ||
|
Oops, something went wrong.