bash-ast 0.1.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/types.d.ts ADDED
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Position in source code
3
+ */
4
+ export interface Position {
5
+ line: number;
6
+ column: number;
7
+ offset: number;
8
+ }
9
+ /**
10
+ * Range in source code
11
+ */
12
+ export interface Range {
13
+ start: Position;
14
+ end: Position;
15
+ }
16
+ /**
17
+ * Base node interface
18
+ */
19
+ export interface BaseNode {
20
+ type: string;
21
+ range?: Range;
22
+ }
23
+ /**
24
+ * Script - root node containing a list of commands
25
+ */
26
+ export interface Script extends BaseNode {
27
+ type: 'Script';
28
+ commands: Command[];
29
+ }
30
+ /**
31
+ * Union type for all command types
32
+ */
33
+ export type Command = SimpleCommand | Pipeline | LogicalExpression | Subshell | CompoundList | IfClause | WhileClause | UntilClause | ForClause | CaseClause | FunctionDefinition;
34
+ /**
35
+ * Simple command (e.g., `echo hello`)
36
+ */
37
+ export interface SimpleCommand extends BaseNode {
38
+ type: 'SimpleCommand';
39
+ name?: Word;
40
+ prefix?: AssignmentWord[];
41
+ suffix?: (Word | Redirect)[];
42
+ }
43
+ /**
44
+ * Word - a token that can be expanded
45
+ */
46
+ export interface Word extends BaseNode {
47
+ type: 'Word';
48
+ text: string;
49
+ expansion?: Expansion[];
50
+ }
51
+ /**
52
+ * Assignment word (e.g., `VAR=value`)
53
+ */
54
+ export interface AssignmentWord extends BaseNode {
55
+ type: 'AssignmentWord';
56
+ text: string;
57
+ expansion?: Expansion[];
58
+ }
59
+ /**
60
+ * Union type for all expansion types
61
+ */
62
+ export type Expansion = ParameterExpansion | CommandSubstitution | ArithmeticExpansion;
63
+ /**
64
+ * Parameter expansion (e.g., `$VAR`, `${VAR}`, `${VAR:-default}`)
65
+ */
66
+ export interface ParameterExpansion extends BaseNode {
67
+ type: 'ParameterExpansion';
68
+ parameter: string;
69
+ kind?: 'default' | 'assign' | 'error' | 'alternative' | 'length' | 'prefix' | 'suffix';
70
+ word?: Word;
71
+ op?: string;
72
+ }
73
+ /**
74
+ * Command substitution (e.g., `$(command)` or `` `command` ``)
75
+ */
76
+ export interface CommandSubstitution extends BaseNode {
77
+ type: 'CommandSubstitution';
78
+ command: Script;
79
+ backtick?: boolean;
80
+ }
81
+ /**
82
+ * Arithmetic expansion (e.g., `$((1 + 2))`)
83
+ */
84
+ export interface ArithmeticExpansion extends BaseNode {
85
+ type: 'ArithmeticExpansion';
86
+ expression: string;
87
+ }
88
+ /**
89
+ * Redirect (e.g., `> file`, `2>&1`, `< input`)
90
+ */
91
+ export interface Redirect extends BaseNode {
92
+ type: 'Redirect';
93
+ op: RedirectOp;
94
+ file?: Word;
95
+ numberIo?: number;
96
+ heredoc?: HereDoc;
97
+ }
98
+ /**
99
+ * Redirect operators
100
+ */
101
+ export type RedirectOp = '>' | '>>' | '<' | '<<' | '<<-' | '<<<' | '<>' | '>&' | '<&' | '>|';
102
+ /**
103
+ * Here document
104
+ */
105
+ export interface HereDoc extends BaseNode {
106
+ type: 'HereDoc';
107
+ delimiter: string;
108
+ content: string;
109
+ quoted?: boolean;
110
+ }
111
+ /**
112
+ * Pipeline (e.g., `cmd1 | cmd2 | cmd3`)
113
+ */
114
+ export interface Pipeline extends BaseNode {
115
+ type: 'Pipeline';
116
+ commands: Command[];
117
+ bang?: boolean;
118
+ }
119
+ /**
120
+ * Logical expression (e.g., `cmd1 && cmd2`, `cmd1 || cmd2`)
121
+ */
122
+ export interface LogicalExpression extends BaseNode {
123
+ type: 'LogicalExpression';
124
+ op: '&&' | '||';
125
+ left: Command;
126
+ right: Command;
127
+ }
128
+ /**
129
+ * Subshell (e.g., `(cmd1; cmd2)`)
130
+ */
131
+ export interface Subshell extends BaseNode {
132
+ type: 'Subshell';
133
+ list: CompoundList;
134
+ }
135
+ /**
136
+ * Compound list - a list of commands
137
+ */
138
+ export interface CompoundList extends BaseNode {
139
+ type: 'CompoundList';
140
+ commands: Command[];
141
+ }
142
+ /**
143
+ * If clause
144
+ */
145
+ export interface IfClause extends BaseNode {
146
+ type: 'IfClause';
147
+ condition: CompoundList;
148
+ then: CompoundList;
149
+ else?: CompoundList | IfClause;
150
+ }
151
+ /**
152
+ * While clause
153
+ */
154
+ export interface WhileClause extends BaseNode {
155
+ type: 'WhileClause';
156
+ condition: CompoundList;
157
+ body: CompoundList;
158
+ }
159
+ /**
160
+ * Until clause
161
+ */
162
+ export interface UntilClause extends BaseNode {
163
+ type: 'UntilClause';
164
+ condition: CompoundList;
165
+ body: CompoundList;
166
+ }
167
+ /**
168
+ * For clause
169
+ */
170
+ export interface ForClause extends BaseNode {
171
+ type: 'ForClause';
172
+ name: string;
173
+ wordlist?: Word[];
174
+ body: CompoundList;
175
+ }
176
+ /**
177
+ * Case clause
178
+ */
179
+ export interface CaseClause extends BaseNode {
180
+ type: 'CaseClause';
181
+ word: Word;
182
+ cases: CaseItem[];
183
+ }
184
+ /**
185
+ * Case item
186
+ */
187
+ export interface CaseItem extends BaseNode {
188
+ type: 'CaseItem';
189
+ pattern: Word[];
190
+ body?: CompoundList;
191
+ }
192
+ /**
193
+ * Function definition
194
+ */
195
+ export interface FunctionDefinition extends BaseNode {
196
+ type: 'FunctionDefinition';
197
+ name: string;
198
+ body: CompoundList | Subshell;
199
+ }
200
+ /**
201
+ * Union type for all AST nodes
202
+ */
203
+ export type Node = Script | Command | Word | AssignmentWord | Redirect | HereDoc | CompoundList | CaseItem;
package/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });