@exercism/codemirror-lang-red 1.0.0 → 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 +4 -0
- package/README.md +61 -67
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,71 +1,11 @@
|
|
|
1
1
|
# @exercism/codemirror-lang-red
|
|
2
2
|
|
|
3
|
-
## This fork
|
|
4
|
-
|
|
5
|
-
This is Exercism's fork of
|
|
6
|
-
[`@codincod/codemirror-lang-rebol`](https://codeberg.org/reeven/codemirror-lang-rebol)
|
|
7
|
-
by CodinCod, released under the MIT license. Exercism uses it in the Red
|
|
8
|
-
editor on [exercism.org](https://exercism.org). Our changes live on the
|
|
9
|
-
`main` branch, and are published as `@exercism/codemirror-lang-red`.
|
|
10
|
-
|
|
11
|
-
The fork adds tree nodes for functions and loops:
|
|
12
|
-
|
|
13
|
-
- `func`, `function`, `has`, `funct` and `closure` make a `Function` node,
|
|
14
|
-
with a `ParamList` for the spec and a `Body`. Each argument and local in
|
|
15
|
-
the spec is a `Param`, which is highlighted as a definition.
|
|
16
|
-
- `foreach`, `repeat`, `remove-each`, `map-each` and `for` make a `Loop`
|
|
17
|
-
node, and each word that they set is a `LoopVar`.
|
|
18
|
-
- In Red, every function available when a Red console starts is highlighted as a builtin.
|
|
19
|
-
|
|
20
|
-
It also adds completion, through `red()`:
|
|
21
|
-
|
|
22
|
-
- The functions, datatypes and constants available when Red starts. The list
|
|
23
|
-
comes from Red's own source, read by `scripts/red-words.mjs`, which copies
|
|
24
|
-
only names and signatures.
|
|
25
|
-
- After a `/`, the refinements of the function, for Red's functions and for
|
|
26
|
-
the functions in the file.
|
|
27
|
-
- Snippets for `func`, `function`, `does`, `has`, objects, `if`, `unless`,
|
|
28
|
-
`either`, `case`, `switch`, `foreach`, `repeat`, `loop`, `while`, `until`,
|
|
29
|
-
`collect` and `parse`.
|
|
30
|
-
- The words set in the file. Inside a function, its arguments, refinements
|
|
31
|
-
and locals are offered too. In a `function`, the set-words in the body are
|
|
32
|
-
locals, as Red makes them, so they are offered inside that function and
|
|
33
|
-
nowhere else.
|
|
34
|
-
- The words of `parse` inside its rules, and `keep` inside `collect`.
|
|
35
|
-
|
|
36
|
-
Nothing is offered inside strings, comments and the other literal values.
|
|
37
|
-
`rebol()` offers the words set in the file, without Red's lists.
|
|
38
|
-
|
|
39
|
-
To update the word list from a checkout of Red:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npm run words -- ../red
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Install
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
npm install @exercism/codemirror-lang-red
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Exercism's Red editor calls `red()`:
|
|
52
|
-
|
|
53
|
-
```javascript
|
|
54
|
-
import {EditorView, basicSetup} from "codemirror"
|
|
55
|
-
import {red} from "@exercism/codemirror-lang-red"
|
|
56
|
-
|
|
57
|
-
new EditorView({
|
|
58
|
-
parent: document.body,
|
|
59
|
-
doc: `Red []\nprint "Hello, World!"\n`,
|
|
60
|
-
extensions: [basicSetup, red()]
|
|
61
|
-
})
|
|
62
|
-
```
|
|
63
|
-
|
|
64
3
|
This package implements [Rebol](http://www.rebol.com/) and
|
|
65
4
|
[Red](https://www.red-lang.org/) language support for the
|
|
66
5
|
[CodeMirror](https://codemirror.net/) code editor: a
|
|
67
6
|
[Lezer](https://lezer.codemirror.net/) grammar, highlighting, folding and
|
|
68
|
-
indentation.
|
|
7
|
+
indentation. Exercism uses it in the Red editor on
|
|
8
|
+
[exercism.org](https://exercism.org).
|
|
69
9
|
|
|
70
10
|
Two languages, one lexer. Red is a second implementation of Rebol's syntax with
|
|
71
11
|
a preprocessor of its own, and Red/System, which a `.reds` file is written in,
|
|
@@ -82,11 +22,13 @@ itself colours these two languages with, and
|
|
|
82
22
|
[Pygments' `rebol.py`](https://github.com/pygments/pygments/blob/master/pygments/lexers/rebol.py),
|
|
83
23
|
which keeps both lexers in one file for the same reason this package does.
|
|
84
24
|
|
|
85
|
-
|
|
86
|
-
platform, where it colours the editor people solve puzzles in.
|
|
25
|
+
This code is released under an [MIT license](LICENSE).
|
|
87
26
|
|
|
88
|
-
|
|
89
|
-
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
npm install @exercism/codemirror-lang-red
|
|
31
|
+
```
|
|
90
32
|
|
|
91
33
|
## Usage
|
|
92
34
|
|
|
@@ -113,6 +55,46 @@ greet "world"
|
|
|
113
55
|
|
|
114
56
|
`red()` is the same grammar with Red's preprocessor recognised.
|
|
115
57
|
|
|
58
|
+
Exercism's Red editor calls `red()`:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
import {EditorView, basicSetup} from "codemirror"
|
|
62
|
+
import {red} from "@exercism/codemirror-lang-red"
|
|
63
|
+
|
|
64
|
+
new EditorView({
|
|
65
|
+
parent: document.body,
|
|
66
|
+
doc: `Red []\nprint "Hello, World!"\n`,
|
|
67
|
+
extensions: [basicSetup, red()]
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Completion
|
|
72
|
+
|
|
73
|
+
`red()` offers completion of:
|
|
74
|
+
|
|
75
|
+
- The functions, datatypes and constants available when Red starts. The list
|
|
76
|
+
comes from Red's own source, read by `scripts/red-words.mjs`, which copies
|
|
77
|
+
only names and signatures.
|
|
78
|
+
- After a `/`, the refinements of the function, for Red's functions and for
|
|
79
|
+
the functions in the file.
|
|
80
|
+
- Snippets for `func`, `function`, `does`, `has`, objects, `if`, `unless`,
|
|
81
|
+
`either`, `case`, `switch`, `foreach`, `repeat`, `loop`, `while`, `until`,
|
|
82
|
+
`collect` and `parse`.
|
|
83
|
+
- The words set in the file. Inside a function, its arguments, refinements
|
|
84
|
+
and locals are offered too. In a `function`, the set-words in the body are
|
|
85
|
+
locals, as Red makes them, so they are offered inside that function and
|
|
86
|
+
nowhere else.
|
|
87
|
+
- The words of `parse` inside its rules, and `keep` inside `collect`.
|
|
88
|
+
|
|
89
|
+
Nothing is offered inside strings, comments and the other literal values.
|
|
90
|
+
`rebol()` offers the words set in the file, without Red's lists.
|
|
91
|
+
|
|
92
|
+
To update the word list from a checkout of Red:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm run words -- ../red
|
|
96
|
+
```
|
|
97
|
+
|
|
116
98
|
## What it reads
|
|
117
99
|
|
|
118
100
|
Rebol states the whole of its syntax in a sentence. A block is a series of
|
|
@@ -146,6 +128,13 @@ is why `if a <b [...]` is a syntax error in a language that has no syntax.
|
|
|
146
128
|
is the brace that does not count. That is how a string holding a line break is
|
|
147
129
|
written, and it is why the string scanner cannot be a regular expression.
|
|
148
130
|
|
|
131
|
+
**Functions and loops have their own nodes.** `func`, `function`, `has`,
|
|
132
|
+
`funct` and `closure` make a `Function` node, with a `ParamList` for the spec
|
|
133
|
+
and a `Body`. Each argument and local in the spec is a `Param`, which is
|
|
134
|
+
highlighted as a definition. `foreach`, `repeat`, `remove-each`, `map-each` and
|
|
135
|
+
`for` make a `Loop` node, and each word that they set is a `LoopVar`. In Red,
|
|
136
|
+
every function available when a Red console starts is highlighted as a builtin.
|
|
137
|
+
|
|
149
138
|
## What the clean figure is worth
|
|
150
139
|
|
|
151
140
|
Almost nothing, and it is worth saying so.
|
|
@@ -180,7 +169,7 @@ fourth language the extensions collect.
|
|
|
180
169
|
A block written in a dialect is a block of ordinary values that another function
|
|
181
170
|
interprets. `parse [some rules]` and `draw [line 0x0 10x10]` are coloured as
|
|
182
171
|
the values they are made of, because a grammar that coloured them as a dialect
|
|
183
|
-
would be guessing at a binding it cannot see. This
|
|
172
|
+
would be guessing at a binding it cannot see. This package makes one exception:
|
|
184
173
|
the spec after `func` and the other function words is read as a spec, because
|
|
185
174
|
the arguments in it are what completion needs.
|
|
186
175
|
|
|
@@ -202,3 +191,8 @@ to redistribute. [red/red](https://github.com/red/red),
|
|
|
202
191
|
[rebol/rebol](https://github.com/rebol/rebol) are what these figures were taken
|
|
203
192
|
against, and `rebol.org`'s script library is the larger collection of code
|
|
204
193
|
people wrote by hand.
|
|
194
|
+
|
|
195
|
+
## Contributing
|
|
196
|
+
|
|
197
|
+
Please read about how to [contribute to Exercism](https://exercism.org/docs/building).
|
|
198
|
+
Be sure to read the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exercism/codemirror-lang-red",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Red and Rebol language support for the CodeMirror code editor, with completion, as used on Exercism",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"homepage": "https://github.com/exercism/codemirror-lang-rebol",
|
|
48
48
|
"repository": {
|
|
49
49
|
"type": "git",
|
|
50
|
-
"url": "https://github.com/exercism/codemirror-lang-rebol"
|
|
50
|
+
"url": "git+https://github.com/exercism/codemirror-lang-rebol.git"
|
|
51
51
|
},
|
|
52
52
|
"bugs": {
|
|
53
53
|
"url": "https://github.com/exercism/codemirror-lang-rebol/issues"
|