-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate-queries.mjs
More file actions
executable file
·50 lines (42 loc) · 1.89 KB
/
generate-queries.mjs
File metadata and controls
executable file
·50 lines (42 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
import fs from "node:fs";
import snapi from "./snapi.js";
import g4api from "./g4api.js";
import unicodelib from "./unicodelib.js";
import StringBuilder from "string-builder";
const builder = new StringBuilder();
builder.clear();
builder.appendLine(";; Auto-generated SNAPI.axi built-ins");
builder.appendLine();
builder.appendLine(";; Functions");
builder.appendLine(`(call_expression
function: (identifier) @function.builtin
(#match? @function.builtin "(?i)^(${Object.keys(snapi.functions).join("|")})$"))`);
builder.appendLine();
builder.appendLine(";; Constants");
builder.appendLine(`(identifier) @constant.builtin
(#match? @constant.builtin "(?i)^(${Object.keys(snapi.constants).join("|")})$")`);
fs.writeFileSync("./queries/highlights-snapi.scm", builder.toString());
builder.clear();
builder.appendLine(";; Auto-generated G4API.axi built-ins");
builder.appendLine();
builder.appendLine(";; Constants");
builder.appendLine(`(identifier) @constant.builtin
(#match? @constant.builtin "(?i)^(${Object.keys(g4api.constants).join("|")})$")`);
fs.writeFileSync("./queries/highlights-g4api.scm", builder.toString());
builder.clear();
builder.appendLine(";; Auto-generated UnicodeLib.axi built-ins");
builder.appendLine();
builder.appendLine(";; Functions");
builder.appendLine(`(call_expression
function: (identifier) @function.builtin
(#match? @function.builtin "(?i)^(${Object.keys(unicodelib.functions).join("|")})$"))`);
builder.appendLine();
builder.appendLine(";; Constants");
builder.appendLine(`(identifier) @constant.builtin
(#match? @constant.builtin "(?i)^(${Object.keys(unicodelib.constants).join("|")})$")`);
builder.appendLine();
builder.appendLine(";; Variables");
builder.appendLine(`(identifier) @variable.builtin
(#match? @variable.builtin "(?i)^(${Object.keys(unicodelib.variables).join("|")})$")`);
fs.writeFileSync("./queries/highlights-unicodelib.scm", builder.toString());