@exercism/lezer-julia 0.0.0-stage → 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Andrey Popp
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.
package/README.md CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ # `@exercism/lezer-julia`
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
+ This repo is Exercism's fork of [`@plutojl/lezer-julia`](https://github.com/JuliaPluto/lezer-julia), by the Pluto team.
4
+ Exercism uses it in the editor on exercism.org, through `@exercism/codemirror-lang-julia`.
5
+ The `main` branch tracks upstream. Exercism's changes are on the `exercism` branch.
6
+ They make these differences from upstream:
7
+
8
+ - In `if f(x)` and `for x in f(y)`, the parser sees `f(x)` and `f(y)` as function calls. Upstream took `f` as the whole condition and `(x)` as the start of the body.
9
+ - The middle part of a ternary can be a comparison or an assignment (`c ? a < b : d`, `c ? x = 1 : f(x)`).
10
+ - An assignment can have a ternary on its left (`c ? x = 1 : x = 2`), so that this common pattern parses without errors.
11
+ - Function calls are highlighted as calls. Upstream's rule named a node that doesn't exist. The name in a short definition such as `f(x) = ...` is now highlighted as a call too, because upstream's rule for it also matched every call on the right of an assignment.
12
+ - The tokenizer reads string content in longer chunks, which makes files with many strings parse about twice as fast.
13
+ - The tokenizer decides how to read `f(`, `x.` and similar text from the surrounding code. The GLR notes in `CLAUDE.md` explain why.
14
+
15
+ ## Install and use
16
+
17
+ To install it, run:
18
+
19
+ ```
20
+ npm install @exercism/lezer-julia
21
+ ```
22
+
23
+ The package exports a Lezer `parser`. To use the parser in CodeMirror, install `@exercism/codemirror-lang-julia`, which wraps the parser. To parse code directly:
24
+
25
+ ```javascript
26
+ import {parser} from "@exercism/lezer-julia"
27
+
28
+ const tree = parser.parse("f(x) = 2x")
29
+ ```
30
+
31
+ To build and test it from a checkout, run `npm install` and then `npm test`. `npm install` builds the parser, which takes about 2 minutes.
32
+
33
+ ## About the grammar
34
+
35
+ This is a [Julia](https://julialang.org) grammar for the
36
+ [lezer](https://lezer.codemirror.net) parser system.
37
+
38
+ The grammar was initially based on [tree-sitter-julia](https://github.com/tree-sitter/tree-sitter-julia).
39
+
40
+ The code is licensed under an MIT license.
41
+
42
+ ## Demo site
43
+ See this parser in action on our demo page: https://juliapluto.github.io/lang-julia-demo/
44
+
45
+ ## Contributing
46
+
47
+ To initialize your development environment:
48
+ ```
49
+ yarn install
50
+ ```
51
+ This will install dependencies and build the parser.
52
+
53
+
54
+ To rebuild the parser after changing the grammar or the tokenizer:
55
+ ```
56
+ yarn run prepare
57
+ ```
58
+ If the build crashes with a GC related error, run `export NODE_OPTIONS='--max-old-space-size=8192'` and try again.
59
+
60
+
61
+ To test the parser:
62
+ ```
63
+ yarn test
64
+ ```
65
+
66
+
67
+ The same commands should also work fine with `npm` or `pnpm` instead of `yarn`.
68
+ The repository also includes a makefile for convenience.