trebol 0.1.0 → 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 +18 -3
- package/dist/cli.js +13790 -11417
- 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/access.d.ts +10 -0
- package/dist/lib/core/access.js +210 -0
- package/dist/lib/core/base.d.ts +4 -0
- package/dist/lib/core/base.js +50 -0
- package/dist/lib/core/bitset.d.ts +9 -0
- package/dist/lib/core/bitset.js +75 -0
- package/dist/lib/core/boot.d.ts +18 -0
- package/dist/lib/core/boot.js +73 -0
- package/dist/lib/core/compare.d.ts +9 -0
- package/dist/lib/core/compare.js +156 -0
- package/dist/lib/core/ctx.d.ts +36 -0
- package/dist/lib/core/ctx.js +251 -0
- package/dist/lib/core/dec.d.ts +28 -0
- package/dist/lib/core/dec.js +158 -0
- package/dist/lib/core/errors.d.ts +15 -0
- package/dist/lib/core/errors.js +44 -0
- package/dist/lib/core/escapes.d.ts +14 -0
- package/dist/lib/core/escapes.js +80 -0
- package/dist/lib/core/eval.d.ts +220 -0
- package/dist/lib/core/eval.js +666 -0
- package/dist/lib/core/func.d.ts +68 -0
- package/dist/lib/core/func.js +129 -0
- package/dist/lib/core/hash.d.ts +5 -0
- package/dist/lib/core/hash.js +155 -0
- package/dist/lib/core/index.d.ts +18 -0
- package/dist/lib/core/index.js +20 -0
- package/dist/lib/core/int64.d.ts +22 -0
- package/dist/lib/core/int64.js +113 -0
- package/dist/lib/core/kinds.d.ts +67 -0
- package/dist/lib/core/kinds.js +134 -0
- package/dist/lib/core/lexer.d.ts +13 -0
- package/dist/lib/core/lexer.js +702 -0
- package/dist/lib/core/mezz.d.ts +1 -0
- package/dist/lib/core/mezz.js +360 -0
- package/dist/lib/core/mold.d.ts +20 -0
- package/dist/lib/core/mold.js +434 -0
- package/dist/lib/core/natives/control.d.ts +1 -0
- package/dist/lib/core/natives/control.js +374 -0
- package/dist/lib/core/natives/csv.d.ts +15 -0
- package/dist/lib/core/natives/csv.js +315 -0
- package/dist/lib/core/natives/data.d.ts +11 -0
- package/dist/lib/core/natives/data.js +367 -0
- package/dist/lib/core/natives/define.d.ts +17 -0
- package/dist/lib/core/natives/define.js +47 -0
- package/dist/lib/core/natives/encode.d.ts +3 -0
- package/dist/lib/core/natives/encode.js +187 -0
- package/dist/lib/core/natives/json.d.ts +5 -0
- package/dist/lib/core/natives/json.js +273 -0
- package/dist/lib/core/natives/math.d.ts +3 -0
- package/dist/lib/core/natives/math.js +500 -0
- package/dist/lib/core/natives/parse.d.ts +1 -0
- package/dist/lib/core/natives/parse.js +600 -0
- package/dist/lib/core/natives/series.d.ts +4 -0
- package/dist/lib/core/natives/series.js +519 -0
- package/dist/lib/core/natives/text.d.ts +1 -0
- package/dist/lib/core/natives/text.js +487 -0
- package/dist/lib/core/natives/xml.d.ts +9 -0
- package/dist/lib/core/natives/xml.js +242 -0
- package/dist/lib/core/series.d.ts +26 -0
- package/dist/lib/core/series.js +73 -0
- package/dist/lib/core/symbols.d.ts +9 -0
- package/dist/lib/core/symbols.js +44 -0
- package/dist/lib/core/values.d.ts +206 -0
- package/dist/lib/core/values.js +223 -0
- package/dist/lib/host/browser.d.ts +4 -0
- package/dist/lib/host/browser.js +4974 -0
- package/dist/lib/host/chart.d.ts +26 -0
- package/dist/lib/host/chart.js +158 -0
- package/dist/lib/host/compress.d.ts +1 -0
- package/dist/lib/host/compress.js +37 -0
- 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/draw.d.ts +31 -0
- package/dist/lib/host/draw.js +348 -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/icons.d.ts +3 -0
- package/dist/lib/host/icons.js +97 -0
- package/dist/lib/host/index.d.ts +40 -0
- package/dist/lib/host/index.js +192 -0
- package/dist/lib/host/js.d.ts +5 -0
- package/dist/lib/host/js.js +130 -0
- package/dist/lib/host/locale.d.ts +40 -0
- package/dist/lib/host/locale.js +241 -0
- package/dist/lib/host/markdown.d.ts +30 -0
- package/dist/lib/host/markdown.js +161 -0
- package/dist/lib/host/modules.d.ts +14 -0
- package/dist/lib/host/modules.js +300 -0
- package/dist/lib/host/natives.d.ts +6 -0
- package/dist/lib/host/natives.js +98 -0
- package/dist/lib/host/net.d.ts +12 -0
- package/dist/lib/host/net.js +549 -0
- package/dist/lib/host/orbit.d.ts +121 -0
- package/dist/lib/host/orbit.js +374 -0
- package/dist/lib/host/page.d.ts +9 -0
- package/dist/lib/host/page.js +55 -0
- package/dist/lib/host/rows.d.ts +29 -0
- package/dist/lib/host/rows.js +109 -0
- package/dist/lib/host/scheduler.d.ts +51 -0
- package/dist/lib/host/scheduler.js +197 -0
- package/dist/lib/host/theme.d.ts +58 -0
- package/dist/lib/host/theme.js +1667 -0
- package/dist/lib/ui/i18n.trb +117 -0
- package/dist/lib/ui/test.trb +565 -0
- package/dist/lib/ui/ui.trb +1678 -0
- package/dist/trebol.js +1427 -138
- 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 +23 -7
- 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 +1235 -83
- 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 +5 -3
- package/src/host/js.ts +127 -0
- package/src/host/markdown.ts +9 -0
- package/src/host/modules.ts +41 -2
- 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 +270 -6
- package/src/ui/i18n.trb +10 -0
- package/src/ui/test.trb +565 -0
- package/src/ui/ui.trb +564 -90
|
@@ -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",
|
|
@@ -16,19 +16,32 @@
|
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
19
|
-
"./core":
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
"./core": {
|
|
20
|
+
"types": "./dist/lib/core/index.d.ts",
|
|
21
|
+
"source": "./src/core/index.ts",
|
|
22
|
+
"default": "./dist/lib/core/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./host": {
|
|
25
|
+
"types": "./dist/lib/host/index.d.ts",
|
|
26
|
+
"source": "./src/host/index.ts",
|
|
27
|
+
"default": "./dist/lib/host/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./browser": {
|
|
30
|
+
"types": "./dist/lib/host/browser.d.ts",
|
|
31
|
+
"source": "./src/host/browser.ts",
|
|
32
|
+
"default": "./dist/lib/host/browser.js"
|
|
33
|
+
}
|
|
22
34
|
},
|
|
23
35
|
"bin": {
|
|
24
|
-
"trebol": "
|
|
36
|
+
"trebol": "dist/cli.js"
|
|
25
37
|
},
|
|
26
38
|
"license": "Apache-2.0",
|
|
27
39
|
"files": [
|
|
28
40
|
"dist",
|
|
29
41
|
"src",
|
|
30
42
|
"LICENSE",
|
|
31
|
-
"README.md"
|
|
43
|
+
"README.md",
|
|
44
|
+
"editors/vscode"
|
|
32
45
|
],
|
|
33
46
|
"engines": {
|
|
34
47
|
"node": ">=22.18"
|
|
@@ -47,13 +60,16 @@
|
|
|
47
60
|
"r3check": "node --disable-warning=ExperimentalWarning tools/r3check.ts",
|
|
48
61
|
"supplier": "node --disable-warning=ExperimentalWarning tools/cli.ts supplier",
|
|
49
62
|
"docs:serve": "npm run docs && node --disable-warning=ExperimentalWarning tools/cli.ts dev docs/_build/html --port 8000",
|
|
50
|
-
"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"
|
|
51
65
|
},
|
|
52
66
|
"devDependencies": {
|
|
53
67
|
"@types/node": "^22.15.0",
|
|
54
68
|
"@types/ws": "^8.18.2",
|
|
55
69
|
"esbuild": "^0.28.2",
|
|
56
70
|
"typescript": "^5.9.0",
|
|
71
|
+
"vscode-oniguruma": "^2.0.1",
|
|
72
|
+
"vscode-textmate": "^9.3.2",
|
|
57
73
|
"ws": "^8.23.0"
|
|
58
74
|
}
|
|
59
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:
|