@exercism/codemirror-lang-raku 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,327 @@
1
+ ## 1.0.1
2
+
3
+ The README is restructured. This release is the first published from GitHub Actions, with npm provenance.
4
+
5
+ # Changelog
6
+
7
+ All notable changes to this project will be documented in this file.
8
+
9
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
10
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
11
+
12
+ ## [Unreleased]
13
+
14
+ ## [1.0.0]
15
+
16
+ This is Exercism's first release of the package, published as
17
+ `@exercism/codemirror-lang-raku`. It adds snippets for common constructs, such
18
+ as `sub`, `class`, `if`, `for` and `given`, to the completion.
19
+
20
+ ## [0.5.0] - 2026-11-21
21
+
22
+ ### Bug fixes
23
+
24
+ - A word list or a regex right after an operator, with no space between
25
+ them, is no longer read as part of the operator: `my @a=<a b c>`,
26
+ `foo |<a b>`, `say +<a b c>`, `my @w=«a b»`, `<1 2>|<2 1>`,
27
+ `$s ~~/^\d+$/`, `say !/x/`. A quote in such a regex could turn the
28
+ rest of the document inside out. Operators that hold these characters
29
+ stay whole: `//=`, `<=>`, `<==`, `>>+<<`, `»+«`, `-<<`, the end of a
30
+ hyper assignment with brackets (`@a >>[&f]=<< @b`, `@a »[+]=« @b`),
31
+ and the shifts and negations `+<`, `~<`, `!<` after a term.
32
+ - `*<key>` is a subscript on the whatever star, and `$i++/2` and `*/2`
33
+ divide.
34
+ - `=:=` is one operator.
35
+ - Characters that are no token, such as full-width digits (`say 42;`),
36
+ letterlike symbols that are no letters (`℃℃`, `№`) or backticks
37
+ (`` 1 ``` 2 ``), no longer turn the code after them, up to the next
38
+ blank line, into Pod. They are errors, and the code after them is read
39
+ as code.
40
+ - After an edit, what follows a prefix `++` or `--` could be read
41
+ differently than in a parse from scratch: the name in `++x` could
42
+ become an operator.
43
+ - After an edit that makes a heredoc's opener no longer open it, the
44
+ text of the heredoc stays a heredoc less often: in a test with 1,170
45
+ such edits, 3 of them, down from 18. Which edits do it has changed, so
46
+ a few that used to be read right now are not. See Known limitations in
47
+ the README.
48
+ - A sigilless name that is spelled like a declarator, as in
49
+ `sub f(\role, \class) { role.say }`, no longer makes a declaration that
50
+ runs on past the signature. A lowercase word after a backslash is a
51
+ name, and so is a declarator that a method is called on.
52
+ - After a character that is no token, the next word is no longer taken
53
+ for the name of the declaration: in `class 42 is Foo { }`, `is` is
54
+ not a `PackageName`.
55
+ - `[/]` is a reduction: in `say [/] 8, 2; say 6 / 2;`, the code between
56
+ the slashes is no longer a regex.
57
+ - Regex adverbs that start with a count, as in `m:2nd/x y/`, `m:1st/a/`
58
+ and `s:3x/a/b/`, start a regex.
59
+ - `∞` is a number and `∅` a term, so the `/` after them divides:
60
+ `∞ / 2`, `-∞..∞`.
61
+ - The letters among the letterlike symbols, the superscripts and the
62
+ subscripts, and a few others, start a name: `my constant \ℝ = 1`,
63
+ `ℵ`, `Ω`, `ⁿ`, `々`. They used to be errors.
64
+ - A number that is one character is a `Number`, as `½` was: the Roman
65
+ numerals (`Ⅻ`, `ⅰ`), the subscripts (`₀`), the circled numbers (`①`,
66
+ `⑴`, `❶`, `㉑`, `㊀`) and the ideographic numbers (`〇`, `〡`). The `/`
67
+ after them divides. They used to be errors, operators (`①`) or names
68
+ (`㉑`).
69
+ - A `++` or `--` at the start of a line after a block is a prefix: in
70
+ `if 1 { }` followed by `++x;`, `x` is no longer read as an operator.
71
+ - A chain of method calls in a string that ends in an argument list is
72
+ interpolated as a whole: `"$c.raku.subst(/ "(" .* /)"`. A quote in the
73
+ arguments no longer closes the string and turns the code after it
74
+ inside out.
75
+ - A backslash in a word list keeps the delimiter after it from closing
76
+ the list: `<a \> b>`, `«a \» b»`, `<<a \>> b>>`.
77
+ - Completion offers the variables that are declared with a native type
78
+ or a coercion type, as in `my int @a`, `my num $n` and
79
+ `my Foo(Str) $x`, and offers nothing for the variable that such a
80
+ declaration is making up, as in `my int $new`.
81
+ - In a string, an array, a hash or a routine with a twigil is
82
+ interpolated when a subscript or a call follows it, as one without a
83
+ twigil is: `"%*ENV<HOME>"`, `"@*ARGS[0]"`, `"@!items[]"`,
84
+ `"%.h<k>"`, `"&?ROUTINE.name()"`.
85
+ - A named capture, `$<name>` or `@<name>`, is a variable, in code and
86
+ in strings, as `$0` and `$/` are. It used to be a sigil and a
87
+ subscript, which in a string were highlighted as its text. A name of
88
+ more than 20 characters still is.
89
+ - `ff`, `fff`, `before`, `after`, `unicmp`, `coll` and `minmax` are
90
+ operators where an operator is expected, as `x` and `min` are, and so
91
+ are the meta operators on word operators: `Zmin`, `Xeq`, `Rcmp`. They
92
+ used to be names, and the meta operators types.
93
+ - The word operators and the set operators are operators after a
94
+ subscript in braces, or a block, on the same line: `%h{$k} x 3`,
95
+ `{ rand } xx 3`, `%h{$k} (elem) $s`.
96
+ - `$%h` and `@%h` are a hash in a container, not a modulo.
97
+ - A type capture (`::T`, as in `role R[::T]`) and the types of the
98
+ current package (`::?CLASS`, `::?ROLE`) are type names, and `$::x`
99
+ is a variable. A `::` that no name follows, as in `::('Foo')` and
100
+ `PROCESS::<$OUT>`, is one token, and `::=` is one operator. They used
101
+ to be split into colons and pair keys.
102
+ - A `:sym<…>` that holds brackets with a space between them belongs to
103
+ the name of a regex declaration, as in `token infix:sym<{ }> { … }`.
104
+ The brackets used to be read as the body of the declaration, and the
105
+ body as code.
106
+ - The import list after the version or the author of a module is a
107
+ word list: `use Foo:ver<1>:auth<zef:me> <a b>`.
108
+ - A byte order mark at the start of a file is whitespace, not an error.
109
+ - Completion offers the variables that are declared with a type of the
110
+ document's own whose name is not capitalized, as in
111
+ `class point { }; my point $p`, when the type is declared in a scope
112
+ around the variable. A word that the document does not declare as a
113
+ type is still taken for a call after a `my` that is being typed on the
114
+ line above it.
115
+ - In a regex, an apostrophe in a name no longer starts a quote, in a
116
+ block of code (`/ { don't() } /`) or in an assertion (`/<it's>/`). The
117
+ regex used to run on past its closing delimiter, and a quote after it
118
+ turned the rest of the line inside out. A block of code in a regex in
119
+ braces is read as code too: `m{ a { don't() } }`.
120
+ - The text of a heredoc that a block of code in a regex declaration
121
+ opens starts on the next line, as in code: `token a { { Q:to/END/ } … }`.
122
+ It used to start after the declaration, and took the code there for
123
+ its text.
124
+ - A hyper operator that holds a comma, as in `@a »,« @b`, `@a <<,>> @b`
125
+ and `@a Z»,« @b`, is one operator, and a hyper infix after a whatever star,
126
+ as in `* «+« 1`, no longer starts a word list. The closing angles could
127
+ open a word list that turned the strings after it inside out.
128
+ - The adverbs of a quote can follow a blank: `Q :q [a \] b]` and
129
+ `qq :!s [$x]` are quotes, and so is the heredoc of `q :to/END/`.
130
+
131
+ ### Performance
132
+
133
+ - Reparsing after an edit reuses the rest of the document when the last
134
+ statement of the document, or of a large block, opens a heredoc. Such a
135
+ document used to be parsed from scratch after every edit: a 1-character
136
+ edit in about 100 KB took about 50 ms, and takes about 1 ms. Documents
137
+ with many heredocs gain as well: in about 95 KB with a heredoc every
138
+ 7 lines, an edit takes under 1 ms, down from about 8 ms.
139
+ - Reparsing after an edit is faster in a huge quote: a 1-character edit
140
+ in a `"…"` or `qq[…]` of about 200 KB takes 55–70% of the time it did.
141
+ - The first completion after an edit no longer gathers the names of the
142
+ whole scope again. The parts of the document that the edit leaves
143
+ alone keep what they declare. In a document of about 17,000 lines, it
144
+ takes under 1 ms, down from about 9 ms.
145
+ - While a `"…` or `qq[…` is not closed, an edit before or after it no
146
+ longer reparses the whole document. Such a quote still runs to the end
147
+ of the document, and is now closed there, also when a `{` of an
148
+ interpolation in it is open. In a document of about 3,500 lines, a
149
+ 1-character edit takes 1–2 ms, down from 25–55 ms. The tree of such a
150
+ quote changes: it no longer ends in an error node, as in
151
+ `StringLiteral(VariableName)` for `"oops $x`. An error node is still
152
+ left in what the quote does not close itself, such as a `{` or a
153
+ nested `[` of its delimiters. A backslash at the end of such a quote
154
+ is part of its text, and no longer an operator after it.
155
+
156
+ ### Dependencies
157
+
158
+ - Requires `@lezer/lr` 1.4.12 or later. With 1.4.11, an edit
159
+ can keep the parser from reusing the first child of the node that holds
160
+ it, and a 1-character edit reads about three times as much text again.
161
+
162
+ ## [0.4.1] - 2026-11-10
163
+
164
+ ### Internal
165
+
166
+ - Releases are prepared by [tagpr](https://github.com/Songmu/tagpr): a
167
+ release pull request carries the version bump and this file's section,
168
+ and merging it tags the release and publishes it to npm with
169
+ [Trusted Publishing](https://docs.npmjs.com/trusted-publishers), with
170
+ provenance. The text of each GitHub release is still this file's section
171
+ for the version.
172
+
173
+ ## [0.4.0] - 2026-10-07
174
+
175
+ Most of this was found by parsing the test suite of
176
+ [mutsu](https://github.com/tokuhirom/mutsu), an implementation of Raku.
177
+
178
+ ### Breaking changes
179
+
180
+ - The name of a constant with a sigil, as in `constant $LIMIT = 3`, is a
181
+ `ConstantName` inside the `ConstantDeclaration`. It was a
182
+ `VariableName` after the declaration, which had no name.
183
+ - A `:sym<…>` that follows the name of a declaration after blanks, as in
184
+ `token word :sym<long> { }`, is part of the `RegexName`.
185
+ - A declarator comment with brackets, `#|( … )` or `#=( … )`, is one
186
+ `DocComment` up to its closing bracket. It ended with its first line,
187
+ and still does when the bracket is not closed.
188
+
189
+ ### New features
190
+
191
+ - Corner quotes (`「…」`), also after a quote word (`Q「…」`), the low
192
+ curly quotes (`„…”`, `„…“`, `‚…’`, `‚…‘`) and the reversed `”…”`.
193
+ - A quote word takes a backtick or a symbol outside of ASCII for a
194
+ delimiter: ``qx`…` ``, `Q♥…♥`.
195
+ - Fractions that are one character (`½`, `⅔`) are numbers, and a power
196
+ in superscript (`$x²`) is an operator.
197
+ - Symbols outside of ASCII are operators: the atomic operators
198
+ (`⚛+=`), and the operators of one's own (`1 ⚡ 2`).
199
+ - The set operators that are written in parentheses, as in
200
+ `$a (<=) $b` and `$x (elem) $s`, are operators.
201
+ - An operator in brackets as a routine, as in `&[+]`, is a
202
+ `VariableName`.
203
+ - The name of an operator can be written in double angles:
204
+ `infix:<< plus-one >>`, `&infix:<<(>=)>>`.
205
+ - The variable `$¢`.
206
+
207
+ ### Bug fixes
208
+
209
+ - In a regex, `‘…’`, `“…”`, `‚…’`, `„…”` and `「…」` are quotes, in which
210
+ the delimiter of the regex does not end it: `m/ab ‘/’ c/`.
211
+ - A list of words in a regex, `/ < a ' b > /`, no longer starts a quote
212
+ at a `'` in it.
213
+ - A regex does not end at its delimiter in code: in the arguments of an
214
+ assertion (`<name: /a/ >`, `<:name(/a/)>`), in `$( … )`, and in a
215
+ declaration (`:my $m = $/;`).
216
+ - A `$/` in the replacement of a substitution does not end it:
217
+ `s/(a)/[$/]/`.
218
+
219
+ ## [0.3.0] - 2026-10-07
220
+
221
+ ### Breaking changes
222
+
223
+ - A pair of a quote's own delimiters inside it, as the `[b]` of
224
+ `qq[a [b] c]`, is a `NestedDelimiters` node in the `StringLiteral`.
225
+ It was text without a node.
226
+
227
+ ### Bug fixes
228
+
229
+ - After an edit in a long quote that interpolates and has bracket
230
+ delimiters (`qq[…]`), the text after a nested `[` could be read as if
231
+ the quote had ended, and every further edit parsed the quote again
232
+ from its start.
233
+ - In such a quote, a `[…]` or `(…)` right after a nested pair of
234
+ delimiters is text, not a subscript or a call: `qq[a [b](c)]`.
235
+ - After an edit, the text of a heredoc could be read as code when a long
236
+ quote that interpolates and spans several lines followed the opener
237
+ of the heredoc on its line.
238
+
239
+ ## [0.2.0] - 2026-10-07
240
+
241
+ ### New features
242
+
243
+ - Regexes are highlighted inside: the literals `/…/`, `rx/…/`, `m/…/` and
244
+ the pattern of `s/…/…/`, and the body of a `token`, `rule` or `regex`
245
+ declaration. A `Regex` node has children for character classes (`CharacterClass`),
246
+ `<…>` assertions (`Assertion`), quoted literals, escapes, quantifiers
247
+ and anchors, variables, comments, and the blocks of code in it, which
248
+ are read as code.
249
+ - `multi foo(…) { }`, `proto foo(…) {*}` and `only foo(…) { }`, without the
250
+ word `sub`, are `RoutineDeclaration` nodes with a `RoutineName`. The
251
+ node has no declarator keyword, and `multi` is the node before it.
252
+ - Pod blocks have child nodes for their directives (`PodDirective`),
253
+ headings (`PodHeading`) and formatting codes (`PodStrong`,
254
+ `PodEmphasis`, `PodCode`, `PodLink`, `PodFormat`), which are highlighted.
255
+ - Variables, blocks and escapes are interpolated in the text of a
256
+ `qq:to` heredoc. Its `Heredoc` node has the children of a string that
257
+ interpolates.
258
+ - Variables, blocks and escapes are interpolated in `<<…>>` and `«…»`
259
+ word lists. Such a list can hold code over several lines, and can be
260
+ a subscript: `%h«$key»`, `:a<<b $c>>`.
261
+ - Completion offers the names that the document declares: the variables
262
+ and attributes in scope, routines, classes, enums, subsets and
263
+ constants, and after a `.` the methods.
264
+ - Completion also offers placeholder variables (`$^a`) in their block,
265
+ and variables without a sigil (`my \x`).
266
+ - A line that starts with a trait, as in `is export {` under
267
+ `sub f($a)`, is indented as the continuation of its statement.
268
+ - Toggling a block comment picks brackets that fit the selection:
269
+ `` #`[ … ] `` when the selection holds an unbalanced parenthesis, and so
270
+ on. A comment is removed whichever bracket it was written with.
271
+ - A line that continues a statement is indented one unit further: after
272
+ a line that ends in an operator or a comma, and when it starts with a
273
+ method call or an infix operator.
274
+ - The adverbs of a quote that switch kinds of interpolation on and off
275
+ are taken into account: `q:c{…}` interpolates blocks, `qq:!s[…]` does
276
+ not interpolate `$` variables. This covers `:c`, `:s`, `:a`, `:h`, `:f`,
277
+ `:b`, `:qq`, `:q` and their long names.
278
+ - An operator referred to as a routine, as in `&infix:<+>`, is a single
279
+ `VariableName`. Operator names can also be written as `circumfix:<[ ]>`
280
+ and `infix:['+']`.
281
+ - `q`, `qq`, `Q` and their variants take a bracket after blanks: `q {…}`,
282
+ `qw <a b>`.
283
+ - An adverb with an argument that is `False` or `0` is switched off:
284
+ `qq:c(False)[…]`.
285
+
286
+ ### Bug fixes
287
+
288
+ - A regex with bracket delimiters no longer ends at the `]` of a
289
+ character class in it: `rx[ <[a..z]> ]`.
290
+ - `multi foo`, `proto foo` and `only foo` declare a sub also when the
291
+ signature or the body starts on the next line.
292
+ - A long comment right after a type name (`my Foo # …`) no longer makes
293
+ every edit before it reparse the document up to that comment.
294
+ - After the built-in terms `pi`, `π`, `tau`, `τ`, `now`, `time` and `rand`, a
295
+ `/` or `<` is an operator whatever the spacing: `pi /2`.
296
+ - A keyword that is a routine and is called with parentheses, as in
297
+ `take(1)` or `not($x)`, is a plain name and not a keyword.
298
+ - The body of a regex declaration that is not closed ends before the next
299
+ `token`, `rule` or `regex` declaration, so that the declarations after
300
+ it are still found.
301
+ - A heredoc opener that is only mentioned in a string or in a comment no
302
+ longer starts a heredoc. Heredocs are now found from the quote tokens
303
+ of the line, not from its text.
304
+
305
+ ## [0.1.0] - 2026-10-06
306
+
307
+ ### New features
308
+
309
+ First release.
310
+
311
+ - Syntax highlighting with the standard tags of `@lezer/highlight`:
312
+ comments and Pod, quotes of all kinds with interpolation, heredocs,
313
+ regexes, numbers, variables with sigils and twigils, keywords, operators
314
+ and declarations
315
+ - A syntax tree with nodes for package, routine, regex, enum, subset and
316
+ constant declarations and their names
317
+ - Indentation, folding and matching of `{ }`, `( )` and `[ ]`, and folding
318
+ of Pod blocks, heredocs and embedded comments
319
+ - Completion of keywords and of the commonly used built-in types,
320
+ routines, methods and special variables
321
+
322
+ [0.5.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.5.0
323
+ [0.4.1]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.4.1
324
+ [0.4.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.4.0
325
+ [0.3.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.3.0
326
+ [0.2.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.2.0
327
+ [0.1.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2026 by Kan Fushihara
4
+ Copyright (C) 2021 by Marijn Haverbeke <marijnh@gmail.com> and others
5
+ (the CodeMirror language package template this project started from)
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.