trebol 0.1.1 → 0.1.2
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/README.md +10 -1
- package/dist/cli.js +13747 -11409
- package/dist/fonts/OFL.txt +93 -0
- package/dist/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/dist/fonts/inter-cyrillic.woff2 +0 -0
- package/dist/fonts/inter-greek-ext.woff2 +0 -0
- package/dist/fonts/inter-greek.woff2 +0 -0
- package/dist/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/fonts/inter-latin.woff2 +0 -0
- package/dist/fonts/inter-vietnamese.woff2 +0 -0
- package/dist/lib/core/boot.js +2 -1
- package/dist/lib/core/func.d.ts +4 -0
- package/dist/lib/core/natives/control.js +1 -1
- package/dist/lib/core/natives/series.js +11 -1
- package/dist/lib/core/natives/text.js +3 -0
- package/dist/lib/host/browser.js +951 -58
- package/dist/lib/host/devlog.d.ts +11 -0
- package/dist/lib/host/devlog.js +13 -0
- package/dist/lib/host/devtools.d.ts +23 -0
- package/dist/lib/host/devtools.js +626 -0
- package/dist/lib/host/fonts/OFL.txt +93 -0
- package/dist/lib/host/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-cyrillic.woff2 +0 -0
- package/dist/lib/host/fonts/inter-greek-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-greek.woff2 +0 -0
- package/dist/lib/host/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-latin.woff2 +0 -0
- package/dist/lib/host/fonts/inter-vietnamese.woff2 +0 -0
- package/dist/lib/host/fonts.d.ts +11 -0
- package/dist/lib/host/fonts.js +29 -0
- package/dist/lib/host/index.d.ts +2 -0
- package/dist/lib/host/index.js +3 -1
- package/dist/lib/host/js.d.ts +5 -0
- package/dist/lib/host/js.js +130 -0
- package/dist/lib/host/markdown.d.ts +2 -0
- package/dist/lib/host/markdown.js +10 -0
- package/dist/lib/host/modules.d.ts +4 -0
- package/dist/lib/host/modules.js +39 -1
- package/dist/lib/host/net.js +9 -1
- package/dist/lib/host/orbit.d.ts +121 -0
- package/dist/lib/host/orbit.js +374 -0
- package/dist/lib/host/rows.d.ts +14 -0
- package/dist/lib/host/rows.js +29 -0
- package/dist/lib/host/scheduler.d.ts +6 -0
- package/dist/lib/host/scheduler.js +60 -36
- package/dist/lib/host/theme.js +207 -2
- package/dist/lib/ui/i18n.trb +6 -0
- package/dist/lib/ui/test.trb +565 -0
- package/dist/lib/ui/ui.trb +523 -82
- package/dist/trebol.js +1346 -124
- package/editors/vscode/README.md +15 -0
- package/editors/vscode/language-configuration.json +28 -0
- package/editors/vscode/package.json +42 -0
- package/editors/vscode/syntaxes/trebol.tmLanguage.json +237 -0
- package/package.json +7 -3
- package/src/core/boot.ts +1 -1
- package/src/core/func.ts +4 -0
- package/src/core/natives/control.ts +1 -1
- package/src/core/natives/series.ts +9 -1
- package/src/core/natives/text.ts +2 -0
- package/src/host/browser.ts +962 -51
- package/src/host/devlog.ts +16 -0
- package/src/host/devtools.ts +641 -0
- package/src/host/fonts/OFL.txt +93 -0
- package/src/host/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/src/host/fonts/inter-cyrillic.woff2 +0 -0
- package/src/host/fonts/inter-greek-ext.woff2 +0 -0
- package/src/host/fonts/inter-greek.woff2 +0 -0
- package/src/host/fonts/inter-latin-ext.woff2 +0 -0
- package/src/host/fonts/inter-latin.woff2 +0 -0
- package/src/host/fonts/inter-vietnamese.woff2 +0 -0
- package/src/host/fonts.ts +39 -0
- package/src/host/index.ts +3 -1
- package/src/host/js.ts +127 -0
- package/src/host/markdown.ts +9 -0
- package/src/host/modules.ts +33 -1
- package/src/host/net.ts +9 -1
- package/src/host/orbit.ts +432 -0
- package/src/host/rows.ts +30 -0
- package/src/host/scheduler.ts +62 -36
- package/src/host/theme.ts +207 -2
- package/src/ui/i18n.trb +6 -0
- package/src/ui/test.trb +565 -0
- package/src/ui/ui.trb +523 -82
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Trebol for Visual Studio Code
|
|
2
|
+
|
|
3
|
+
Colors for [Trebol](https://github.com/acasadom/trebol) `.trb` files: comments, strings and escapes, every
|
|
4
|
+
literal datatype (numbers, money, dates, times, pairs, tuples, files, urls, emails, tags, binaries), set-words,
|
|
5
|
+
get-words, lit-words, refinements, datatypes, and the words of control flow. `;` comments a line out, and
|
|
6
|
+
brackets close and indent themselves.
|
|
7
|
+
|
|
8
|
+
To install it, copy this folder into VS Code's extensions folder and restart VS Code:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
cp -R node_modules/trebol/editors/vscode ~/.vscode/extensions/trebol
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The grammar is written by `tools/grammar.ts` (`npm run grammar`) from the rules of Trebol's lexer;
|
|
15
|
+
`test/grammar.test.ts` checks it colors every `.trb` file of the repository the way `load` reads it.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"comments": {
|
|
3
|
+
"lineComment": ";"
|
|
4
|
+
},
|
|
5
|
+
"brackets": [
|
|
6
|
+
["[", "]"],
|
|
7
|
+
["(", ")"],
|
|
8
|
+
["{", "}"]
|
|
9
|
+
],
|
|
10
|
+
"autoClosingPairs": [
|
|
11
|
+
{ "open": "[", "close": "]" },
|
|
12
|
+
{ "open": "(", "close": ")" },
|
|
13
|
+
{ "open": "{", "close": "}" },
|
|
14
|
+
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] }
|
|
15
|
+
],
|
|
16
|
+
"surroundingPairs": [
|
|
17
|
+
["[", "]"],
|
|
18
|
+
["(", ")"],
|
|
19
|
+
["{", "}"],
|
|
20
|
+
["\"", "\""],
|
|
21
|
+
["<", ">"]
|
|
22
|
+
],
|
|
23
|
+
"wordPattern": "[^\\s@#$%^,:'/\\\\\"()\\[\\]{};]+",
|
|
24
|
+
"indentationRules": {
|
|
25
|
+
"increaseIndentPattern": "[\\[(]\\s*(;.*)?$",
|
|
26
|
+
"decreaseIndentPattern": "^\\s*[\\])]"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "trebol",
|
|
3
|
+
"displayName": "Trebol",
|
|
4
|
+
"description": "Syntax highlighting for Trebol (.trb files)",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"publisher": "acasadom",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"homepage": "https://github.com/acasadom/trebol",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/acasadom/trebol.git",
|
|
12
|
+
"directory": "editors/vscode"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"vscode": "^1.75.0"
|
|
16
|
+
},
|
|
17
|
+
"categories": [
|
|
18
|
+
"Programming Languages"
|
|
19
|
+
],
|
|
20
|
+
"contributes": {
|
|
21
|
+
"languages": [
|
|
22
|
+
{
|
|
23
|
+
"id": "trebol",
|
|
24
|
+
"aliases": [
|
|
25
|
+
"Trebol",
|
|
26
|
+
"trebol"
|
|
27
|
+
],
|
|
28
|
+
"extensions": [
|
|
29
|
+
".trb"
|
|
30
|
+
],
|
|
31
|
+
"configuration": "./language-configuration.json"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"grammars": [
|
|
35
|
+
{
|
|
36
|
+
"language": "trebol",
|
|
37
|
+
"scopeName": "source.trebol",
|
|
38
|
+
"path": "./syntaxes/trebol.tmLanguage.json"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
3
|
+
"name": "Trebol",
|
|
4
|
+
"scopeName": "source.trebol",
|
|
5
|
+
"fileTypes": [
|
|
6
|
+
"trb"
|
|
7
|
+
],
|
|
8
|
+
"patterns": [
|
|
9
|
+
{
|
|
10
|
+
"include": "#value"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"value": {
|
|
15
|
+
"patterns": [
|
|
16
|
+
{
|
|
17
|
+
"include": "#comment"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"include": "#string"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"include": "#braced"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"include": "#hash"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"include": "#tag"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"include": "#file"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"include": "#scalar"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"include": "#word"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"include": "#path"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"include": "#bracket"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"comment": {
|
|
49
|
+
"match": ";.*$",
|
|
50
|
+
"name": "comment.line.semicolon.trebol"
|
|
51
|
+
},
|
|
52
|
+
"escape": {
|
|
53
|
+
"match": "\\^(?:\\([^)]*\\)|.)",
|
|
54
|
+
"name": "constant.character.escape.trebol"
|
|
55
|
+
},
|
|
56
|
+
"string": {
|
|
57
|
+
"begin": "\"",
|
|
58
|
+
"end": "\"|$",
|
|
59
|
+
"name": "string.quoted.double.trebol",
|
|
60
|
+
"patterns": [
|
|
61
|
+
{
|
|
62
|
+
"include": "#escape"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"braced": {
|
|
67
|
+
"begin": "\\{",
|
|
68
|
+
"end": "\\}",
|
|
69
|
+
"name": "string.quoted.other.braces.trebol",
|
|
70
|
+
"patterns": [
|
|
71
|
+
{
|
|
72
|
+
"include": "#escape"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"include": "#braced-inner"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"braced-inner": {
|
|
80
|
+
"begin": "\\{",
|
|
81
|
+
"end": "\\}",
|
|
82
|
+
"patterns": [
|
|
83
|
+
{
|
|
84
|
+
"include": "#escape"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"include": "#braced-inner"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"hash": {
|
|
92
|
+
"patterns": [
|
|
93
|
+
{
|
|
94
|
+
"match": "#\"(?:\\^(?:\\([^)]*\\)|.)|[^\"])\"",
|
|
95
|
+
"name": "constant.character.trebol"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"begin": "(?<![^\\s\\[\\](){}\"])(?:2|16|64)?#\\{",
|
|
99
|
+
"end": "\\}",
|
|
100
|
+
"name": "constant.other.binary.trebol"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"match": "#[\\[(]",
|
|
104
|
+
"name": "punctuation.definition.construction.trebol"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:#[^\\s\\[\\](){}\";]+)(?=[\\s\\[\\](){}\";]|$)",
|
|
108
|
+
"name": "constant.other.issue.trebol"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"tag": {
|
|
113
|
+
"begin": "<(?=[A-Za-z/!?])",
|
|
114
|
+
"end": ">",
|
|
115
|
+
"name": "entity.name.tag.trebol",
|
|
116
|
+
"patterns": [
|
|
117
|
+
{
|
|
118
|
+
"begin": "\"",
|
|
119
|
+
"end": "\""
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"begin": "'",
|
|
123
|
+
"end": "'"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
"file": {
|
|
128
|
+
"patterns": [
|
|
129
|
+
{
|
|
130
|
+
"begin": "%\"",
|
|
131
|
+
"end": "\"|$",
|
|
132
|
+
"name": "string.quoted.double.file.trebol"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:%(?!%?:?(?:[\\s\\[\\](){}\";]|$))[^\\s\\[\\](){}\";]+)(?=[\\s\\[\\](){}\";]|$)",
|
|
136
|
+
"name": "string.unquoted.file.trebol"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
"scalar": {
|
|
141
|
+
"patterns": [
|
|
142
|
+
{
|
|
143
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:[A-Za-z][A-Za-z0-9+.\\-]*:[^\\s\\[\\](){}\";]+)(?=[\\s\\[\\](){}\";]|$)",
|
|
144
|
+
"name": "markup.underline.link.url.trebol"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:[^@/\\s\\[\\](){}\";][^@\\s\\[\\](){}\";]*@[^@\\s\\[\\](){}\";]*)(?=[\\s\\[\\](){}\";]|$)",
|
|
148
|
+
"name": "string.unquoted.email.trebol"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:[+-]?(?:[A-Za-z]{3})?\\$[+-]?(?:\\d[\\d']*(?:[.,]\\d*)?|[.,]\\d+))(?=[\\s\\[\\](){}\";]|$)",
|
|
152
|
+
"name": "constant.numeric.money.trebol"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:\\d+([-/])(?:[A-Za-z]+|\\d+)\\1\\d+(?:[/T][^\\s\\[\\](){}\";]+)?)(?=[\\s\\[\\](){}\";]|$)",
|
|
156
|
+
"name": "constant.numeric.date.trebol"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:[+-]?\\d+:\\d+(?::\\d+(?:[.,]\\d+)?)?)(?=[\\s\\[\\](){}\";]|$)",
|
|
160
|
+
"name": "constant.numeric.time.trebol"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:\\d+(?:\\.\\d+){2,11})(?=[\\s\\[\\](){}\";]|$)",
|
|
164
|
+
"name": "constant.numeric.tuple.trebol"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:[+-]?(?:\\d[\\d']*(?:[.,]\\d*)?|[.,]\\d+)(?:[eE][+-]?\\d+)?[xX][+-]?(?:\\d[\\d']*(?:[.,]\\d*)?|[.,]\\d+)(?:[eE][+-]?\\d+)?)(?=[\\s\\[\\](){}\";]|$)",
|
|
168
|
+
"name": "constant.numeric.pair.trebol"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:[+-]?(?:\\d[\\d']*(?:[.,]\\d*)?|[.,]\\d+)(?:[eE][+-]?\\d+)?%)(?=[\\s\\[\\](){}\";]|$)",
|
|
172
|
+
"name": "constant.numeric.percent.trebol"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:[+-]?\\d[\\d']*)(?=[\\s\\[\\](){}\";]|$)",
|
|
176
|
+
"name": "constant.numeric.integer.trebol"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:[+-]?(?:\\d[\\d']*(?:[.,]\\d*)?|[.,]\\d+)(?:[eE][+-]?\\d+)?)(?=[\\s\\[\\](){}\";]|$)",
|
|
180
|
+
"name": "constant.numeric.decimal.trebol"
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
"word": {
|
|
185
|
+
"patterns": [
|
|
186
|
+
{
|
|
187
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:(?![+-]?\\.?\\d)[^\\s@#$%^,:'/\\\\\"()\\[\\]{};]+(?:/[^\\s\\[\\](){}\";/]+)*:)(?=[\\s\\[\\](){}\";]|$)",
|
|
188
|
+
"name": "entity.name.variable.set-word.trebol"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?::(?![+-]?\\.?\\d)[^\\s@#$%^,:'/\\\\\"()\\[\\]{};]+(?:/[^\\s\\[\\](){}\";/]+)*)(?=[\\s\\[\\](){}\";]|$)",
|
|
192
|
+
"name": "variable.other.get-word.trebol"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:'(?![+-]?\\.?\\d)[^\\s@#$%^,:'/\\\\\"()\\[\\]{};]+(?:/[^\\s\\[\\](){}\";/]+)*)(?=[\\s\\[\\](){}\";]|$)",
|
|
196
|
+
"name": "constant.other.symbol.lit-word.trebol"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:(?:\\+|-|\\*|\\*\\*|\\/|\\/\\/|%|%%|=|==|<>|!=|<|>|<=|>=|=\\?|and|or|xor))(?=[\\s\\[\\](){}\";]|$)",
|
|
200
|
+
"name": "keyword.operator.trebol"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:/(?![+-]?\\.?\\d)[^\\s@#$%^,:'/\\\\\"()\\[\\]{};]+)(?=[\\s\\[\\](){}\";]|$)",
|
|
204
|
+
"name": "variable.parameter.refinement.trebol"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:(?![+-]?\\.?\\d)[^\\s@#$%^,:'/\\\\\"()\\[\\]{};]+!)(?=[\\s\\[\\](){}\";/]|$)",
|
|
208
|
+
"name": "support.type.datatype.trebol"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:(?i:true|false|none|yes|no|on|off))(?=[\\s\\[\\](){}\";/]|$)",
|
|
212
|
+
"name": "constant.language.trebol"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"match": "(?<![^\\s\\[\\](){}\"])(?:(?i:if|either|unless|case|switch|while|until|loop|repeat|foreach|forall|forskip|forever|break|continue|return|exit|throw|catch|try|attempt|do|func|function|does|has|closure))(?=[\\s\\[\\](){}\";/]|$)",
|
|
216
|
+
"name": "keyword.control.trebol"
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
"path": {
|
|
221
|
+
"match": "(?<=[^\\s\\[\\](){}\";]|\\))/",
|
|
222
|
+
"name": "punctuation.separator.path.trebol"
|
|
223
|
+
},
|
|
224
|
+
"bracket": {
|
|
225
|
+
"patterns": [
|
|
226
|
+
{
|
|
227
|
+
"match": "[\\[\\]]",
|
|
228
|
+
"name": "punctuation.section.block.trebol"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"match": "[()]",
|
|
232
|
+
"name": "punctuation.section.paren.trebol"
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trebol",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Trebol: a Rebol-derived language for building beautiful web UIs without HTML or CSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rebol",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"dist",
|
|
41
41
|
"src",
|
|
42
42
|
"LICENSE",
|
|
43
|
-
"README.md"
|
|
43
|
+
"README.md",
|
|
44
|
+
"editors/vscode"
|
|
44
45
|
],
|
|
45
46
|
"engines": {
|
|
46
47
|
"node": ">=22.18"
|
|
@@ -59,13 +60,16 @@
|
|
|
59
60
|
"r3check": "node --disable-warning=ExperimentalWarning tools/r3check.ts",
|
|
60
61
|
"supplier": "node --disable-warning=ExperimentalWarning tools/cli.ts supplier",
|
|
61
62
|
"docs:serve": "npm run docs && node --disable-warning=ExperimentalWarning tools/cli.ts dev docs/_build/html --port 8000",
|
|
62
|
-
"docs": "uv run --quiet --no-project --with-requirements docs/requirements.txt sphinx-build -q -E -b html docs docs/_build/html"
|
|
63
|
+
"docs": "uv run --quiet --no-project --with-requirements docs/requirements.txt sphinx-build -q -E -b html docs docs/_build/html",
|
|
64
|
+
"grammar": "node --disable-warning=ExperimentalWarning tools/grammar.ts"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
67
|
"@types/node": "^22.15.0",
|
|
66
68
|
"@types/ws": "^8.18.2",
|
|
67
69
|
"esbuild": "^0.28.2",
|
|
68
70
|
"typescript": "^5.9.0",
|
|
71
|
+
"vscode-oniguruma": "^2.0.1",
|
|
72
|
+
"vscode-textmate": "^9.3.2",
|
|
69
73
|
"ws": "^8.23.0"
|
|
70
74
|
}
|
|
71
75
|
}
|
package/src/core/boot.ts
CHANGED
|
@@ -38,7 +38,7 @@ export function makeRuntime(): Runtime {
|
|
|
38
38
|
['off', FALSE], ['yes', TRUE], ['no', FALSE]] as const) set(name, v);
|
|
39
39
|
KIND_NAMES.forEach((name, k) => set(name, datatype(k as Kind)));
|
|
40
40
|
for (const [name, bits] of Object.entries(TYPESETS)) set(name, typeset(bits));
|
|
41
|
-
for (const def of registeredNatives()) set(def.name, { t: K.Native, p: def });
|
|
41
|
+
for (const def of registeredNatives()) if (def.hidden !== true) set(def.name, { t: K.Native, p: def });
|
|
42
42
|
for (const [name, fn] of OPS) {
|
|
43
43
|
const i = ctxFind(lib, intern(fn));
|
|
44
44
|
if (i < 0) throw new Error(`operator ${name} refers to unknown native ${fn}`);
|
package/src/core/func.ts
CHANGED
|
@@ -73,6 +73,10 @@ export interface NativeDef {
|
|
|
73
73
|
readonly specBlock: BlockCell;
|
|
74
74
|
readonly id: number;
|
|
75
75
|
readonly name: string;
|
|
76
|
+
/** Explicit data for natives the host makes after boot, such as which JavaScript function a call runs. */
|
|
77
|
+
readonly data?: number;
|
|
78
|
+
/** Kept out of lib: only the host hands out natives built on it. */
|
|
79
|
+
readonly hidden?: boolean;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
/** The payload of an op! cell: the two-argument function it calls. */
|
|
@@ -311,7 +311,7 @@ native('until', '["Evaluates the block until it gives true." body [block!]]', (_
|
|
|
311
311
|
});
|
|
312
312
|
|
|
313
313
|
native('break', '["Leaves the loop it is in." /return value [any-value!]]', (_t, f) =>
|
|
314
|
-
({ k: 'throw', e: { kind: T.Break, v: f.args[0]!.t === K.Logic ? f.args[1]! :
|
|
314
|
+
({ k: 'throw', e: { kind: T.Break, v: f.args[0]!.t === K.Logic ? f.args[1]! : UNSET, name: null } }));
|
|
315
315
|
|
|
316
316
|
native('continue', '["Goes on with the next turn of the loop it is in." ]', () => ({ k: 'throw', e: { kind: T.Continue, v: UNSET, name: null } }));
|
|
317
317
|
|
|
@@ -14,8 +14,9 @@ import {
|
|
|
14
14
|
import { bindSeries, copyDeep } from '../ctx.ts';
|
|
15
15
|
import { isEqual, compare, foldCase } from '../compare.ts';
|
|
16
16
|
import { pick } from '../access.ts';
|
|
17
|
-
import { context, time, sameValue } from '../values.ts';
|
|
17
|
+
import { context, time, sameValue, string } from '../values.ts';
|
|
18
18
|
import { dateDiff } from './math.ts';
|
|
19
|
+
import { sourceOf } from '../mold.ts';
|
|
19
20
|
import {
|
|
20
21
|
splice, itemsFor, lengthOf, at, clampIndex,
|
|
21
22
|
type SeriesCell, type Item,
|
|
@@ -90,6 +91,11 @@ native('at', '["The series at a position, counted from where it is." series [ser
|
|
|
90
91
|
native('index?', '["The position of the series, from 1." series [series!]]', (_t, f) => value(integer((f.args[0] as SeriesCell).i + 1)));
|
|
91
92
|
native('head?', '["True if the series is at its head." series [series!]]', (_t, f) => value(logic((f.args[0] as SeriesCell).i === 0)));
|
|
92
93
|
native('tail?', '["True if the series is at its tail." series [series!]]', (_t, f) => value(logic(lengthOf(f.args[0] as SeriesCell) === 0)));
|
|
94
|
+
native('loaded-at', '["Where the value at the position of a block was loaded from, as file:line:col; none if it was made at run time." block [any-block!]]', (_t, f) => {
|
|
95
|
+
const b = f.args[0] as BlockCell;
|
|
96
|
+
const at = sourceOf(b.s, b.i);
|
|
97
|
+
return value(at === null ? NONE : string(at));
|
|
98
|
+
});
|
|
93
99
|
|
|
94
100
|
// --- editing ---------------------------------------------------------------------
|
|
95
101
|
|
|
@@ -153,6 +159,8 @@ native('copy', '["A copy of the series, map, object or bitset." value [series! m
|
|
|
153
159
|
const b = s as BlockCell;
|
|
154
160
|
const part: Series<Cell> = { data: b.s.data.slice(from, end) };
|
|
155
161
|
if (b.s.nl) part.nl = b.s.nl.slice(from, end);
|
|
162
|
+
if (b.s.pos) part.pos = b.s.pos.slice(from, end);
|
|
163
|
+
if (b.s.file !== undefined) part.file = b.s.file;
|
|
156
164
|
return value({ t: b.t, s: deep ? copyDeep(part) : part, i: 0 });
|
|
157
165
|
}
|
|
158
166
|
return value({ t: s.t, s: { data: (s.s.data as number[]).slice(from, end) }, i: 0 } as StringCell);
|
package/src/core/natives/text.ts
CHANGED
|
@@ -145,6 +145,8 @@ function toKind(k: Kind, v: Cell): Cell | string {
|
|
|
145
145
|
if (v.t === K.Binary) return { t: k, s: { data: codePoints(new TextDecoder().decode(new Uint8Array(v.s.data.slice(v.i)))) }, i: 0 };
|
|
146
146
|
if (isAnyWord(v.t)) return { t: k, s: { data: codePoints(spell((v as WordCell).sym)) }, i: 0 };
|
|
147
147
|
if (v.t === K.Char) return { t: k, s: { data: [v.v] }, i: 0 };
|
|
148
|
+
// the text itself, so to string! <a> is "a", as in R3; form gives "<a>"
|
|
149
|
+
if (isAnyString(v.t)) return { t: k, s: { data: (v as StringCell).s.data.slice((v as StringCell).i) }, i: 0 };
|
|
148
150
|
return { t: k, s: { data: codePoints(textOf(v)) }, i: 0 };
|
|
149
151
|
}
|
|
150
152
|
case K.Binary:
|