Skip to content

Commit e87d6b5

Browse files
authored
Move syntax into compiler (rescript-lang#5780)
* Remove syntax submodule * Add syntax sources directly to compiler repo * Update CONTRIBUTIING.md * CI stuff for syntax
1 parent 9b1e2f6 commit e87d6b5

File tree

2,008 files changed

+337976
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,008 files changed

+337976
-23
lines changed

.github/workflows/ci.yml

+35-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Checkout
3232
uses: actions/checkout@v3
3333
with:
34-
submodules: true
34+
fetch-depth: 2 # to be able to check for changes in subfolder res_syntax later
3535

3636
- name: Use OCaml ${{matrix.ocaml_compiler}}
3737
uses: ocaml/setup-ocaml@v2
@@ -40,10 +40,35 @@ jobs:
4040
opam-pin: false
4141
opam-depext: false
4242

43-
- name: Use Node.js
44-
uses: actions/setup-node@v3
45-
with:
46-
node-version: 16
43+
- name: "Check if syntax subfolder has changed"
44+
id: syntax-diff
45+
shell: bash
46+
run: |
47+
if git diff --name-only --exit-code HEAD^ HEAD -- res_syntax; then
48+
echo "syntax_status=unchanged" >> $GITHUB_ENV
49+
else
50+
echo "syntax_status=changed" >> $GITHUB_ENV
51+
fi
52+
53+
- name: "Syntax: install OPAM dependencies"
54+
if: env.syntax_status == 'changed'
55+
run: opam install . --deps-only
56+
working-directory: res_syntax
57+
58+
- name: "Syntax: build CLI"
59+
if: env.syntax_status == 'changed'
60+
run: opam exec -- dune build
61+
working-directory: res_syntax
62+
63+
- name: "Syntax: Run roundtrip tests"
64+
if: ${{ env.syntax_status == 'changed' && runner.os != 'Windows' }}
65+
run: opam exec -- make roundtrip-test
66+
working-directory: res_syntax
67+
68+
- name: "Syntax: Run tests (Windows)"
69+
if: ${{ env.syntax_status == 'changed' && runner.os == 'Windows' }}
70+
run: opam exec -- make test
71+
working-directory: res_syntax
4772

4873
# Required for ninja build
4974
- name: "Windows: Use MSVC"
@@ -55,6 +80,11 @@ jobs:
5580
- name: Build ninja
5681
run: node scripts/buildNinjaBinary.js
5782

83+
- name: Use Node.js
84+
uses: actions/setup-node@v3
85+
with:
86+
node-version: 16
87+
5888
- name: NPM install
5989
run: opam exec -- npm ci
6090
env:

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ coverage
5555
ppx_tools/
5656
vendor/ocaml/stdlib/target_camlheader
5757
vendor/ocaml/stdlib/target_camlheaderd
58-
reason/
5958
man/
6059
lib/ocaml
6160
*.tgz

.gitmodules

-8
This file was deleted.

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ jscomp/
22
lib/
33
vendor/
44
ninja/
5-
syntax/
5+
res_syntax/
66
_opam
77
CHANGELOG.md
88
README.md

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Welcome to the ReScript compiler project!
44

55
This document will give you guidance on how to get up and running to work on the ReScript compiler and toolchain.
66

7-
(If you want to contribute to the documentation website, check out [rescript-association/rescript-lang.org](https://github.com/reason-association/rescript-lang.org). For contributions to the ReScript syntax, please visit the [rescript-lang/syntax](https://github.com/rescript-lang/syntax) project.)
7+
(If you want to contribute to the documentation website, check out [rescript-association/rescript-lang.org](https://github.com/reason-association/rescript-lang.org).
88

99
We tried to keep the installation process as simple as possible. In case you are having issues or get stuck in the process, please let us know in the issue tracker.
1010

dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(dirs jscomp)
1+
(dirs jscomp res_syntax)

res_syntax/.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.DS_STORE
2+
*.cm*
3+
*.o
4+
*.s
5+
lib/*
6+
!lib/README.md
7+
.vscode/settings.json
8+
9+
# Dune
10+
_build
11+
12+
# Merlin
13+
.merlin
14+
15+
# Local opam switch
16+
_opam/
17+
18+
# Output dir for bootstrap script
19+
bootstrap/

res_syntax/.ocamlformat

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
profile = default
2+
version = 0.22.4
3+
4+
field-space = tight-decl
5+
break-cases = toplevel
6+
module-item-spacing = preserve
7+
cases-exp-indent = 2
8+
space-around-arrays = false
9+
space-around-lists = false
10+
space-around-records = false
11+
space-around-variants = false

res_syntax/.ocamlformat-ignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
compiler-libs-406/*

res_syntax/CHANGELOG.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
## Master
2+
3+
> **Tags:**
4+
>
5+
> - :boom: [Breaking Change]
6+
> - :eyeglasses: [Spec Compliance]
7+
> - :rocket: [New Feature]
8+
> - :bug: [Bug Fix]
9+
> - :memo: [Documentation]
10+
> - :house: [Internal]
11+
> - :nail_care: [Polish]
12+
13+
#### :boom: Breaking Change
14+
15+
- Emit an error when a `@string` or `@int` attribute is used in a V4 component https://github.com/rescript-lang/rescript-compiler/issues/5724
16+
17+
#### :rocket: New Feature
18+
19+
- Add surface syntax for `async`/`await` https://github.com/rescript-lang/syntax/pull/600
20+
21+
- Initial support for JSX V4, still work in progress.
22+
23+
- :boom: when V4 is activated, at most one component is allowed for each module.
24+
25+
- Add support for empty record literal `{}` for records with only optional fields, and type definition of empty record (e.g. `type empty = {}`) https://github.com/rescript-lang/syntax/pull/632
26+
27+
- Support the use of spread anywhere in list creation (e.g. `list{...x, 1, ...y, ...z}). https://github.com/rescript-lang/syntax/pull/692
28+
29+
- Add support for the argument of `@react.component` to set a props type from the outside. https://github.com/rescript-lang/syntax/pull/699
30+
31+
#### :bug: Bug Fix
32+
33+
- Fix issue in formatting JSX spread props https://github.com/rescript-lang/syntax/pull/644
34+
- Fix pretty printer where it would print doc comments on the same line as other attributes https://github.com/rescript-lang/syntax/pull/642
35+
- Fix location issue in error messages with JSX V4 where the body of the component is an application https://github.com/rescript-lang/syntax/pull/633
36+
- Fix issue where the printer would omit attributes for `->` and `|>` https://github.com/rescript-lang/syntax/pull/629
37+
- Fix printing of optional fields in records https://github.com/rescript-lang/rescript-compiler/issues/5654
38+
- Fix printing of comments inside empty blocks https://github.com/rescript-lang/syntax/pull/647
39+
- Fix location issue in error messages with JSX V4 where the multiple props types are defined https://github.com/rescript-lang/syntax/pull/655
40+
- Fix location issue in make function in JSX V4 that breaks dead code elimination https://github.com/rescript-lang/syntax/pull/660
41+
- Fix parsing (hence pretty printing) of expressions with underscore `_` and comments.
42+
- Fix printing of comments inside JSX tag https://github.com/rescript-lang/syntax/pull/664
43+
- Fix issue where formatter erases tail comments inside JSX tag https://github.com/rescript-lang/syntax/issues/663
44+
- Fix issue where the JSX prop has type annotation of the first class module https://github.com/rescript-lang/syntax/pull/666
45+
- Fix issue where a spread `...x` in non-last position would not be reported as syntax error https://github.com/rescript-lang/syntax/pull/673/
46+
- Fix issue where the formatter would delete `async` in a function with labelled arguments.
47+
- Fix several printing issues with `async` including an infinite loop https://github.com/rescript-lang/syntax/pull/680
48+
- Fix issue where certain JSX expressions would be formatted differenctly in compiler 10.1.0-rc.1 https://github.com/rescript-lang/syntax/issues/675
49+
- Fix issue where printing nested pipe discards await https://github.com/rescript-lang/syntax/issues/687
50+
- Fix issue where the JSX key type is not an optional string https://github.com/rescript-lang/syntax/pull/693
51+
- Fix issue where the JSX fragment without children build error https://github.com/rescript-lang/syntax/pull/704
52+
- Fix issue where async as an id cannot be used with application and labelled arguments https://github.com/rescript-lang/syntax/issues/707
53+
- Treat await as almost-unary operator weaker than pipe so `await foo->bar` means `await (foo->bar)` https://github.com/rescript-lang/syntax/pull/711
54+
55+
#### :eyeglasses: Spec Compliance
56+
57+
- Functions with consecutive dots now print as multiple arrow functions like in JavaScript.
58+
59+
#### :nail_care Polish
60+
61+
- Change the internal representation of props for the lowercase components to record. https://github.com/rescript-lang/syntax/pull/665
62+
- Change the payload of Pconst_char for type safety. https://github.com/rescript-lang/rescript-compiler/pull/5759
63+
- Specialize the printing of the rhs of a record field assignment for optional values `{x: ? e}` https://github.com/rescript-lang/syntax/issues/714
64+
65+
## ReScript 10.0
66+
67+
- Fix printing for inline nullary functor types [#477](https://github.com/rescript-lang/syntax/pull/477)
68+
- Fix stripping of quotes for empty poly variants [#474](https://github.com/rescript-lang/syntax/pull/474)
69+
- Implement syntax for arity zero vs arity one in uncurried application in [#139](https://github.com/rescript-lang/syntax/pull/139)
70+
- Fix parsing of first class module exprs as part of binary/ternary expr in [#256](https://github.com/rescript-lang/syntax/pull/256)
71+
- Fix formatter hanging on deeply nested function calls [#261](https://github.com/rescript-lang/syntax/issues/261)
72+
- Remove parsing of "import" and "export" which was never officially supported.
73+
74+
## ReScript 9.0.0
75+
76+
- Fix parsing of poly-var typexpr consisting of one tag-spec-first in [#254](https://github.com/rescript-lang/syntax/pull/254)
77+
- Implement new syntax for guards on pattern match cases in [#248](https://github.com/rescript-lang/syntax/pull/248)
78+
- Implement intelligent breaking for poly-var type expressions in [#246](https://github.com/rescript-lang/syntax/pull/246)
79+
- Improve indentation of fast pipe chain in let binding in [#244](https://github.com/rescript-lang/syntax/pull/244)
80+
- Improve printing of non-callback arguments in call expressions with callback in [#241](https://github.com/rescript-lang/syntax/pull/241/files)
81+
- Fix printing of constrained expressions in rhs of js objects [#240](https://github.com/rescript-lang/syntax/pull/240)
82+
- Improve printing of trailing comments under lhs of "pipe" expression in [#329](https://github.com/rescript-lang/syntax/pull/239/files)
83+
- Improve printing of jsx children and props with leading line comment in [#236](https://github.com/rescript-lang/syntax/pull/236)
84+
- Improve conversion of quoted strings from Reason in [#238](https://github.com/rescript-lang/syntax/pull/238)
85+
- Print attributes/extension without bs prefix where possible in [#230](https://github.com/rescript-lang/syntax/pull/230)
86+
- Cleanup gentype attribute printing [fe05e1051aa94b16f6993ddc5ba9651f89e86907](https://github.com/rescript-lang/syntax/commit/fe05e1051aa94b16f6993ddc5ba9651f89e86907)
87+
- Implement light weight syntax for poly-variants [f84c5760b3f743f65e934195c87fc06bf88bff75](https://github.com/rescript-lang/syntax/commit/f84c5760b3f743f65e934195c87fc06bf88bff75)
88+
- Fix bug in fast pipe conversion from Reason. [3d5f2daba5418b821c577ba03e2de1afb0dd66de](https://github.com/rescript-lang/syntax/commit/3d5f2daba5418b821c577ba03e2de1afb0dd66de)
89+
- Improve parsed AST when tilde is missing in arrow expr parameters. [e52a0c89ac39b578a2062ef15fae2be625962e1f](https://github.com/rescript-lang/syntax/commit/e52a0c89ac39b578a2062ef15fae2be625962e1f)
90+
- Improve parser diagnostics for missing tilde in labeled parameters. [a0d7689d5d2bfc31dc251e966ac33a3001200171](https://github.com/rescript-lang/syntax/commit/a0d7689d5d2bfc31dc251e966ac33a3001200171)
91+
- Improve printing of uncurried application with a huggable expression in [c8767215186982e171fe9f9101d518150a65f0d7](https://github.com/rescript-lang/syntax/commit/c8767215186982e171fe9f9101d518150a65f0d7)
92+
- Improve printing of uncurried arrow typexpr outcome printer in [4d953b668cf47358deccb8b730566f24de25b9ee](https://github.com/rescript-lang/syntax/commit/4d953b668cf47358deccb8b730566f24de25b9ee)
93+
- Remove support for nativeint syntax in [72d9b7034fc28f317672c94994b322bee520acca](https://github.com/rescript-lang/syntax/commit/72d9b7034fc28f317672c94994b322bee520acca)
94+
- Improve printing of poly variant typexprs with attributes in [bf6561b](https://github.com/rescript-lang/syntax/commit/bf6561bb5d84557b8b6cbbcd40078c39526af4af)
95+
96+
## ReScript 8.4.2 (December 11, 2020)
97+
98+
Released in https://github.com/rescript-lang/syntax/releases/tag/v8.4.2 as part of https://github.com/rescript-lang/rescript-compiler/releases/tag/8.4.2

res_syntax/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 ReScript
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.

res_syntax/Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
SHELL = /bin/bash
2+
3+
build:
4+
dune build
5+
6+
bootstrap: build
7+
dune exec -- bash ./scripts/bootstrap.sh
8+
9+
bench: build
10+
dune exec -- bench
11+
12+
test: build
13+
dune exec -- testrunner
14+
dune exec -- bash ./scripts/test.sh
15+
make reanalyze
16+
bash ./scripts/testok.sh
17+
18+
roundtrip-test: build
19+
dune exec -- testrunner
20+
ROUNDTRIP_TEST=1 dune exec -- bash ./scripts/test.sh
21+
make reanalyze
22+
bash ./scripts/testok.sh
23+
24+
reanalyze: build
25+
reanalyze.exe -set-exit-code -all-cmt _build/default -suppress testrunner,compiler-libs-406 -exclude-paths compiler-libs-406
26+
27+
format:
28+
dune build @fmt --auto-promote
29+
30+
checkformat:
31+
dune build @fmt
32+
33+
clean:
34+
dune clean
35+
36+
.PHONY: bench clean test roundtrip-test reanalyze bootstrap build-native

0 commit comments

Comments
 (0)