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/LICENSE +21 -0
- package/README.md +122 -0
- package/clean.d.ts +14 -0
- package/clean.js +66 -0
- package/deparser.d.ts +100 -0
- package/deparser.js +299 -0
- package/esm/clean.js +60 -0
- package/esm/deparser.js +294 -0
- package/esm/index.js +10 -0
- package/esm/lexer.js +447 -0
- package/esm/parser.js +662 -0
- package/esm/types.js +1 -0
- package/index.d.ts +5 -0
- package/index.js +37 -0
- package/lexer.d.ts +130 -0
- package/lexer.js +451 -0
- package/package.json +42 -0
- package/parser.d.ts +135 -0
- package/parser.js +667 -0
- package/types.d.ts +203 -0
- package/types.js +2 -0
package/parser.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Script } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parser options
|
|
4
|
+
*/
|
|
5
|
+
export interface ParserOptions {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Bash Parser
|
|
9
|
+
*/
|
|
10
|
+
export declare class Parser {
|
|
11
|
+
private tokens;
|
|
12
|
+
private pos;
|
|
13
|
+
private options;
|
|
14
|
+
constructor(options?: ParserOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Parse bash source into AST
|
|
17
|
+
*/
|
|
18
|
+
parse(source: string): Script;
|
|
19
|
+
/**
|
|
20
|
+
* Check if at end of tokens
|
|
21
|
+
*/
|
|
22
|
+
private isAtEnd;
|
|
23
|
+
/**
|
|
24
|
+
* Peek at current token
|
|
25
|
+
*/
|
|
26
|
+
private peek;
|
|
27
|
+
/**
|
|
28
|
+
* Advance to next token
|
|
29
|
+
*/
|
|
30
|
+
private advance;
|
|
31
|
+
/**
|
|
32
|
+
* Check if current token matches type
|
|
33
|
+
*/
|
|
34
|
+
private check;
|
|
35
|
+
/**
|
|
36
|
+
* Consume token if it matches, otherwise error
|
|
37
|
+
*/
|
|
38
|
+
private expect;
|
|
39
|
+
/**
|
|
40
|
+
* Skip newlines
|
|
41
|
+
*/
|
|
42
|
+
private skipNewlines;
|
|
43
|
+
/**
|
|
44
|
+
* Skip newlines and separators
|
|
45
|
+
*/
|
|
46
|
+
private skipNewlinesAndSeparators;
|
|
47
|
+
/**
|
|
48
|
+
* Parse a command (handles logical operators)
|
|
49
|
+
*/
|
|
50
|
+
private parseCommand;
|
|
51
|
+
/**
|
|
52
|
+
* Parse logical OR (||)
|
|
53
|
+
*/
|
|
54
|
+
private parseLogicalOr;
|
|
55
|
+
/**
|
|
56
|
+
* Parse logical AND (&&)
|
|
57
|
+
*/
|
|
58
|
+
private parseLogicalAnd;
|
|
59
|
+
/**
|
|
60
|
+
* Parse pipeline (|)
|
|
61
|
+
*/
|
|
62
|
+
private parsePipeline;
|
|
63
|
+
/**
|
|
64
|
+
* Parse compound command or simple command
|
|
65
|
+
*/
|
|
66
|
+
private parseCompoundCommand;
|
|
67
|
+
/**
|
|
68
|
+
* Parse simple command
|
|
69
|
+
*/
|
|
70
|
+
private parseSimpleCommand;
|
|
71
|
+
/**
|
|
72
|
+
* Check if current token is a redirect operator
|
|
73
|
+
*/
|
|
74
|
+
private isRedirectOp;
|
|
75
|
+
/**
|
|
76
|
+
* Parse redirect
|
|
77
|
+
*/
|
|
78
|
+
private parseRedirect;
|
|
79
|
+
/**
|
|
80
|
+
* Parse if clause
|
|
81
|
+
*/
|
|
82
|
+
private parseIf;
|
|
83
|
+
/**
|
|
84
|
+
* Parse elif as nested if
|
|
85
|
+
*/
|
|
86
|
+
private parseElif;
|
|
87
|
+
/**
|
|
88
|
+
* Parse while clause
|
|
89
|
+
*/
|
|
90
|
+
private parseWhile;
|
|
91
|
+
/**
|
|
92
|
+
* Parse until clause
|
|
93
|
+
*/
|
|
94
|
+
private parseUntil;
|
|
95
|
+
/**
|
|
96
|
+
* Parse for clause
|
|
97
|
+
*/
|
|
98
|
+
private parseFor;
|
|
99
|
+
/**
|
|
100
|
+
* Parse case clause
|
|
101
|
+
*/
|
|
102
|
+
private parseCase;
|
|
103
|
+
/**
|
|
104
|
+
* Parse case item
|
|
105
|
+
*/
|
|
106
|
+
private parseCaseItem;
|
|
107
|
+
/**
|
|
108
|
+
* Parse subshell
|
|
109
|
+
*/
|
|
110
|
+
private parseSubshell;
|
|
111
|
+
/**
|
|
112
|
+
* Parse brace group
|
|
113
|
+
*/
|
|
114
|
+
private parseBraceGroup;
|
|
115
|
+
/**
|
|
116
|
+
* Parse function definition (function name { ... })
|
|
117
|
+
*/
|
|
118
|
+
private parseFunction;
|
|
119
|
+
/**
|
|
120
|
+
* Parse function shorthand (name () { ... })
|
|
121
|
+
*/
|
|
122
|
+
private parseFunctionShorthand;
|
|
123
|
+
/**
|
|
124
|
+
* Parse function body
|
|
125
|
+
*/
|
|
126
|
+
private parseFunctionBody;
|
|
127
|
+
/**
|
|
128
|
+
* Parse compound list (list of commands)
|
|
129
|
+
*/
|
|
130
|
+
private parseCompoundList;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Parse bash source into AST
|
|
134
|
+
*/
|
|
135
|
+
export declare function parse(source: string, options?: ParserOptions): Script;
|