@konomanoasa/tree-sitter-diagnostic-dash 0.1.0 → 0.3.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.
- package/Cargo.toml +2 -2
- package/PARSING_POLICY.md +1 -2
- package/README.md +3 -3
- package/binding.gyp +1 -5
- package/package.json +2 -2
- package/pyproject.toml +18 -3
- package/scripts/tree-sitter.js +47 -18
- package/src/parser.c +1 -1
- package/src/scanner.c +10 -5
- package/src/tokens.h +1 -1
- package/tree-sitter.json +5 -2
package/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "konomanoasa-tree-sitter-diagnostic-dash"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
description = "Tree-sitter grammar for diagnostics of dash."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -34,4 +34,4 @@ tree-sitter-language = "=0.1.9"
|
|
|
34
34
|
tree-sitter = "=0.27.2"
|
|
35
35
|
|
|
36
36
|
[build-dependencies]
|
|
37
|
-
cc = "=1.
|
|
37
|
+
cc = "=1.13.0"
|
package/PARSING_POLICY.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Parsing Policy
|
|
2
2
|
|
|
3
|
-
`diagnostic_dash` parses source using [dash
|
|
4
|
-
default settings.
|
|
3
|
+
`diagnostic_dash` parses source using the default settings of [dash](https://manpages.debian.org/experimental/dash/dash.1.en.html) 0.5.13.6.
|
|
5
4
|
|
|
6
5
|
These commands are parsed without changing how subsequent source is parsed.
|
|
7
6
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://pypi.org/project/konomanoasa-tree-sitter-diagnostic-dash/)
|
|
7
7
|
|
|
8
8
|
[Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for
|
|
9
|
-
diagnostics of the Debian Almquist Shell 0.5.13.
|
|
9
|
+
diagnostics of the Debian Almquist Shell 0.5.13.6.
|
|
10
10
|
|
|
11
11
|
Guarantees cover fresh parsing only.
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ npm install @konomanoasa/tree-sitter-diagnostic-dash
|
|
|
18
18
|
|
|
19
19
|
## Parsing Policy
|
|
20
20
|
|
|
21
|
-
[Parsing Policy](
|
|
21
|
+
[Parsing Policy](PARSING_POLICY.md)
|
|
22
22
|
|
|
23
23
|
## Development
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ npm test
|
|
|
29
29
|
|
|
30
30
|
## Specification
|
|
31
31
|
|
|
32
|
-
[dash(1) Manual
|
|
32
|
+
[dash(1) Manual](https://manpages.debian.org/experimental/dash/dash.1.en.html)
|
|
33
33
|
|
|
34
34
|
## License
|
|
35
35
|
|
package/binding.gyp
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
"targets": [
|
|
3
3
|
{
|
|
4
4
|
"target_name": "tree_sitter_diagnostic_dash_binding",
|
|
5
|
-
"sources": [
|
|
6
|
-
"bindings/node/binding.cc",
|
|
7
|
-
"src/parser.c",
|
|
8
|
-
"src/scanner.c"
|
|
9
|
-
],
|
|
5
|
+
"sources": ["bindings/node/binding.cc", "src/parser.c", "src/scanner.c"],
|
|
10
6
|
"include_dirs": ["src"],
|
|
11
7
|
"dependencies": [
|
|
12
8
|
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomanoasa/tree-sitter-diagnostic-dash",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Tree-sitter grammar for diagnostics of dash.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "git+https://github.com/konomanoasa/tree-sitter-diagnostic-dash.git",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"tree-sitter": "0.25.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@biomejs/biome": "2.6.
|
|
60
|
+
"@biomejs/biome": "2.6.10",
|
|
61
61
|
"@types/node": "26.6.11",
|
|
62
62
|
"node-gyp": "13.1.0",
|
|
63
63
|
"tree-sitter-cli": "0.27.2",
|
package/pyproject.toml
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "konomanoasa-tree-sitter-diagnostic-dash"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
description = "Tree-sitter grammar for diagnostics of dash."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.13"
|
|
8
9
|
|
|
9
10
|
[project.urls]
|
|
10
11
|
Repository = "https://github.com/konomanoasa/tree-sitter-diagnostic-dash"
|
|
@@ -16,7 +17,7 @@ dev = [
|
|
|
16
17
|
"setuptools==84.2.1",
|
|
17
18
|
"tree-sitter==0.27.0",
|
|
18
19
|
"twine==7.0.0",
|
|
19
|
-
"ty==
|
|
20
|
+
"ty==1.2.0",
|
|
20
21
|
]
|
|
21
22
|
|
|
22
23
|
[build-system]
|
|
@@ -25,7 +26,9 @@ build-backend = "setuptools.build_meta"
|
|
|
25
26
|
|
|
26
27
|
[tool.setuptools]
|
|
27
28
|
include-package-data = false
|
|
28
|
-
packages = [
|
|
29
|
+
packages = [
|
|
30
|
+
"tree_sitter_diagnostic_dash",
|
|
31
|
+
]
|
|
29
32
|
|
|
30
33
|
[tool.setuptools.package-dir]
|
|
31
34
|
tree_sitter_diagnostic_dash = "bindings/python"
|
|
@@ -56,3 +59,15 @@ skip-magic-trailing-comma = true
|
|
|
56
59
|
|
|
57
60
|
[tool.ruff.lint.isort]
|
|
58
61
|
split-on-trailing-comma = false
|
|
62
|
+
|
|
63
|
+
[tool.uv]
|
|
64
|
+
cache-keys = [
|
|
65
|
+
{ file = "LICENSE" },
|
|
66
|
+
{ file = "README.md" },
|
|
67
|
+
{ file = "bindings/python/*" },
|
|
68
|
+
{ file = "pyproject.toml" },
|
|
69
|
+
{ file = "setup.py" },
|
|
70
|
+
{ file = "src/*.c" },
|
|
71
|
+
{ file = "src/*.h" },
|
|
72
|
+
{ file = "src/tree_sitter/*.h" },
|
|
73
|
+
]
|
package/scripts/tree-sitter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
@@ -15,6 +15,15 @@ export const cli = fileURLToPath(
|
|
|
15
15
|
export const libraryName =
|
|
16
16
|
process.platform === "win32" ? "diagnostic_dash.dll" : "diagnostic_dash.so";
|
|
17
17
|
|
|
18
|
+
function resultStatus(result, command = "Tree-sitter CLI") {
|
|
19
|
+
if (result.error) throw result.error;
|
|
20
|
+
if (result.signal) {
|
|
21
|
+
process.stderr.write(`${command} terminated by ${result.signal}.\n`);
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
24
|
+
return result.status ?? 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
18
27
|
export function runTreeSitter(args, options = {}) {
|
|
19
28
|
return spawnSync(cli, args, {
|
|
20
29
|
cwd: root,
|
|
@@ -30,26 +39,29 @@ export function runTreeSitter(args, options = {}) {
|
|
|
30
39
|
});
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
function tokenHeader(externals) {
|
|
43
|
+
const enumerators = new Map(
|
|
44
|
+
tokens.map(({ name, scanner }) => [name, scanner]),
|
|
45
|
+
);
|
|
46
|
+
const enumerations = externals.map(({ name }) => {
|
|
47
|
+
const scanner = enumerators.get(name);
|
|
48
|
+
if (scanner === undefined)
|
|
49
|
+
throw new Error(`Missing scanner name for ${name}.`);
|
|
50
|
+
return ` ${scanner},`;
|
|
51
|
+
});
|
|
52
|
+
return `/* Generated by npm run generate. */
|
|
42
53
|
|
|
43
54
|
#ifndef TREE_SITTER_DIAGNOSTIC_DASH_TOKENS_H_
|
|
44
55
|
#define TREE_SITTER_DIAGNOSTIC_DASH_TOKENS_H_
|
|
45
56
|
|
|
46
57
|
enum TokenType {
|
|
47
|
-
${
|
|
58
|
+
${enumerations.join("\n")}
|
|
48
59
|
TOKEN_TYPE_COUNT,
|
|
49
60
|
};
|
|
50
61
|
|
|
51
62
|
#endif
|
|
52
63
|
`;
|
|
64
|
+
}
|
|
53
65
|
|
|
54
66
|
export function generateParsers(outputRoot = root) {
|
|
55
67
|
const src = join(outputRoot, "src");
|
|
@@ -60,14 +72,22 @@ export function generateParsers(outputRoot = root) {
|
|
|
60
72
|
stdio: "inherit",
|
|
61
73
|
},
|
|
62
74
|
);
|
|
63
|
-
if (result
|
|
64
|
-
if (result.status !== 0) throw new Error("Parser generation failed.");
|
|
75
|
+
if (resultStatus(result) !== 0) throw new Error("Parser generation failed.");
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
const { externals } = JSON.parse(
|
|
78
|
+
readFileSync(join(src, "grammar.json"), "utf8"),
|
|
79
|
+
);
|
|
80
|
+
writeFileSync(join(src, "tokens.h"), tokenHeader(externals));
|
|
67
81
|
}
|
|
68
82
|
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
export function buildParser(output) {
|
|
84
|
+
mkdirSync(dirname(output), { recursive: true });
|
|
85
|
+
const result = runTreeSitter(["build", "--output", output, root]);
|
|
86
|
+
if (resultStatus(result) !== 0)
|
|
87
|
+
throw new Error(result.stderr || result.stdout || "Parser build failed.");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function main(args) {
|
|
71
91
|
if (["generate-all", "build-all"].includes(args[0]) && args.length !== 1)
|
|
72
92
|
throw new Error(`Usage: node scripts/tree-sitter.js ${args[0]}`);
|
|
73
93
|
if (args[0] === "build-all") buildParser(join(root, "parsers", libraryName));
|
|
@@ -77,7 +97,16 @@ if (import.meta.main) {
|
|
|
77
97
|
stdio: "inherit",
|
|
78
98
|
cwd: process.cwd(),
|
|
79
99
|
});
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
return resultStatus(result);
|
|
101
|
+
}
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (import.meta.main) {
|
|
106
|
+
try {
|
|
107
|
+
process.exitCode = main(process.argv.slice(2));
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
110
|
+
process.exitCode = 1;
|
|
82
111
|
}
|
|
83
112
|
}
|
package/src/parser.c
CHANGED
|
@@ -11803,7 +11803,7 @@ TS_PUBLIC const TSLanguage *tree_sitter_diagnostic_dash(void) {
|
|
|
11803
11803
|
.max_reserved_word_set_size = 0,
|
|
11804
11804
|
.metadata = {
|
|
11805
11805
|
.major_version = 0,
|
|
11806
|
-
.minor_version =
|
|
11806
|
+
.minor_version = 3,
|
|
11807
11807
|
.patch_version = 0,
|
|
11808
11808
|
},
|
|
11809
11809
|
};
|
package/src/scanner.c
CHANGED
|
@@ -725,8 +725,7 @@ static struct DelimFrame *push_delimiter(
|
|
|
725
725
|
frame.substitution_depth = stack->depth + 1;
|
|
726
726
|
} else if (parent) {
|
|
727
727
|
frame.keeps_slash = parent->keeps_slash;
|
|
728
|
-
//
|
|
729
|
-
// close before its surrounding substitution can close.
|
|
728
|
+
// Inside an operand's explicit quotes, parameters must close before the enclosing substitution.
|
|
730
729
|
bool quoted_operand = mode == DOUBLE && parameter_group(parent->kind);
|
|
731
730
|
if (parameter_group(kind) && !quoted_operand)
|
|
732
731
|
frame.substitution_depth = parent->substitution_depth;
|
|
@@ -978,7 +977,6 @@ static bool match_multiline(struct Input *line, struct HereBound *bound) {
|
|
|
978
977
|
bound->scanned = line->index;
|
|
979
978
|
bound->matched = 0;
|
|
980
979
|
}
|
|
981
|
-
// Candidate lines advance in source order. Share their overlapping prefix scans.
|
|
982
980
|
while (bound->scanned < end) {
|
|
983
981
|
uint8_t bytes[4];
|
|
984
982
|
size_t n = utf8((uint32_t)line->units[bound->scanned++].character, bytes);
|
|
@@ -1586,8 +1584,15 @@ static enum Header clause_token(
|
|
|
1586
1584
|
finish_wrappers(plan, list->base, t.start);
|
|
1587
1585
|
f = current(plan, list->base);
|
|
1588
1586
|
}
|
|
1589
|
-
if (!f
|
|
1590
|
-
if (list->position
|
|
1587
|
+
if (!f) return LIST_TOKEN;
|
|
1588
|
+
if (!clause_delimiter(f, t.kind, list->position)) {
|
|
1589
|
+
if (
|
|
1590
|
+
list->position != REDIRECTED_COMPOUND ||
|
|
1591
|
+
!clause_delimiter(f, t.kind, SEPARATED)
|
|
1592
|
+
)
|
|
1593
|
+
return LIST_TOKEN;
|
|
1594
|
+
recover_issue(plan, t, UNEXPECTED_TOKEN, false, t.end, RECOVERY_RESUME);
|
|
1595
|
+
} else if (list->position == EMPTY && f->kind != BEGIN_CASE_CLAUSE)
|
|
1591
1596
|
recover_issue(plan, t, COMMAND_GAP, false, t.start, RECOVERY_RESUME);
|
|
1592
1597
|
advance_clause(plan, f, t, list);
|
|
1593
1598
|
return CONSUMED;
|
package/src/tokens.h
CHANGED
package/tree-sitter.json
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
"title": "Diagnostic dash",
|
|
7
7
|
"scope": "source.diagnostic-dash",
|
|
8
8
|
"path": ".",
|
|
9
|
-
"external-files": [
|
|
9
|
+
"external-files": [
|
|
10
|
+
"src/tokens.h",
|
|
11
|
+
"src/tokens.json"
|
|
12
|
+
]
|
|
10
13
|
}
|
|
11
14
|
],
|
|
12
15
|
"metadata": {
|
|
13
|
-
"version": "0.
|
|
16
|
+
"version": "0.3.0",
|
|
14
17
|
"license": "MIT",
|
|
15
18
|
"description": "Tree-sitter grammar for diagnostics of dash.",
|
|
16
19
|
"links": {
|