limn-hl 0.1.0 → 0.2.0

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.
Files changed (73) hide show
  1. package/README.md +109 -148
  2. package/dist/detect.d.ts +7 -1
  3. package/dist/detect.js +592 -502
  4. package/dist/engine.js +45 -1
  5. package/dist/generated/detect.d.ts +11 -0
  6. package/dist/generated/detect.js +2434 -0
  7. package/dist/generated/grammars.d.ts +119 -0
  8. package/dist/generated/grammars.js +613 -0
  9. package/dist/generated/lang.d.ts +6 -0
  10. package/dist/{lang/index.js → generated/lang.js} +82 -56
  11. package/dist/{theme/generated.d.ts → generated/themes.d.ts} +3 -1
  12. package/dist/{theme/generated.js → generated/themes.js} +29 -0
  13. package/dist/lang.d.ts +1 -0
  14. package/dist/lang.js +1 -0
  15. package/dist/render/ansi.d.ts +1 -1
  16. package/dist/render/html.d.ts +1 -1
  17. package/dist/{theme/index.d.ts → theme.d.ts} +1 -1
  18. package/dist/theme.js +1 -0
  19. package/dist/vm/compile.d.ts +4 -0
  20. package/dist/vm/compile.js +390 -0
  21. package/dist/vm/exec.d.ts +3 -0
  22. package/dist/vm/exec.js +218 -0
  23. package/dist/vm/format.d.ts +255 -0
  24. package/dist/vm/format.js +248 -0
  25. package/dist/vm/index.d.ts +2 -0
  26. package/dist/vm/index.js +2 -0
  27. package/dist/vm/pat.d.ts +4 -0
  28. package/dist/vm/pat.js +701 -0
  29. package/dist/vm/quoted.d.ts +8 -0
  30. package/dist/vm/quoted.js +190 -0
  31. package/dist/vm/scan.d.ts +3 -0
  32. package/dist/vm/scan.js +499 -0
  33. package/dist/wordtable.d.ts +8 -4
  34. package/dist/wordtable.js +107 -30
  35. package/package.json +6 -6
  36. package/dist/lang/clike.d.ts +0 -15
  37. package/dist/lang/clike.js +0 -35
  38. package/dist/lang/clike_helpers.d.ts +0 -8
  39. package/dist/lang/clike_helpers.js +0 -220
  40. package/dist/lang/code.d.ts +0 -45
  41. package/dist/lang/code.js +0 -779
  42. package/dist/lang/config.d.ts +0 -5
  43. package/dist/lang/config.js +0 -164
  44. package/dist/lang/css.d.ts +0 -5
  45. package/dist/lang/css.js +0 -125
  46. package/dist/lang/docs.d.ts +0 -12
  47. package/dist/lang/docs.js +0 -462
  48. package/dist/lang/formats.d.ts +0 -10
  49. package/dist/lang/formats.js +0 -295
  50. package/dist/lang/html.d.ts +0 -11
  51. package/dist/lang/html.js +0 -298
  52. package/dist/lang/index.d.ts +0 -20
  53. package/dist/lang/js.d.ts +0 -9
  54. package/dist/lang/js.js +0 -532
  55. package/dist/lang/js_helpers.d.ts +0 -7
  56. package/dist/lang/js_helpers.js +0 -308
  57. package/dist/lang/json.d.ts +0 -3
  58. package/dist/lang/json.js +0 -136
  59. package/dist/lang/markdown.d.ts +0 -3
  60. package/dist/lang/markdown.js +0 -249
  61. package/dist/lang/python.d.ts +0 -3
  62. package/dist/lang/python.js +0 -335
  63. package/dist/lang/scripting.d.ts +0 -7
  64. package/dist/lang/scripting.js +0 -216
  65. package/dist/lang/shell.d.ts +0 -7
  66. package/dist/lang/shell.js +0 -278
  67. package/dist/lang/specs_gen.d.ts +0 -66
  68. package/dist/lang/specs_gen.js +0 -381
  69. package/dist/lang/terminal.d.ts +0 -9
  70. package/dist/lang/terminal.js +0 -550
  71. package/dist/lang/yaml.d.ts +0 -4
  72. package/dist/lang/yaml.js +0 -176
  73. package/dist/theme/index.js +0 -1
@@ -1,278 +0,0 @@
1
- import {
2
- Cursor,
3
- emitCommentWithTodo,
4
- isDigit,
5
- isIdentCont,
6
- isIdentStart
7
- } from "../cursor.js";
8
- import { Grammar } from "../engine.js";
9
- import { TokenKind, WordTable } from "../index.js";
10
- import { onceGrammar } from "./code.js";
11
- function scanBashDollar(src, pos, e) {
12
- const n = src.length;
13
- if (pos + 1 >= n)
14
- return pos + 1;
15
- const next = src.charCodeAt(pos + 1);
16
- if (next === 123) {
17
- const cur = new Cursor(src, pos + 2);
18
- cur.scanBalanced(123, 125, false);
19
- e.emit(pos, cur.pos, TokenKind.Variable);
20
- return cur.pos;
21
- }
22
- if (next === 40) {
23
- e.emit(pos, pos + 2, TokenKind.Punctuation);
24
- const cur = new Cursor(src, pos + 2);
25
- const closed = cur.scanBalanced(40, 41, true);
26
- const exprEnd = closed ? cur.pos - 1 : cur.pos;
27
- e.embed(src, pos + 2, exprEnd, bash(), TokenKind.Plain);
28
- if (closed)
29
- e.emit(exprEnd, cur.pos, TokenKind.Punctuation);
30
- return cur.pos;
31
- }
32
- let end = pos + 1;
33
- const b = src.charCodeAt(end);
34
- if (b === 63 || b === 35 || b === 64 || b === 42 || b === 36 || b === 33 || isDigit(b)) {
35
- end++;
36
- } else {
37
- while (end < n && isIdentCont(src.charCodeAt(end)))
38
- end++;
39
- }
40
- if (end > pos + 1) {
41
- e.emit(pos, end, TokenKind.Variable);
42
- return end;
43
- }
44
- return pos + 1;
45
- }
46
- function scanBashDoubleString(src, start, e) {
47
- const n = src.length;
48
- let i = start + 1;
49
- let seg = start;
50
- while (i < n) {
51
- const ch = src.charCodeAt(i);
52
- if (ch === 34) {
53
- i++;
54
- e.emit(seg, i, TokenKind.String);
55
- return i;
56
- }
57
- if (ch === 92 && i + 1 < n) {
58
- if (i > seg)
59
- e.emit(seg, i, TokenKind.String);
60
- e.emit(i, i + 2, TokenKind.Escape);
61
- i += 2;
62
- seg = i;
63
- continue;
64
- }
65
- if (ch === 36 && i + 1 < n) {
66
- if (i > seg)
67
- e.emit(seg, i, TokenKind.String);
68
- i = scanBashDollar(src, i, e);
69
- seg = i;
70
- continue;
71
- }
72
- i++;
73
- }
74
- e.emit(seg, n, TokenKind.String);
75
- return n;
76
- }
77
- function scanBash(src, words, e) {
78
- const n = src.length;
79
- let i = 0;
80
- while (i < n && !e.stopped()) {
81
- const ch = src.charCodeAt(i);
82
- if (ch === 32 || ch === 9 || ch === 10 || ch === 13) {
83
- i++;
84
- } else if (ch === 35 && (i === 0 || src.charCodeAt(i - 1) === 32 || src.charCodeAt(i - 1) === 9 || src.charCodeAt(i - 1) === 10 || src.charCodeAt(i - 1) === 59)) {
85
- const nl = src.indexOf(`
86
- `, i + 1);
87
- const end = nl >= 0 ? nl : n;
88
- emitCommentWithTodo(src, i, end, e);
89
- i = end;
90
- } else if (ch === 39) {
91
- const cur = new Cursor(src, i);
92
- cur.scanQuoted(39, true, true);
93
- e.emit(i, cur.pos, TokenKind.String);
94
- i = cur.pos;
95
- } else if (ch === 34) {
96
- i = scanBashDoubleString(src, i, e);
97
- } else if (ch === 36 && i + 1 < n && src.charCodeAt(i + 1) === 39) {
98
- const cur = new Cursor(src, i + 1);
99
- cur.scanQuoted(39, true, false);
100
- e.emit(i, cur.pos, TokenKind.String);
101
- i = cur.pos;
102
- } else if (ch === 36) {
103
- i = scanBashDollar(src, i, e);
104
- } else if (ch === 45 && i + 1 < n && (isIdentStart(src.charCodeAt(i + 1)) || src.charCodeAt(i + 1) === 45)) {
105
- if (i === 0 || src.charCodeAt(i - 1) === 32 || src.charCodeAt(i - 1) === 9) {
106
- const s = i;
107
- i++;
108
- while (i < n && (isIdentCont(src.charCodeAt(i)) || src.charCodeAt(i) === 45))
109
- i++;
110
- e.emit(s, i, TokenKind.Property);
111
- continue;
112
- }
113
- e.emit(i, i + 1, TokenKind.Operator);
114
- i++;
115
- } else if (ch === 124 || ch === 38 || ch === 62 || ch === 60 || ch === 61 || ch === 33) {
116
- const s = i;
117
- i++;
118
- while (i < n) {
119
- const b = src.charCodeAt(i);
120
- if (b === 124 || b === 38 || b === 62 || b === 60 || b === 61)
121
- i++;
122
- else
123
- break;
124
- }
125
- e.emit(s, i, TokenKind.Operator);
126
- } else if (ch === 40 || ch === 41 || ch === 123 || ch === 125 || ch === 91 || ch === 93 || ch === 59) {
127
- e.emit(i, i + 1, TokenKind.Punctuation);
128
- i++;
129
- } else if (isDigit(ch) && (i === 0 || src.charCodeAt(i - 1) === 32 || src.charCodeAt(i - 1) === 9 || src.charCodeAt(i - 1) === 61)) {
130
- const s = i;
131
- while (i < n && isDigit(src.charCodeAt(i)))
132
- i++;
133
- if (i === n || !isIdentCont(src.charCodeAt(i))) {
134
- e.emit(s, i, TokenKind.Number);
135
- }
136
- } else if (isIdentStart(ch)) {
137
- const s = i;
138
- i++;
139
- while (i < n && (isIdentCont(src.charCodeAt(i)) || src.charCodeAt(i) === 45))
140
- i++;
141
- if (i < n && src.charCodeAt(i) === 61) {
142
- e.emit(s, i, TokenKind.Variable);
143
- } else {
144
- const kind = words.lookupSpan(src, s, i);
145
- if (kind !== TokenKind.Plain)
146
- e.emit(s, i, kind);
147
- }
148
- } else {
149
- i++;
150
- }
151
- }
152
- }
153
- function scanDocker(src, instrs, e) {
154
- const n = src.length;
155
- let pos = 0;
156
- while (pos < n && !e.stopped()) {
157
- const nl = src.indexOf(`
158
- `, pos);
159
- let end = nl >= 0 ? nl : n;
160
- while (end < n && end > pos && src.charCodeAt(end - 1) === 92) {
161
- const nextNL = src.indexOf(`
162
- `, end + 1);
163
- if (nextNL < 0) {
164
- end = n;
165
- break;
166
- }
167
- end = nextNL;
168
- }
169
- let i = pos;
170
- while (i < end && (src.charCodeAt(i) === 32 || src.charCodeAt(i) === 9))
171
- i++;
172
- if (i < end) {
173
- if (src.charCodeAt(i) === 35) {
174
- emitCommentWithTodo(src, i, end, e);
175
- } else {
176
- const ws = i;
177
- while (i < end && isIdentCont(src.charCodeAt(i)))
178
- i++;
179
- if (instrs.lookupSpan(src, ws, i) === TokenKind.Keyword) {
180
- e.emit(ws, i, TokenKind.Keyword);
181
- while (i < end && (src.charCodeAt(i) === 32 || src.charCodeAt(i) === 9))
182
- i++;
183
- if (i < end) {
184
- e.embed(src, i, end, bash(), TokenKind.Plain);
185
- }
186
- }
187
- }
188
- }
189
- if (end >= n)
190
- break;
191
- pos = end + 1;
192
- }
193
- }
194
- function scanMake(src, dirs, e) {
195
- const n = src.length;
196
- let pos = 0;
197
- while (pos < n && !e.stopped()) {
198
- const nl = src.indexOf(`
199
- `, pos);
200
- const end = nl >= 0 ? nl : n;
201
- if (pos < end) {
202
- if (src.charCodeAt(pos) === 9) {
203
- e.embed(src, pos + 1, end, bash(), TokenKind.Plain);
204
- } else {
205
- let i = pos;
206
- while (i < end && src.charCodeAt(i) === 32)
207
- i++;
208
- if (i < end && src.charCodeAt(i) === 35) {
209
- emitCommentWithTodo(src, i, end, e);
210
- } else if (i < end) {
211
- let ws = i;
212
- while (ws < end) {
213
- const b = src.charCodeAt(ws);
214
- if (isIdentCont(b) || b === 46 || b === 45)
215
- ws++;
216
- else
217
- break;
218
- }
219
- const w = src.slice(i, ws);
220
- if (dirs.lookup(w) === TokenKind.Keyword || w === ".PHONY") {
221
- e.emit(i, ws, TokenKind.Keyword);
222
- } else {
223
- const colon = src.indexOf(":", i);
224
- if (colon > i && colon < end && (colon + 1 >= end || src.charCodeAt(colon + 1) !== 61)) {
225
- e.emit(i, colon, TokenKind.Section);
226
- e.emit(colon, colon + 1, TokenKind.Punctuation);
227
- ws = colon + 1;
228
- } else {
229
- ws = i;
230
- }
231
- }
232
- for (let k = ws;k < end; k++) {
233
- const ch = src.charCodeAt(k);
234
- if (ch === 35) {
235
- emitCommentWithTodo(src, k, end, e);
236
- break;
237
- }
238
- if (ch === 36 && k + 1 < end && (src.charCodeAt(k + 1) === 40 || src.charCodeAt(k + 1) === 123)) {
239
- const open = src.charCodeAt(k + 1);
240
- const close = open === 123 ? 125 : 41;
241
- const cur = new Cursor(src.slice(0, end), k + 2);
242
- cur.scanBalanced(open, close, false);
243
- e.emit(k, cur.pos, TokenKind.Variable);
244
- k = cur.pos - 1;
245
- }
246
- }
247
- }
248
- }
249
- }
250
- if (nl < 0)
251
- break;
252
- pos = end + 1;
253
- }
254
- }
255
- export const bash = /* @__PURE__ */ onceGrammar(() => {
256
- const words = new WordTable(false, {
257
- kind: TokenKind.Keyword,
258
- words: "case coproc do done elif else esac exit export fi for function if in local readonly return select set then time until while"
259
- }, {
260
- kind: TokenKind.Func,
261
- words: "alias awk basename cat cd chmod chown cp curl cut dirname echo env eval exec find grep head jq kill ls mkdir mv printf ps pwd rm sed sleep sort source tail tar tee test touch tr xargs"
262
- }, { kind: TokenKind.Constant, words: "true false" });
263
- return new Grammar("bash", (src, e) => scanBash(src, words, e), "sh", "shell", "zsh", "fish", "console");
264
- });
265
- export const docker = /* @__PURE__ */ onceGrammar(() => {
266
- const instrs = new WordTable(true, {
267
- kind: TokenKind.Keyword,
268
- words: "add arg cmd copy entrypoint env expose from healthcheck label maintainer onbuild run shell stopsignal user volume workdir as"
269
- });
270
- return new Grammar("docker", (src, e) => scanDocker(src, instrs, e), "dockerfile");
271
- });
272
- export const make = /* @__PURE__ */ onceGrammar(() => {
273
- const dirs = new WordTable(false, {
274
- kind: TokenKind.Keyword,
275
- words: "define endef else endif export ifdef ifeq ifndef ifneq include override sinclude unexport vpath"
276
- });
277
- return new Grammar("make", (src, e) => scanMake(src, dirs, e), "makefile", "mk");
278
- });
@@ -1,66 +0,0 @@
1
- import type { Grammar } from "../engine.js";
2
- import { type CodeConfig } from "./code.js";
3
- export declare const specGo: CodeConfig;
4
- export declare const specC: CodeConfig;
5
- export declare const specCpp: CodeConfig;
6
- export declare const specCs: CodeConfig;
7
- export declare const specJava: CodeConfig;
8
- export declare const specKt: CodeConfig;
9
- export declare const specSwift: CodeConfig;
10
- export declare const specRs: CodeConfig;
11
- export declare const specZig: CodeConfig;
12
- export declare const specDart: CodeConfig;
13
- export declare const specPhp: CodeConfig;
14
- export declare const specSql: CodeConfig;
15
- export declare const specRb: CodeConfig;
16
- export declare const specLua: CodeConfig;
17
- export declare const specNix: CodeConfig;
18
- export declare const specGraphql: CodeConfig;
19
- export declare const specScala: CodeConfig;
20
- export declare const specGroovy: CodeConfig;
21
- export declare const specGlsl: CodeConfig;
22
- export declare const specWgsl: CodeConfig;
23
- export declare const specSolidity: CodeConfig;
24
- export declare const specGleam: CodeConfig;
25
- export declare const specProto: CodeConfig;
26
- export declare const specHcl: CodeConfig;
27
- export declare const specPrisma: CodeConfig;
28
- export declare const specCmake: CodeConfig;
29
- export declare const specNginx: CodeConfig;
30
- export declare const specR: CodeConfig;
31
- /** Returns the go grammar. */
32
- export declare const go: () => Grammar;
33
- /** Returns the java grammar. */
34
- export declare const java: () => Grammar;
35
- /** Returns the kt grammar. */
36
- export declare const kt: () => Grammar;
37
- /** Returns the swift grammar. */
38
- export declare const swift: () => Grammar;
39
- /** Returns the dart grammar. */
40
- export declare const dart: () => Grammar;
41
- /** Returns the sql grammar. */
42
- export declare const sql: () => Grammar;
43
- /** Returns the graphql grammar. */
44
- export declare const graphql: () => Grammar;
45
- /** Returns the scala grammar. */
46
- export declare const scala: () => Grammar;
47
- /** Returns the groovy grammar. */
48
- export declare const groovy: () => Grammar;
49
- /** Returns the wgsl grammar. */
50
- export declare const wgsl: () => Grammar;
51
- /** Returns the solidity grammar. */
52
- export declare const solidity: () => Grammar;
53
- /** Returns the gleam grammar. */
54
- export declare const gleam: () => Grammar;
55
- /** Returns the proto grammar. */
56
- export declare const proto: () => Grammar;
57
- /** Returns the hcl grammar. */
58
- export declare const hcl: () => Grammar;
59
- /** Returns the prisma grammar. */
60
- export declare const prisma: () => Grammar;
61
- /** Returns the cmake grammar. */
62
- export declare const cmake: () => Grammar;
63
- /** Returns the nginx grammar. */
64
- export declare const nginx: () => Grammar;
65
- /** Returns the r grammar. */
66
- export declare const r: () => Grammar;