codemirror-lang-raku 0.4.0 → 0.4.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 +30 -4
- package/README.md +76 -33
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
|
|
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
|
+
## [0.4.1] - 2026-11-10
|
|
11
|
+
|
|
12
|
+
### Internal
|
|
13
|
+
|
|
14
|
+
- Releases are prepared by [tagpr](https://github.com/Songmu/tagpr): a
|
|
15
|
+
release pull request carries the version bump and this file's section,
|
|
16
|
+
and merging it tags the release and publishes it to npm with
|
|
17
|
+
[Trusted Publishing](https://docs.npmjs.com/trusted-publishers), with
|
|
18
|
+
provenance. The text of each GitHub release is still this file's section
|
|
19
|
+
for the version.
|
|
20
|
+
|
|
21
|
+
## [0.4.0] - 2026-10-07
|
|
2
22
|
|
|
3
23
|
Most of this was found by parsing the test suite of
|
|
4
24
|
[mutsu](https://github.com/tokuhirom/mutsu), an implementation of Raku.
|
|
@@ -44,7 +64,7 @@ Most of this was found by parsing the test suite of
|
|
|
44
64
|
- A `$/` in the replacement of a substitution does not end it:
|
|
45
65
|
`s/(a)/[$/]/`.
|
|
46
66
|
|
|
47
|
-
## 0.3.0
|
|
67
|
+
## [0.3.0] - 2026-10-07
|
|
48
68
|
|
|
49
69
|
### Breaking changes
|
|
50
70
|
|
|
@@ -64,7 +84,7 @@ Most of this was found by parsing the test suite of
|
|
|
64
84
|
quote that interpolates and spans several lines followed the opener
|
|
65
85
|
of the heredoc on its line.
|
|
66
86
|
|
|
67
|
-
## 0.2.0
|
|
87
|
+
## [0.2.0] - 2026-10-07
|
|
68
88
|
|
|
69
89
|
### New features
|
|
70
90
|
|
|
@@ -130,7 +150,7 @@ Most of this was found by parsing the test suite of
|
|
|
130
150
|
longer starts a heredoc. Heredocs are now found from the quote tokens
|
|
131
151
|
of the line, not from its text.
|
|
132
152
|
|
|
133
|
-
## 0.1.0
|
|
153
|
+
## [0.1.0] - 2026-10-06
|
|
134
154
|
|
|
135
155
|
### New features
|
|
136
156
|
|
|
@@ -146,3 +166,9 @@ First release.
|
|
|
146
166
|
of Pod blocks, heredocs and embedded comments
|
|
147
167
|
- Completion of keywords and of the commonly used built-in types,
|
|
148
168
|
routines, methods and special variables
|
|
169
|
+
|
|
170
|
+
[0.4.1]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.4.1
|
|
171
|
+
[0.4.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.4.0
|
|
172
|
+
[0.3.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.3.0
|
|
173
|
+
[0.2.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.2.0
|
|
174
|
+
[0.1.0]: https://github.com/kan/codemirror-lang-raku/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
indentation, code folding, bracket matching and completion, built on a
|
|
10
10
|
[Lezer](https://lezer.codemirror.net/) grammar.
|
|
11
11
|
|
|
12
|
-
It covers comments and Pod, quotes of all kinds (`'…'`, `"…"`,
|
|
13
|
-
`Q` with any delimiter, heredocs,
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
It covers comments and Pod, quotes of all kinds (`'…'`, `"…"`, `「…」`,
|
|
13
|
+
curly quotes, `q` / `qq` / `Q` with any delimiter, heredocs,
|
|
14
|
+
`<word lists>`) with interpolation, regexes and grammars, numbers,
|
|
15
|
+
variables with sigils and twigils, keywords, operators, including the
|
|
16
|
+
ones written in Unicode, blocks and declarations.
|
|
16
17
|
|
|
17
18
|
Try it in the [demo](https://kan.github.io/codemirror-lang-raku/), which
|
|
18
19
|
shows the syntax tree next to the editor.
|
|
@@ -90,25 +91,38 @@ on incomplete code.
|
|
|
90
91
|
| `RegexDeclaration` | `token`, `rule`, `regex`, with a `RegexName` child, up to the body `Block`, which holds one `Regex`. The name includes a `:sym<…>`, with the blanks before it if there are any (`word :sym<long>`) |
|
|
91
92
|
| `EnumDeclaration`, `SubsetDeclaration`, `ConstantDeclaration` | The declarator and its `EnumName`, `SubsetName` or `ConstantName`. The name of a constant includes its sigil if it has one (`constant $LIMIT`). A constant without a sigil that is declared with a backslash (`constant \x`) has no `ConstantName` |
|
|
92
93
|
| `Block`, `Parens`, `Brackets` | `{ }`, `( )`, `[ ]` |
|
|
93
|
-
| `VariableName`, `AttributeName`, `SpecialVariable` | `$x` / `$^a`, `$!x` / `$.x`, `$*x` / `$?x` |
|
|
94
|
+
| `VariableName`, `AttributeName`, `SpecialVariable` | `$x` / `$^a`, `$!x` / `$.x`, `$*x` / `$?x`. An operator that is referred to as a routine is one `VariableName`: `&infix:<+>`, `&[+]` |
|
|
95
|
+
| `Identifier`, `TypeName` | A bare name (`say`, `my-sub`), and a capitalized one (`Int`, `Foo::Bar`), with its smiley if it has one (`Int:D`) |
|
|
96
|
+
| `MethodCall` | The `.` and the `MethodName` of `.name`, `.?name` and the like. The arguments are the `Parens` after it |
|
|
97
|
+
| `PairKey` | `:key`, `:!key`. The value is the node after it |
|
|
98
|
+
| `Number`, `Version` | `42`, `1.5e3`, `0x1F`, `:16<FF>`, `½`, and `v6.d` |
|
|
99
|
+
| `True`, `False`, `Nil` | These three words |
|
|
100
|
+
| `Operator` | An operator made of symbols, a word operator where an operator is expected (`x`, `min`, `Z+`), a set operator in parentheses (`(elem)`) |
|
|
94
101
|
| `StringLiteral` | A quote of any kind. One that interpolates has `Escape`, `Interpolation`, variable, `Brackets`, `Parens` and `MethodCall` children, and a `NestedDelimiters` for each pair of its own delimiters in it (the `[b]` of `qq[a [b] c]`) |
|
|
95
102
|
| `Heredoc` | The text of a heredoc, from the line after its `q:to/END/` opener through its terminator. The opener is a `StringLiteral`. The text of a `qq:to` heredoc has the same children as a string that interpolates. The texts of the heredocs that one line opens are a single node |
|
|
96
|
-
| `Regex` | `/…/`, `rx//`, `m//`, `s///`, `tr///`, or the body of a regex declaration. Its children are `CharacterClass` (`<[a..z]>`), `Assertion` (`<name>`, `<?before …>`), `StringLiteral`, `Escape` (`\d`), `Operator` (quantifiers, `\|`, anchors), `VariableName` (`$x`, `$<name>`), `LineComment`, and a `Block` for each `{ }` of code |
|
|
97
|
-
| `LineComment`, `DocComment`, `BlockComment` | `#`,
|
|
103
|
+
| `Regex` | `/…/`, `rx//`, `m//`, `s///`, `tr///`, or the body of a regex declaration. Its children are `CharacterClass` (`<[a..z]>`), `Assertion` (`<name>`, `<?before …>`), `StringLiteral`, `Escape` (`\d`), `Operator` (quantifiers, `\|`, anchors), `VariableName` (`$x`, `$<name>`), `LineComment`, `BlockComment`, and a `Block` for each `{ }` of code |
|
|
104
|
+
| `LineComment`, `DocComment`, `BlockComment` | `#`, `#\|` / `#=`, `` #`( ) ``. A declarator comment with brackets, `#\|( … )`, is one `DocComment` up to its closing bracket |
|
|
98
105
|
| `Pod` | `=begin` … `=end` and the other Pod blocks. Its children are `PodDirective` (`=begin`, `=head1`, `=end pod`), `PodHeading` (the text after `=head1`), and the formatting codes `PodStrong` (`B<…>`), `PodEmphasis` (`I<…>`), `PodCode` (`C<…>`), `PodLink` (`L<…>`) and `PodFormat` (the others) |
|
|
99
106
|
|
|
100
|
-
Each
|
|
101
|
-
`
|
|
107
|
+
Each keyword is a node named after the keyword (`if`, `for`, `my`,
|
|
108
|
+
`is`, `eq`, …), and so is each phaser (`BEGIN`, `LEAVE`, …). A
|
|
109
|
+
declarator keyword is a child of its declaration node (`class`, `sub`,
|
|
110
|
+
`token`, …). The words `unit`, `multi`, `proto`, `only`, `my` and
|
|
102
111
|
`our` are not part of the declaration node. They are the nodes right
|
|
103
112
|
before it, also in `multi foo(…) { }`, where the declaration node has no
|
|
104
113
|
declarator keyword.
|
|
105
114
|
|
|
115
|
+
Statements and expressions have no nodes: `if $x { }` is the nodes `if`,
|
|
116
|
+
`VariableName` and `Block` next to each other.
|
|
117
|
+
|
|
106
118
|
## Known limitations
|
|
107
119
|
|
|
108
120
|
Not supported yet:
|
|
109
121
|
|
|
110
122
|
- Nothing is highlighted in the replacement of `s/…/…/`, nor in
|
|
111
|
-
`tr/…/…/`.
|
|
123
|
+
`tr/…/…/`. The second pair of brackets of `tr[…][…]` is read as code.
|
|
124
|
+
A replacement that is a block of code with the delimiter in it, as in
|
|
125
|
+
`s/x/{ "a/b" }/`, ends at that delimiter.
|
|
112
126
|
- In a regex, a `<…>` is one
|
|
113
127
|
token, with the code or the nested `<…>` in it, and has to be closed on
|
|
114
128
|
its line unless it is a character class. Groups (`[ ]`, `( )`) and
|
|
@@ -131,9 +145,9 @@ Not supported yet:
|
|
|
131
145
|
to 10 lines. A longer one is not taken to be a word list. Nothing is
|
|
132
146
|
interpolated in a list that holds an unbalanced `{` or its own
|
|
133
147
|
delimiter: it is a single token.
|
|
134
|
-
- A Pod block
|
|
135
|
-
|
|
136
|
-
|
|
148
|
+
- A Pod block between a declarator and its name, as between `class` and
|
|
149
|
+
the name of the class, hides the name: the declaration then has no
|
|
150
|
+
`PackageName`. A comment there does not.
|
|
137
151
|
- In a quote that has braces for delimiters, a `{ }` is taken to be a
|
|
138
152
|
nested pair of the delimiters, not a block of code: the `{$b + 1}` of
|
|
139
153
|
`qq{a {$b + 1} c}` is text, in which `$b` is interpolated. With other
|
|
@@ -148,8 +162,9 @@ Not supported yet:
|
|
|
148
162
|
(`sub infix:<+++>`) and as a routine (`&infix:<+++>`). Where it is
|
|
149
163
|
used, it is an operator when it is made of operator characters or of
|
|
150
164
|
symbols outside of ASCII (`1 ⚡ 2`). One that is a word is a plain
|
|
151
|
-
name, also between hyper marks (`@a »plus« @b`)
|
|
152
|
-
|
|
165
|
+
name, also between hyper marks (`@a »plus« @b`). A term or a circumfix of one's own is not known: one that is
|
|
166
|
+
a symbol is highlighted as an operator, and one that is a letter
|
|
167
|
+
outside of the ranges for names, such as `ℵ`, is an error.
|
|
153
168
|
- The `native` declarator, which NativeCall uses internally, does not
|
|
154
169
|
make a declaration node.
|
|
155
170
|
- Completion does not know types. After a `.` it offers the built-in
|
|
@@ -159,7 +174,8 @@ Not supported yet:
|
|
|
159
174
|
`has`, in a signature, after the `->` of a pointy block, or by being a
|
|
160
175
|
placeholder variable (`$^a`, `$:a`). A sigilless variable is offered
|
|
161
176
|
when it is declared with a backslash (`my \x`, `sub f(\x)`, `-> \x`),
|
|
162
|
-
|
|
177
|
+
and a constant when it is declared with `constant`. A term that is
|
|
178
|
+
declared as a routine (`sub term:<x>`) is not offered.
|
|
163
179
|
- In a string, only the code in `{ }` and in a subscript is completed,
|
|
164
180
|
not the method name of `"$x.name()"`.
|
|
165
181
|
|
|
@@ -175,6 +191,16 @@ Heuristics that can be wrong:
|
|
|
175
191
|
the line before it does not end in a `;` or a `}`. Inside `( )` and
|
|
176
192
|
`[ ]`, indentation follows the brackets only.
|
|
177
193
|
- A capitalized word is taken to be a type name.
|
|
194
|
+
- A symbol outside of ASCII is taken to be an operator, whatever it was
|
|
195
|
+
declared as.
|
|
196
|
+
- A set operator in parentheses, such as `(elem)` or `(<=)`, is an
|
|
197
|
+
operator after a term and a space: `$a (elem) $b`. Right after the
|
|
198
|
+
term, the parentheses hold arguments: `$f(elem)`.
|
|
199
|
+
- An operator in brackets, `&[+]`, is a routine when the operator is at
|
|
200
|
+
most 11 characters long, and not after a term, where the `&` is an
|
|
201
|
+
operator.
|
|
202
|
+
- An operator name in double angles, as in `infix:<< plus >>`, has to
|
|
203
|
+
end within 20 characters of where it starts.
|
|
178
204
|
- Whether `/` starts a regex and `<` starts a word list is decided from
|
|
179
205
|
the token before it. After a bare name, spacing decides: `say /x/` and
|
|
180
206
|
`say <a b>` are a regex and a word list, `foo / 2` and `n < 3` are not.
|
|
@@ -183,7 +209,8 @@ Heuristics that can be wrong:
|
|
|
183
209
|
routine of your own has one of these names. After a closing brace, a
|
|
184
210
|
line break decides.
|
|
185
211
|
- A `<…>` right after a term is a subscript only when it holds plain words
|
|
186
|
-
on one line: `%h<key>`, but not `$a<$b
|
|
212
|
+
on one line: `%h<key>`, but not `$a<$b`, nor a key with a quote or
|
|
213
|
+
other punctuation in it (`%h<a"b>`). A `<<…>>` or `«…»` that touches
|
|
187
214
|
the term before it is a subscript when it is at most 24 characters
|
|
188
215
|
long and starts and ends in a word, a variable or a quote: `%h«$key»`,
|
|
189
216
|
but not the hyper operators of `@a<<+>>@b` and `@a«R-»@b`. A hyper
|
|
@@ -194,10 +221,14 @@ Heuristics that can be wrong:
|
|
|
194
221
|
between. One that is being typed takes the code up to there for its
|
|
195
222
|
content.
|
|
196
223
|
- In a `<<…>>` word list, a `>>` in a subscript or a call that is
|
|
197
|
-
interpolated ends the list: `<<@a[1 >> 2]
|
|
198
|
-
|
|
224
|
+
interpolated ends the list: `<<@a[1 >> 2]>>`, and so does the `>` of
|
|
225
|
+
a subscript right before the end, as in `<<x %h<b>>>`. A heredoc that
|
|
226
|
+
is opened in a block in a word list or in a regex literal is not read
|
|
227
|
+
as one.
|
|
199
228
|
- `q`, `qq`, `Q`, `m`, `rx`, `s`, `tr` and their variants start a quote
|
|
200
|
-
when a delimiter follows directly
|
|
229
|
+
when a delimiter follows directly: a bracket, one of
|
|
230
|
+
``/ ! | ~ ^ % @ " ' ` ``, or a symbol outside of ASCII. So a
|
|
231
|
+
sigilless `s/2` is misread.
|
|
201
232
|
`q`, `qq` and `Q` also take a bracket after blanks (`q {…}`), so a
|
|
202
233
|
routine or a sigilless variable of your own named `q`, before a block
|
|
203
234
|
or a subscript, is misread. The
|
|
@@ -213,12 +244,23 @@ Heuristics that can be wrong:
|
|
|
213
244
|
as a method name, as a declared name, before `=>`, and for the
|
|
214
245
|
keywords that are routines (`take`, `return`, `next`, `not`, …) right
|
|
215
246
|
before a `(`: `take(1)`. A sigilless variable or a routine of your own
|
|
216
|
-
that is named like a keyword is highlighted as one
|
|
247
|
+
that is named like a keyword is highlighted as one, and a declarator
|
|
248
|
+
that is called, as in `method($n)`, starts a declaration.
|
|
249
|
+
- In a regex, a curly quote or a corner quote opens a quote, as Raku
|
|
250
|
+
has it. A lone one, as in `/‘/`, takes the text up to the next
|
|
251
|
+
closing quote on its line.
|
|
252
|
+
- A `$/` in the replacement of `s/…/…/` is the match variable when a `/`
|
|
253
|
+
follows on the same line, and a `$` before the closing delimiter
|
|
254
|
+
otherwise.
|
|
255
|
+
- A `:sym<…>` after the name of a declaration and blanks is part of the
|
|
256
|
+
name, also for a declaration that is not a regex.
|
|
217
257
|
- A quote that does not interpolate (`'…'`, `q{…}`), a regex and a
|
|
218
258
|
heredoc have to be closed. Otherwise their opener is read as ordinary
|
|
219
259
|
code.
|
|
220
260
|
- A quote that interpolates (`"…`, `qq[…`), a Pod block or an embedded
|
|
221
|
-
comment that is not closed runs to the end of the document.
|
|
261
|
+
comment that is not closed runs to the end of the document. A
|
|
262
|
+
declarator comment with brackets (`#|( …`) that is not closed ends
|
|
263
|
+
with its line.
|
|
222
264
|
- The body of a regex declaration that is not closed runs up to the next
|
|
223
265
|
line that starts a `token`, `rule` or `regex` declaration, or to the
|
|
224
266
|
end of the document.
|
|
@@ -233,17 +275,18 @@ npm run dev # serves demo/, an editor next to the syntax tree of its content
|
|
|
233
275
|
|
|
234
276
|
The demo loads the sources, so a change to the grammar shows up on reload.
|
|
235
277
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
278
|
+
Changes go in through pull requests. A pull request that changes what
|
|
279
|
+
users get adds its entry under `## [Unreleased]` in `CHANGELOG.md`. One
|
|
280
|
+
that adds a feature also adds a sample of it to
|
|
281
|
+
`test/fixtures/new-in-<next minor version>.raku` (`new-in-0.5.raku`, say),
|
|
282
|
+
and is labelled `enhancement` to make the next release a minor one.
|
|
283
|
+
|
|
284
|
+
Releases are made with [tagpr](https://github.com/Songmu/tagpr). It keeps
|
|
285
|
+
a release pull request open that bumps the version and turns
|
|
286
|
+
`## [Unreleased]` into the version's section. Merging it tags the merge
|
|
287
|
+
commit, and a workflow then publishes the version to npm with Trusted
|
|
288
|
+
Publishing and creates the GitHub release from the section of
|
|
289
|
+
`CHANGELOG.md`.
|
|
247
290
|
|
|
248
291
|
## License
|
|
249
292
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codemirror-lang-raku",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Raku (formerly Perl 6) language support for CodeMirror",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemirror",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"pretest": "npm run build",
|
|
22
22
|
"test": "mocha test/test.js",
|
|
23
23
|
"prepare": "npm run build",
|
|
24
|
-
"prepublishOnly": "
|
|
24
|
+
"prepublishOnly": "node -e \"if (!process.env.GITHUB_ACTIONS) { console.error('Publish by merging the release pull request (AGENTS.md)'); process.exit(1) }\"",
|
|
25
25
|
"dev": "vite demo",
|
|
26
26
|
"build:demo": "vite build demo"
|
|
27
27
|
},
|