@exercism/codemirror-lang-rescript 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ ## 1.0.1
2
+
3
+ The README is restructured. This release is the first published from GitHub Actions, with npm provenance.
4
+
5
+ ## 1.0.0
6
+
7
+ This is Exercism's first release of the package, published as
8
+ `@exercism/codemirror-lang-rescript`. It adds CodeMirror support through
9
+ `rescript()`, with highlighting, indentation, folding and completion, and parses
10
+ `%` as the remainder operator, value signatures at the top level and the spread
11
+ in a list pattern.
12
+
13
+ ## 0.1.0 (2025-10-24)
14
+
15
+ ### New Features
16
+
17
+ First documented release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2018 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,172 @@
1
- # Temporary Holding Version
1
+ # rescript-lezer
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Exercism's fork
4
+
5
+ This is Exercism's fork of [tsnobip/rescript-lezer](https://github.com/tsnobip/rescript-lezer), by tsnobip.
6
+ Exercism uses it in the ReScript editor on [exercism.org](https://exercism.org).
7
+ It is published on npm as `@exercism/codemirror-lang-rescript`.
8
+ Our changes are on the `exercism` branch, and the `main` branch follows upstream.
9
+ Below this section, the README is upstream's.
10
+
11
+ The package keeps upstream's `parser` export and adds CodeMirror 6 support.
12
+ `rescript()` gives highlighting, indentation, folding and completion. Completion offers:
13
+
14
+ - keywords, global functions such as `ignore`, the standard library's module names, and constructors such as `Some` and `Ok`.
15
+ - snippets for `let`, functions, `switch`, `if` and `if`/`else`, record and variant types, `module`, `for`, `while` and `try`.
16
+ - the functions in each standard library module after its name and a dot, as in `Array.`, `String.`, `List.`, `Option.`, `Int.` and `Belt.Map.Int.`. Each one shows its type. After `open Belt`, `Array.` offers Belt.Array's functions too.
17
+ - the names defined in the file (bindings, parameters, pattern variables, types, constructors and modules), where they are in scope. After a module defined in the file and a dot, it offers that module's names.
18
+ - built-in and file-defined types inside a type annotation.
19
+
20
+ `src/builtins.js` lists the standard library's functions. `scripts/generate-builtins.mjs` writes it from the interface files in the `@rescript/runtime` package. To update it, install that package without saving it, then run:
21
+
22
+ ```bash
23
+ npm install --no-save @rescript/runtime@12
24
+ npm run build
25
+ npm run builtins -- node_modules/@rescript/runtime/lib/ocaml
26
+ ```
27
+
28
+ The fork also changes the grammar so that it parses all of the ReScript track's example solutions:
29
+
30
+ - `%` between two expressions is the remainder operator, as in ReScript 12.
31
+ - Value signatures such as `let keep: array<int> => array<int>` can appear at the top level. Exercism's editor uses one language for both `.res` and `.resi` files.
32
+ - In `list{first, ...rest}`, `rest` is a binding.
33
+
34
+ ### Install and use
35
+
36
+ To install it, run:
37
+
38
+ ```bash
39
+ npm install @exercism/codemirror-lang-rescript
40
+ ```
41
+
42
+ Then add `rescript()` to the editor's extensions:
43
+
44
+ ```js
45
+ import {rescript} from "@exercism/codemirror-lang-rescript"
46
+
47
+ new EditorView({extensions: [basicSetup, rescript()], parent: document.body})
48
+ ```
49
+
50
+ ### Building and testing
51
+
52
+ Run `npm install`, which also builds the package into `dist/`. Run `npm run build` to rebuild it and `npm test` to run the tests.
53
+ `.github/workflows/test.yml` runs `npm test`.
54
+ To run upstream's grammar audit, described below, first run `npm install --no-save @rescript/runtime@12`.
55
+
56
+ ### Releasing
57
+
58
+ To release from the `exercism` branch, set `version` in `package.json` and push a tag of the same version:
59
+
60
+ ```bash
61
+ npm version patch # or minor / major
62
+ git push origin HEAD --follow-tags
63
+ ```
64
+
65
+ `npm version` updates the package and lockfile, commits the change, and creates the version tag. The tag starts `.github/workflows/publish.yml`. The workflow checks that the tag matches `package.json`, builds and tests the package, and publishes it to npm as `@exercism/codemirror-lang-rescript`, using the `exercism` organisation's `NPM_TOKEN` secret.
66
+
67
+ ### Contributing
68
+
69
+ Contributions to this fork follow the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).
70
+ Please read about how to [contribute to Exercism](https://exercism.org/docs/building).
71
+
72
+ ---
73
+
74
+ This is a ReScript grammar for the
75
+ [lezer](https://lezer.codemirror.net/) parser system.
76
+
77
+ The `top` option can be set to `"SingleExpression"` to parse an expression instead of a
78
+ full program.
79
+
80
+ ## Grammar Audit
81
+
82
+ Use the audit script to find remaining grammar bugs against the official ReScript parser.
83
+
84
+ The compiler and corpus are pinned in the `vendored/rescript` Git submodule.
85
+ Initialize it once, then build the parser comparator with ReScript's OCaml/dune
86
+ dependencies installed (see its `CONTRIBUTING.md`):
87
+
88
+ ```bash
89
+ git submodule update --init vendored/rescript
90
+ cd vendored/rescript
91
+ dune build compiler/bsc/rescript_compiler_main.exe
92
+ cd ../..
93
+ ```
94
+
95
+ ### Quick run
96
+
97
+ ```bash
98
+ npm run build
99
+ npm run audit:grammar
100
+ ```
101
+
102
+ ### Corpus regression check
103
+
104
+ ```bash
105
+ npm run test:corpus
106
+ ```
107
+
108
+ This checks the syntax fixtures, runtime packages, and scripts in the pinned
109
+ checkout. It also compares fresh and incremental trees across 1,000 reproducible edits.
110
+ It fails on compiler-valid parse errors, incremental mismatches, or crashes.
111
+ Compiler-rejected fixtures remain visible in the full differential audit.
112
+
113
+ GitHub Actions runs `npm test` and this corpus check on pushes and pull requests,
114
+ and saves the JSON audit report as the `grammar-audit` artifact.
115
+
116
+ ### Strict agreement
117
+
118
+ ```bash
119
+ npm run audit:grammar:strict
120
+ ```
121
+
122
+ ### Custom run
123
+
124
+ ```bash
125
+ node scripts/audit-grammar.mjs \
126
+ --mode all \
127
+ --max-files 10000 \
128
+ --fuzz-cases 500 \
129
+ --incremental-cases 300 \
130
+ --include-idempotency \
131
+ --report /tmp/rescript-lezer-audit.json
132
+ ```
133
+
134
+ ### What it checks
135
+
136
+ - Differential parse agreement vs ReScript (`-only-parse`) on upstream corpus files
137
+ - Mutation fuzzing with mismatch detection
138
+ - Incremental parse consistency (incremental tree vs fresh parse)
139
+
140
+ `--corpus` adds directories to the default corpus. Reports include error positions
141
+ and the full source and edit for reproducing fuzz and incremental failures. Use a fixed
142
+ `--seed` to reproduce edits, and `--rescript-root` or `RESCRIPT_ROOT` to compare
143
+ against another compiler checkout.
144
+
145
+ ## Publishing
146
+
147
+ Version tags (`v0.9.1`, for example) trigger `.github/workflows/publish.yml`.
148
+ The workflow runs the full test suite and corpus check, verifies that the tag
149
+ matches `package.json`, then builds and publishes to npm. Only stable versions
150
+ are supported.
151
+
152
+ Before the first automated release, push the workflow and configure a
153
+ [Trusted Publisher](https://docs.npmjs.com/trusted-publishers/) in the npm settings
154
+ for `@tsnobip/rescript-lezer`:
155
+
156
+ - GitHub user: `tsnobip`
157
+ - Repository: `rescript-lezer`
158
+ - Workflow filename: `publish.yml`
159
+ - Allow direct publishing with `npm publish`
160
+
161
+ Publishing uses OIDC, so no npm token secret is needed.
162
+ To release from a clean checkout of the release branch:
163
+
164
+ ```bash
165
+ npm version patch # or minor / major
166
+ git push origin HEAD --follow-tags
167
+ ```
168
+
169
+ `npm version` updates the package and lockfile, commits the change, and creates
170
+ the version tag. Failed workflow runs can be rerun from GitHub Actions.
171
+
172
+ The code is licensed under an MIT license.