codemirror-lang-raku 0.3.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 CHANGED
@@ -1,4 +1,70 @@
1
- ## 0.3.0 (2026-10-07)
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
22
+
23
+ Most of this was found by parsing the test suite of
24
+ [mutsu](https://github.com/tokuhirom/mutsu), an implementation of Raku.
25
+
26
+ ### Breaking changes
27
+
28
+ - The name of a constant with a sigil, as in `constant $LIMIT = 3`, is a
29
+ `ConstantName` inside the `ConstantDeclaration`. It was a
30
+ `VariableName` after the declaration, which had no name.
31
+ - A `:sym<…>` that follows the name of a declaration after blanks, as in
32
+ `token word :sym<long> { }`, is part of the `RegexName`.
33
+ - A declarator comment with brackets, `#|( … )` or `#=( … )`, is one
34
+ `DocComment` up to its closing bracket. It ended with its first line,
35
+ and still does when the bracket is not closed.
36
+
37
+ ### New features
38
+
39
+ - Corner quotes (`「…」`), also after a quote word (`Q「…」`), the low
40
+ curly quotes (`„…”`, `„…“`, `‚…’`, `‚…‘`) and the reversed `”…”`.
41
+ - A quote word takes a backtick or a symbol outside of ASCII for a
42
+ delimiter: ``qx`…` ``, `Q♥…♥`.
43
+ - Fractions that are one character (`½`, `⅔`) are numbers, and a power
44
+ in superscript (`$x²`) is an operator.
45
+ - Symbols outside of ASCII are operators: the atomic operators
46
+ (`⚛+=`), and the operators of one's own (`1 ⚡ 2`).
47
+ - The set operators that are written in parentheses, as in
48
+ `$a (<=) $b` and `$x (elem) $s`, are operators.
49
+ - An operator in brackets as a routine, as in `&[+]`, is a
50
+ `VariableName`.
51
+ - The name of an operator can be written in double angles:
52
+ `infix:<< plus-one >>`, `&infix:<<(>=)>>`.
53
+ - The variable `$¢`.
54
+
55
+ ### Bug fixes
56
+
57
+ - In a regex, `‘…’`, `“…”`, `‚…’`, `„…”` and `「…」` are quotes, in which
58
+ the delimiter of the regex does not end it: `m/ab ‘/’ c/`.
59
+ - A list of words in a regex, `/ < a ' b > /`, no longer starts a quote
60
+ at a `'` in it.
61
+ - A regex does not end at its delimiter in code: in the arguments of an
62
+ assertion (`<name: /a/ >`, `<:name(/a/)>`), in `$( … )`, and in a
63
+ declaration (`:my $m = $/;`).
64
+ - A `$/` in the replacement of a substitution does not end it:
65
+ `s/(a)/[$/]/`.
66
+
67
+ ## [0.3.0] - 2026-10-07
2
68
 
3
69
  ### Breaking changes
4
70
 
@@ -18,7 +84,7 @@
18
84
  quote that interpolates and spans several lines followed the opener
19
85
  of the heredoc on its line.
20
86
 
21
- ## 0.2.0 (2026-10-07)
87
+ ## [0.2.0] - 2026-10-07
22
88
 
23
89
  ### New features
24
90
 
@@ -84,7 +150,7 @@
84
150
  longer starts a heredoc. Heredocs are now found from the quote tokens
85
151
  of the line, not from its text.
86
152
 
87
- ## 0.1.0 (2026-10-06)
153
+ ## [0.1.0] - 2026-10-06
88
154
 
89
155
  ### New features
90
156
 
@@ -100,3 +166,9 @@ First release.
100
166
  of Pod blocks, heredocs and embedded comments
101
167
  - Completion of keywords and of the commonly used built-in types,
102
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 (`'…'`, `"…"`, `q` / `qq` /
13
- `Q` with any delimiter, heredocs, `<word lists>`) with interpolation,
14
- regexes, numbers, variables with sigils and twigils, keywords, operators,
15
- blocks and declarations.
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.
@@ -87,33 +88,48 @@ on incomplete code.
87
88
  |---|---|
88
89
  | `PackageDeclaration` | `class`, `role`, `grammar`, `module`, `package`, with a `PackageName` child, up to the body `Block` or the `;` of a `unit` declaration |
89
90
  | `RoutineDeclaration` | `sub`, `method`, `submethod`, with a `RoutineName` child (absent for anonymous routines), up to the body `Block`. Also the `foo(…) { }` of `multi foo(…) { }`, which declares a sub without the word `sub`: that node starts with its `RoutineName` |
90
- | `RegexDeclaration` | `token`, `rule`, `regex`, with a `RegexName` child, up to the body `Block`, which holds one `Regex` |
91
- | `EnumDeclaration`, `SubsetDeclaration`, `ConstantDeclaration` | The declarator and its `EnumName`, `SubsetName` or `ConstantName` |
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>`) |
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 declarator keyword is a child node named after the keyword (`class`,
101
- `sub`, `token`, …). The words `unit`, `multi`, `proto`, `only`, `my` and
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
115
129
  adverbs (`:i`, `:my`) are plain text, so the text after `:my` is read
116
- as regex.
130
+ as regex, and so is the code in `$( … )`. Such code does not end the
131
+ regex when it holds the delimiter (`/ :my $m = $/; /`), if it is on
132
+ one line.
117
133
  - A heredoc is interpolated when everything interpolates in it, as in
118
134
  `qq:to`. One that interpolates in part (`q:c:to`, `qq:!s:to`) is not
119
135
  highlighted inside. When a line opens several heredocs, they are
@@ -129,9 +145,13 @@ Not supported yet:
129
145
  to 10 lines. A longer one is not taken to be a word list. Nothing is
130
146
  interpolated in a list that holds an unbalanced `{` or its own
131
147
  delimiter: it is a single token.
132
- - A Pod block is read where a statement or a term can stand, not
133
- everywhere that whitespace can: one between `class` and the name of
134
- the class is not read as Pod.
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.
151
+ - In a quote that has braces for delimiters, a `{ }` is taken to be a
152
+ nested pair of the delimiters, not a block of code: the `{$b + 1}` of
153
+ `qq{a {$b + 1} c}` is text, in which `$b` is interpolated. With other
154
+ delimiters, as in `qq[a {$b + 1} c]`, it is a block.
135
155
  - A quote adverb is switched off by the argument `False` or `0`, as in
136
156
  `qq:c(False)[…]`. With any other argument, such as a variable, it
137
157
  counts as switched on.
@@ -139,8 +159,14 @@ Not supported yet:
139
159
  command. Text that unbalances every bracket that is tried gets
140
160
  `` #`( `` … `)`, which then does not cover exactly that text.
141
161
  - A user-defined operator is recognized where it is declared
142
- (`sub infix:<+++>`) and as a routine (`&infix:<+++>`), not where it is
143
- used as an operator.
162
+ (`sub infix:<+++>`) and as a routine (`&infix:<+++>`). Where it is
163
+ used, it is an operator when it is made of operator characters or of
164
+ symbols outside of ASCII (`1 ⚡ 2`). One that is a word is a plain
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.
168
+ - The `native` declarator, which NativeCall uses internally, does not
169
+ make a declaration node.
144
170
  - Completion does not know types. After a `.` it offers the built-in
145
171
  methods and every method that the document declares, whatever the
146
172
  invocant is. Names from other files are not offered.
@@ -148,7 +174,8 @@ Not supported yet:
148
174
  `has`, in a signature, after the `->` of a pointy block, or by being a
149
175
  placeholder variable (`$^a`, `$:a`). A sigilless variable is offered
150
176
  when it is declared with a backslash (`my \x`, `sub f(\x)`, `-> \x`),
151
- not as a term (`my constant x`, `sub term:<x>`).
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.
152
179
  - In a string, only the code in `{ }` and in a subscript is completed,
153
180
  not the method name of `"$x.name()"`.
154
181
 
@@ -164,6 +191,16 @@ Heuristics that can be wrong:
164
191
  the line before it does not end in a `;` or a `}`. Inside `( )` and
165
192
  `[ ]`, indentation follows the brackets only.
166
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.
167
204
  - Whether `/` starts a regex and `<` starts a word list is decided from
168
205
  the token before it. After a bare name, spacing decides: `say /x/` and
169
206
  `say <a b>` are a regex and a word list, `foo / 2` and `n < 3` are not.
@@ -172,7 +209,8 @@ Heuristics that can be wrong:
172
209
  routine of your own has one of these names. After a closing brace, a
173
210
  line break decides.
174
211
  - A `<…>` right after a term is a subscript only when it holds plain words
175
- on one line: `%h<key>`, but not `$a<$b`. A `<<…>>` or `«…»` that touches
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
176
214
  the term before it is a subscript when it is at most 24 characters
177
215
  long and starts and ends in a word, a variable or a quote: `%h«$key»`,
178
216
  but not the hyper operators of `@a<<+>>@b` and `@a«R-»@b`. A hyper
@@ -183,10 +221,14 @@ Heuristics that can be wrong:
183
221
  between. One that is being typed takes the code up to there for its
184
222
  content.
185
223
  - In a `<<…>>` word list, a `>>` in a subscript or a call that is
186
- interpolated ends the list: `<<@a[1 >> 2]>>`. A heredoc that is opened
187
- in a block in a word list or in a regex literal is not read as one.
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.
188
228
  - `q`, `qq`, `Q`, `m`, `rx`, `s`, `tr` and their variants start a quote
189
- when a delimiter follows directly, so a sigilless `s/2` is misread.
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.
190
232
  `q`, `qq` and `Q` also take a bracket after blanks (`q {…}`), so a
191
233
  routine or a sigilless variable of your own named `q`, before a block
192
234
  or a subscript, is misread. The
@@ -202,12 +244,23 @@ Heuristics that can be wrong:
202
244
  as a method name, as a declared name, before `=>`, and for the
203
245
  keywords that are routines (`take`, `return`, `next`, `not`, …) right
204
246
  before a `(`: `take(1)`. A sigilless variable or a routine of your own
205
- 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.
206
257
  - A quote that does not interpolate (`'…'`, `q{…}`), a regex and a
207
258
  heredoc have to be closed. Otherwise their opener is read as ordinary
208
259
  code.
209
260
  - A quote that interpolates (`"…`, `qq[…`), a Pod block or an embedded
210
- 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.
211
264
  - The body of a regex declaration that is not closed runs up to the next
212
265
  line that starts a `token`, `rule` or `regex` declaration, or to the
213
266
  end of the document.
@@ -222,17 +275,18 @@ npm run dev # serves demo/, an editor next to the syntax tree of its content
222
275
 
223
276
  The demo loads the sources, so a change to the grammar shows up on reload.
224
277
 
225
- To release a version:
226
-
227
- 1. Run `npm version 1.2.3 --no-git-tag-version`, and turn the
228
- `## Unreleased` heading of `CHANGELOG.md` into `## 1.2.3 (2026-01-31)`.
229
- Commit and push.
230
- 2. Run `npm publish` from that commit. It first runs the tests and checks
231
- that `CHANGELOG.md` has that section and that nothing is uncommitted.
232
- 3. Tag that commit `v1.2.3` and push the tag. A workflow then checks that
233
- the tag matches `package.json` and that npm has the version, published
234
- from that commit, and creates the GitHub release from the section of
235
- `CHANGELOG.md`.
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`.
236
290
 
237
291
  ## License
238
292