sh-ast 0.3.1 → 0.5.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/README.md +199 -143
- package/dist/analyze/ansi-c-escapes.d.ts +1 -1
- package/dist/analyze/ansi-c-escapes.js +1 -1
- package/dist/analyze/enumerate-commands.d.ts +11 -16
- package/dist/analyze/enumerate-commands.d.ts.map +1 -1
- package/dist/analyze/enumerate-commands.js +82 -92
- package/dist/analyze/enumerate-commands.js.map +1 -1
- package/dist/analyze/index.d.ts +3 -2
- package/dist/analyze/index.d.ts.map +1 -1
- package/dist/analyze/index.js +1 -1
- package/dist/analyze/node-helpers.d.ts +10 -21
- package/dist/analyze/node-helpers.d.ts.map +1 -1
- package/dist/analyze/node-helpers.js +16 -27
- package/dist/analyze/node-helpers.js.map +1 -1
- package/dist/analyze/resolve-argv0.d.ts +6 -6
- package/dist/analyze/resolve-argv0.js +6 -6
- package/dist/analyze/resolve-word.d.ts +7 -10
- package/dist/analyze/resolve-word.d.ts.map +1 -1
- package/dist/analyze/resolve-word.js +39 -22
- package/dist/analyze/resolve-word.js.map +1 -1
- package/dist/analyze.d.ts +3780 -397
- package/dist/errors.d.ts +6 -79
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -64
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +20 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/dist/sh-ast.d.ts +3616 -1020
- package/dist/syntax-errors.d.ts +56 -0
- package/dist/syntax-errors.d.ts.map +1 -0
- package/dist/syntax-errors.js +80 -0
- package/dist/syntax-errors.js.map +1 -0
- package/dist/syntax-print-errors.d.ts +35 -0
- package/dist/syntax-print-errors.d.ts.map +1 -0
- package/dist/syntax-print-errors.js +37 -0
- package/dist/syntax-print-errors.js.map +1 -0
- package/dist/syntax-print.d.ts +49 -0
- package/dist/syntax-print.d.ts.map +1 -0
- package/dist/syntax-print.js +86 -0
- package/dist/syntax-print.js.map +1 -0
- package/dist/syntax-snapshot.d.ts +47 -0
- package/dist/syntax-snapshot.d.ts.map +1 -0
- package/dist/syntax-snapshot.js +121 -0
- package/dist/syntax-snapshot.js.map +1 -0
- package/dist/syntax-walk-bounds.d.ts +18 -0
- package/dist/syntax-walk-bounds.d.ts.map +1 -0
- package/dist/syntax-walk-bounds.js +188 -0
- package/dist/syntax-walk-bounds.js.map +1 -0
- package/dist/syntax-walk-errors.d.ts +19 -0
- package/dist/syntax-walk-errors.d.ts.map +1 -0
- package/dist/syntax-walk-errors.js +23 -0
- package/dist/syntax-walk-errors.js.map +1 -0
- package/dist/syntax-walk-license.d.ts +3 -0
- package/dist/syntax-walk-license.d.ts.map +1 -0
- package/dist/syntax-walk-license.js +37 -0
- package/dist/syntax-walk-license.js.map +1 -0
- package/dist/syntax-walk.d.ts +46 -0
- package/dist/syntax-walk.d.ts.map +1 -0
- package/dist/syntax-walk.js +322 -0
- package/dist/syntax-walk.js.map +1 -0
- package/dist/syntax-wire.d.ts +31 -0
- package/dist/syntax-wire.d.ts.map +1 -0
- package/dist/syntax-wire.js +202 -0
- package/dist/syntax-wire.js.map +1 -0
- package/dist/syntax.d.ts +65 -0
- package/dist/syntax.d.ts.map +1 -0
- package/dist/syntax.js +152 -0
- package/dist/syntax.js.map +1 -0
- package/dist/wasm-instance.d.ts +5 -8
- package/dist/wasm-instance.d.ts.map +1 -1
- package/dist/wasm-instance.js +44 -47
- package/dist/wasm-instance.js.map +1 -1
- package/generated/syntax-constants.d.ts +1652 -0
- package/generated/syntax-constants.js +1384 -0
- package/generated/syntax-schema.d.ts +60 -0
- package/generated/syntax-schema.js +1740 -0
- package/generated/syntax-types.d.ts +1977 -0
- package/package.json +2 -2
- package/shim/sh-ast.wasm +0 -0
- package/dist/normalize.d.ts +0 -52
- package/dist/normalize.d.ts.map +0 -1
- package/dist/normalize.js +0 -260
- package/dist/normalize.js.map +0 -1
- package/dist/parse.d.ts +0 -50
- package/dist/parse.d.ts.map +0 -1
- package/dist/parse.js +0 -125
- package/dist/parse.js.map +0 -1
- package/dist/types.d.ts +0 -74
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/visitor-keys.d.ts +0 -21
- package/dist/visitor-keys.d.ts.map +0 -1
- package/dist/visitor-keys.js +0 -23
- package/dist/visitor-keys.js.map +0 -1
- package/dist/walk.d.ts +0 -18
- package/dist/walk.d.ts.map +0 -1
- package/dist/walk.js +0 -40
- package/dist/walk.js.map +0 -1
- package/generated/child-type-schema.d.ts +0 -14
- package/generated/child-type-schema.js +0 -188
- package/generated/node-types.d.ts +0 -1002
- package/generated/position-fields.d.ts +0 -21
- package/generated/position-fields.js +0 -50
- package/generated/visitor-keys.d.ts +0 -11
- package/generated/visitor-keys.js +0 -50
package/dist/visitor-keys.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { deepFreeze } from './deep-freeze.js';
|
|
2
|
-
import { visitorKeys as generatedVisitorKeys } from '../generated/visitor-keys.js';
|
|
3
|
-
/**
|
|
4
|
-
* Maps each normalized node `type` to the field names (lowercased, matching
|
|
5
|
-
* the normalized node shape produced by `normalize`) whose values hold child
|
|
6
|
-
* nodes.
|
|
7
|
-
*
|
|
8
|
-
* Generated from mvdan/sh's `syntax` package struct definitions by
|
|
9
|
-
* `tools/gen-visitor-keys` (see design/ARCHITECTURE.md, "The schema table is
|
|
10
|
-
* generated, not hand-written") — this module only re-exports the generated
|
|
11
|
-
* table under the public name, frozen. {@link walk} does not depend on this
|
|
12
|
-
* table for correctness — it discovers children structurally — so any gap
|
|
13
|
-
* here (there shouldn't be one; the kitchen-sink golden test guards it)
|
|
14
|
-
* affects only external consumers that choose to traverse via this table.
|
|
15
|
-
*
|
|
16
|
-
* Frozen (including each per-type field-name array) so immutability of this
|
|
17
|
-
* shared, module-scoped table is a contract, not just a convention any
|
|
18
|
-
* importer happens to honor.
|
|
19
|
-
*
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export const visitorKeys = deepFreeze(generatedVisitorKeys);
|
|
23
|
-
//# sourceMappingURL=visitor-keys.js.map
|
package/dist/visitor-keys.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-keys.js","sourceRoot":"","sources":["../src/visitor-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEnF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,UAAU,CAAC,oBAAoB,CAAC,CAAC"}
|
package/dist/walk.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ShNode } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Visits every node in a normalized tree, pre-order (parent before
|
|
4
|
-
* children), starting at `node`.
|
|
5
|
-
*
|
|
6
|
-
* Children are discovered structurally: any field on a visited node whose
|
|
7
|
-
* value is itself a normalized node (or an array of normalized nodes) is
|
|
8
|
-
* treated as a child. This is deliberately not driven off {@link
|
|
9
|
-
* visitorKeys} — the spike's hand-written visitor-keys table missed
|
|
10
|
-
* `DeclClause.Variant` (see design/ARCHITECTURE.md) and silently
|
|
11
|
-
* under-walked the tree, and `visitorKeys` remains hand-maintained pending a
|
|
12
|
-
* schema generator (tracked separately). Walking structurally means this
|
|
13
|
-
* function's completeness never depends on that table's accuracy.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export declare function walk(node: ShNode, visit: (node: ShNode, parent: ShNode | null) => void): void;
|
|
18
|
-
//# sourceMappingURL=walk.d.ts.map
|
package/dist/walk.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA6BzC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,CAE7F"}
|
package/dist/walk.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
function isShNode(value) {
|
|
2
|
-
return (typeof value === 'object' &&
|
|
3
|
-
value !== null &&
|
|
4
|
-
!Array.isArray(value) &&
|
|
5
|
-
typeof value.type === 'string' &&
|
|
6
|
-
Array.isArray(value.range));
|
|
7
|
-
}
|
|
8
|
-
function walkNode(node, parent, visit) {
|
|
9
|
-
visit(node, parent);
|
|
10
|
-
for (const value of Object.values(node)) {
|
|
11
|
-
if (isShNode(value)) {
|
|
12
|
-
walkNode(value, node, visit);
|
|
13
|
-
}
|
|
14
|
-
else if (Array.isArray(value)) {
|
|
15
|
-
for (const item of value) {
|
|
16
|
-
if (isShNode(item))
|
|
17
|
-
walkNode(item, node, visit);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Visits every node in a normalized tree, pre-order (parent before
|
|
24
|
-
* children), starting at `node`.
|
|
25
|
-
*
|
|
26
|
-
* Children are discovered structurally: any field on a visited node whose
|
|
27
|
-
* value is itself a normalized node (or an array of normalized nodes) is
|
|
28
|
-
* treated as a child. This is deliberately not driven off {@link
|
|
29
|
-
* visitorKeys} — the spike's hand-written visitor-keys table missed
|
|
30
|
-
* `DeclClause.Variant` (see design/ARCHITECTURE.md) and silently
|
|
31
|
-
* under-walked the tree, and `visitorKeys` remains hand-maintained pending a
|
|
32
|
-
* schema generator (tracked separately). Walking structurally means this
|
|
33
|
-
* function's completeness never depends on that table's accuracy.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export function walk(node, visit) {
|
|
38
|
-
walkNode(node, null, visit);
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=walk.js.map
|
package/dist/walk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ;QACtD,KAAK,CAAC,OAAO,CAAE,KAA6B,CAAC,KAAK,CAAC,CACpD,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CACf,IAAY,EACZ,MAAqB,EACrB,KAAoD;IAEpD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,KAAK,MAAM,IAAI,IAAI,KAAkB,EAAE,CAAC;gBACtC,IAAI,QAAQ,CAAC,IAAI,CAAC;oBAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,KAAoD;IACrF,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Code generated by tools/gen-visitor-keys from mvdan.cc/sh/v3 v3.13.1. DO NOT EDIT.
|
|
2
|
-
// See design/ARCHITECTURE.md, "The schema table is generated, not hand-written".
|
|
3
|
-
/**
|
|
4
|
-
* `(parentType, fieldName) -> childType` for node fields whose static Go
|
|
5
|
-
* type is a concrete struct rather than an interface — typedjson only
|
|
6
|
-
* emits a "Type" discriminator for interface-typed fields, so these need
|
|
7
|
-
* the child type injected during normalization. A `null` value means the
|
|
8
|
-
* field's static type is a Node-derived interface (already
|
|
9
|
-
* self-discriminating). See design/ARCHITECTURE.md, "The schema table is
|
|
10
|
-
* generated, not hand-written".
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export declare const CHILD_TYPE_SCHEMA: Record<string, Record<string, string | null>>;
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
// Code generated by tools/gen-visitor-keys from mvdan.cc/sh/v3 v3.13.1. DO NOT EDIT.
|
|
2
|
-
// See design/ARCHITECTURE.md, "The schema table is generated, not hand-written".
|
|
3
|
-
export const CHILD_TYPE_SCHEMA = {
|
|
4
|
-
ArithmCmd: {
|
|
5
|
-
X: null,
|
|
6
|
-
},
|
|
7
|
-
ArithmExp: {
|
|
8
|
-
X: null,
|
|
9
|
-
},
|
|
10
|
-
ArrayElem: {
|
|
11
|
-
Comments: 'Comment',
|
|
12
|
-
Index: null,
|
|
13
|
-
Value: 'Word',
|
|
14
|
-
},
|
|
15
|
-
ArrayExpr: {
|
|
16
|
-
Elems: 'ArrayElem',
|
|
17
|
-
Last: 'Comment',
|
|
18
|
-
},
|
|
19
|
-
Assign: {
|
|
20
|
-
Array: 'ArrayExpr',
|
|
21
|
-
Index: null,
|
|
22
|
-
Name: 'Lit',
|
|
23
|
-
Value: 'Word',
|
|
24
|
-
},
|
|
25
|
-
BinaryArithm: {
|
|
26
|
-
X: null,
|
|
27
|
-
Y: null,
|
|
28
|
-
},
|
|
29
|
-
BinaryCmd: {
|
|
30
|
-
X: 'Stmt',
|
|
31
|
-
Y: 'Stmt',
|
|
32
|
-
},
|
|
33
|
-
BinaryTest: {
|
|
34
|
-
X: null,
|
|
35
|
-
Y: null,
|
|
36
|
-
},
|
|
37
|
-
Block: {
|
|
38
|
-
Last: 'Comment',
|
|
39
|
-
Stmts: 'Stmt',
|
|
40
|
-
},
|
|
41
|
-
BraceExp: {
|
|
42
|
-
Elems: 'Word',
|
|
43
|
-
},
|
|
44
|
-
CStyleLoop: {
|
|
45
|
-
Cond: null,
|
|
46
|
-
Init: null,
|
|
47
|
-
Post: null,
|
|
48
|
-
},
|
|
49
|
-
CallExpr: {
|
|
50
|
-
Args: 'Word',
|
|
51
|
-
Assigns: 'Assign',
|
|
52
|
-
},
|
|
53
|
-
CaseClause: {
|
|
54
|
-
Items: 'CaseItem',
|
|
55
|
-
Last: 'Comment',
|
|
56
|
-
Word: 'Word',
|
|
57
|
-
},
|
|
58
|
-
CaseItem: {
|
|
59
|
-
Comments: 'Comment',
|
|
60
|
-
Last: 'Comment',
|
|
61
|
-
Patterns: 'Word',
|
|
62
|
-
Stmts: 'Stmt',
|
|
63
|
-
},
|
|
64
|
-
CmdSubst: {
|
|
65
|
-
Last: 'Comment',
|
|
66
|
-
Stmts: 'Stmt',
|
|
67
|
-
},
|
|
68
|
-
Comment: {},
|
|
69
|
-
CoprocClause: {
|
|
70
|
-
Name: 'Word',
|
|
71
|
-
Stmt: 'Stmt',
|
|
72
|
-
},
|
|
73
|
-
DblQuoted: {
|
|
74
|
-
Parts: null,
|
|
75
|
-
},
|
|
76
|
-
DeclClause: {
|
|
77
|
-
Args: 'Assign',
|
|
78
|
-
Variant: 'Lit',
|
|
79
|
-
},
|
|
80
|
-
Expansion: {
|
|
81
|
-
Word: 'Word',
|
|
82
|
-
},
|
|
83
|
-
ExtGlob: {
|
|
84
|
-
Pattern: 'Lit',
|
|
85
|
-
},
|
|
86
|
-
File: {
|
|
87
|
-
Last: 'Comment',
|
|
88
|
-
Stmts: 'Stmt',
|
|
89
|
-
},
|
|
90
|
-
FlagsArithm: {
|
|
91
|
-
Flags: 'Lit',
|
|
92
|
-
X: null,
|
|
93
|
-
},
|
|
94
|
-
ForClause: {
|
|
95
|
-
Do: 'Stmt',
|
|
96
|
-
DoLast: 'Comment',
|
|
97
|
-
Loop: null,
|
|
98
|
-
},
|
|
99
|
-
FuncDecl: {
|
|
100
|
-
Body: 'Stmt',
|
|
101
|
-
Name: 'Lit',
|
|
102
|
-
Names: 'Lit',
|
|
103
|
-
},
|
|
104
|
-
IfClause: {
|
|
105
|
-
Cond: 'Stmt',
|
|
106
|
-
CondLast: 'Comment',
|
|
107
|
-
Else: 'IfClause',
|
|
108
|
-
Last: 'Comment',
|
|
109
|
-
Then: 'Stmt',
|
|
110
|
-
ThenLast: 'Comment',
|
|
111
|
-
},
|
|
112
|
-
LetClause: {
|
|
113
|
-
Exprs: null,
|
|
114
|
-
},
|
|
115
|
-
Lit: {},
|
|
116
|
-
ParamExp: {
|
|
117
|
-
Exp: 'Expansion',
|
|
118
|
-
Flags: 'Lit',
|
|
119
|
-
Index: null,
|
|
120
|
-
Modifiers: 'Lit',
|
|
121
|
-
NestedParam: null,
|
|
122
|
-
Param: 'Lit',
|
|
123
|
-
Repl: 'Replace',
|
|
124
|
-
Slice: 'Slice',
|
|
125
|
-
},
|
|
126
|
-
ParenArithm: {
|
|
127
|
-
X: null,
|
|
128
|
-
},
|
|
129
|
-
ParenTest: {
|
|
130
|
-
X: null,
|
|
131
|
-
},
|
|
132
|
-
ProcSubst: {
|
|
133
|
-
Last: 'Comment',
|
|
134
|
-
Stmts: 'Stmt',
|
|
135
|
-
},
|
|
136
|
-
Redirect: {
|
|
137
|
-
Hdoc: 'Word',
|
|
138
|
-
N: 'Lit',
|
|
139
|
-
Word: 'Word',
|
|
140
|
-
},
|
|
141
|
-
Replace: {
|
|
142
|
-
Orig: 'Word',
|
|
143
|
-
With: 'Word',
|
|
144
|
-
},
|
|
145
|
-
SglQuoted: {},
|
|
146
|
-
Slice: {
|
|
147
|
-
Length: null,
|
|
148
|
-
Offset: null,
|
|
149
|
-
},
|
|
150
|
-
Stmt: {
|
|
151
|
-
Cmd: null,
|
|
152
|
-
Comments: 'Comment',
|
|
153
|
-
Redirs: 'Redirect',
|
|
154
|
-
},
|
|
155
|
-
Subshell: {
|
|
156
|
-
Last: 'Comment',
|
|
157
|
-
Stmts: 'Stmt',
|
|
158
|
-
},
|
|
159
|
-
TestClause: {
|
|
160
|
-
X: null,
|
|
161
|
-
},
|
|
162
|
-
TestDecl: {
|
|
163
|
-
Body: 'Stmt',
|
|
164
|
-
Description: 'Word',
|
|
165
|
-
},
|
|
166
|
-
TimeClause: {
|
|
167
|
-
Stmt: 'Stmt',
|
|
168
|
-
},
|
|
169
|
-
UnaryArithm: {
|
|
170
|
-
X: null,
|
|
171
|
-
},
|
|
172
|
-
UnaryTest: {
|
|
173
|
-
X: null,
|
|
174
|
-
},
|
|
175
|
-
WhileClause: {
|
|
176
|
-
Cond: 'Stmt',
|
|
177
|
-
CondLast: 'Comment',
|
|
178
|
-
Do: 'Stmt',
|
|
179
|
-
DoLast: 'Comment',
|
|
180
|
-
},
|
|
181
|
-
Word: {
|
|
182
|
-
Parts: null,
|
|
183
|
-
},
|
|
184
|
-
WordIter: {
|
|
185
|
-
Items: 'Word',
|
|
186
|
-
Name: 'Lit',
|
|
187
|
-
},
|
|
188
|
-
};
|