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