shell-dsl 0.0.35 → 0.0.37
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 +27 -3
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/commands/echo/echo.cjs +29 -23
- package/dist/cjs/src/commands/echo/echo.cjs.map +3 -3
- package/dist/cjs/src/commands/index.cjs +6 -2
- package/dist/cjs/src/commands/index.cjs.map +3 -3
- package/dist/cjs/src/commands/od/od.cjs +274 -0
- package/dist/cjs/src/commands/od/od.cjs.map +10 -0
- package/dist/cjs/src/index.cjs +2 -7
- package/dist/cjs/src/index.cjs.map +3 -3
- package/dist/cjs/src/interpreter/interpreter.cjs +186 -68
- package/dist/cjs/src/interpreter/interpreter.cjs.map +3 -3
- package/dist/cjs/src/parser/ast.cjs +5 -25
- package/dist/cjs/src/parser/ast.cjs.map +3 -3
- package/dist/cjs/src/parser/index.cjs +2 -7
- package/dist/cjs/src/parser/index.cjs.map +3 -3
- package/dist/cjs/src/parser/parser.cjs +132 -82
- package/dist/cjs/src/parser/parser.cjs.map +3 -3
- package/dist/mjs/index.mjs +4 -2
- package/dist/mjs/index.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/src/commands/echo/echo.mjs +29 -23
- package/dist/mjs/src/commands/echo/echo.mjs.map +3 -3
- package/dist/mjs/src/commands/index.mjs +6 -2
- package/dist/mjs/src/commands/index.mjs.map +3 -3
- package/dist/mjs/src/commands/od/od.mjs +234 -0
- package/dist/mjs/src/commands/od/od.mjs.map +10 -0
- package/dist/mjs/src/index.mjs +4 -14
- package/dist/mjs/src/index.mjs.map +3 -3
- package/dist/mjs/src/interpreter/interpreter.mjs +186 -68
- package/dist/mjs/src/interpreter/interpreter.mjs.map +3 -3
- package/dist/mjs/src/parser/ast.mjs +5 -25
- package/dist/mjs/src/parser/ast.mjs.map +3 -3
- package/dist/mjs/src/parser/index.mjs +4 -14
- package/dist/mjs/src/parser/index.mjs.map +3 -3
- package/dist/mjs/src/parser/parser.mjs +132 -82
- package/dist/mjs/src/parser/parser.mjs.map +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/src/commands/index.d.ts +1 -0
- package/dist/types/src/commands/od/od.d.ts +2 -0
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/interpreter/interpreter.d.ts +15 -1
- package/dist/types/src/parser/ast.d.ts +34 -38
- package/dist/types/src/parser/index.d.ts +2 -2
- package/dist/types/src/parser/parser.d.ts +4 -1
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ export { ShellError, LexError, ParseError } from "./errors.ts";
|
|
|
6
6
|
export { Lexer, lex, tokenToString } from "./lexer/index.ts";
|
|
7
7
|
export type { Token, RedirectMode } from "./lexer/index.ts";
|
|
8
8
|
export { Parser, parse } from "./parser/index.ts";
|
|
9
|
-
export type { ASTNode, Redirect, CommandNode, PipelineNode, AndNode, OrNode, SequenceNode,
|
|
10
|
-
export { isCommandNode, isPipelineNode, isAndNode, isOrNode, isSequenceNode,
|
|
9
|
+
export type { ASTNode, Redirect, CommandNode, PipelineNode, AndNode, OrNode, SequenceNode, WordNode, WordPart, TextPart, VariablePart, SubstitutionPart, ArithmeticPart, IfNode, ForNode, WhileNode, UntilNode, CaseNode, CaseClause, } from "./parser/index.ts";
|
|
10
|
+
export { isWordNode, isCommandNode, isPipelineNode, isAndNode, isOrNode, isSequenceNode, isIfNode, isForNode, isWhileNode, isUntilNode, isCaseNode, } from "./parser/index.ts";
|
|
11
11
|
export { Interpreter, type InterpreterOptions, BreakException, ContinueException } from "./interpreter/index.ts";
|
|
12
12
|
export { createVirtualFS } from "./fs/index.ts";
|
|
13
13
|
export { FileSystem, ReadOnlyFileSystem, WebFileSystem, createWebUnderlyingFS, type PathOps, type Permission, type PermissionRules, type UnderlyingFS, } from "./fs/index.ts";
|
|
@@ -42,7 +42,21 @@ export declare class Interpreter {
|
|
|
42
42
|
private executeUntil;
|
|
43
43
|
private executeCase;
|
|
44
44
|
private matchCasePattern;
|
|
45
|
-
private
|
|
45
|
+
private expandCommandWords;
|
|
46
|
+
private expandWordForCommand;
|
|
47
|
+
private expandWordScalar;
|
|
48
|
+
private expandWordFields;
|
|
49
|
+
private expandWordPart;
|
|
50
|
+
private executeSubstitution;
|
|
51
|
+
private getIFS;
|
|
52
|
+
private splitUnquotedExpansion;
|
|
53
|
+
private createExpandedField;
|
|
54
|
+
private appendSegment;
|
|
55
|
+
private expandPathname;
|
|
56
|
+
private hasUnquotedGlobMeta;
|
|
57
|
+
private fieldToString;
|
|
58
|
+
private fieldToGlobPattern;
|
|
59
|
+
private escapeLiteralGlobChars;
|
|
46
60
|
private evaluateArithmetic;
|
|
47
61
|
private parseArithmeticExpr;
|
|
48
62
|
setCwd(cwd: string): void;
|
|
@@ -1,18 +1,43 @@
|
|
|
1
1
|
export type RedirectMode = ">" | ">>" | "<" | "2>" | "2>>" | "&>" | "&>>" | "2>&1" | "1>&2";
|
|
2
|
+
export interface TextPart {
|
|
3
|
+
type: "text";
|
|
4
|
+
value: string;
|
|
5
|
+
quoted: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface VariablePart {
|
|
8
|
+
type: "variable";
|
|
9
|
+
name: string;
|
|
10
|
+
quoted: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SubstitutionPart {
|
|
13
|
+
type: "substitution";
|
|
14
|
+
command: ASTNode;
|
|
15
|
+
quoted: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ArithmeticPart {
|
|
18
|
+
type: "arithmetic";
|
|
19
|
+
expression: string;
|
|
20
|
+
quoted: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type WordPart = TextPart | VariablePart | SubstitutionPart | ArithmeticPart;
|
|
23
|
+
export interface WordNode {
|
|
24
|
+
type: "word";
|
|
25
|
+
parts: WordPart[];
|
|
26
|
+
}
|
|
2
27
|
export interface Redirect {
|
|
3
28
|
mode: RedirectMode;
|
|
4
|
-
target:
|
|
29
|
+
target: WordNode;
|
|
5
30
|
heredocContent?: boolean;
|
|
6
31
|
}
|
|
7
|
-
export type ASTNode = CommandNode | PipelineNode | AndNode | OrNode | SequenceNode |
|
|
32
|
+
export type ASTNode = CommandNode | PipelineNode | AndNode | OrNode | SequenceNode | IfNode | ForNode | WhileNode | UntilNode | CaseNode;
|
|
8
33
|
export interface CommandNode {
|
|
9
34
|
type: "command";
|
|
10
|
-
name:
|
|
11
|
-
args:
|
|
35
|
+
name: WordNode;
|
|
36
|
+
args: WordNode[];
|
|
12
37
|
redirects: Redirect[];
|
|
13
38
|
assignments: Array<{
|
|
14
39
|
name: string;
|
|
15
|
-
value:
|
|
40
|
+
value: WordNode;
|
|
16
41
|
}>;
|
|
17
42
|
}
|
|
18
43
|
export interface PipelineNode {
|
|
@@ -33,26 +58,6 @@ export interface SequenceNode {
|
|
|
33
58
|
type: "sequence";
|
|
34
59
|
commands: ASTNode[];
|
|
35
60
|
}
|
|
36
|
-
export interface LiteralNode {
|
|
37
|
-
type: "literal";
|
|
38
|
-
value: string;
|
|
39
|
-
}
|
|
40
|
-
export interface VariableNode {
|
|
41
|
-
type: "variable";
|
|
42
|
-
name: string;
|
|
43
|
-
}
|
|
44
|
-
export interface SubstitutionNode {
|
|
45
|
-
type: "substitution";
|
|
46
|
-
command: ASTNode;
|
|
47
|
-
}
|
|
48
|
-
export interface GlobNode {
|
|
49
|
-
type: "glob";
|
|
50
|
-
pattern: string;
|
|
51
|
-
}
|
|
52
|
-
export interface ConcatNode {
|
|
53
|
-
type: "concat";
|
|
54
|
-
parts: ASTNode[];
|
|
55
|
-
}
|
|
56
61
|
export interface IfNode {
|
|
57
62
|
type: "if";
|
|
58
63
|
condition: ASTNode;
|
|
@@ -66,7 +71,7 @@ export interface IfNode {
|
|
|
66
71
|
export interface ForNode {
|
|
67
72
|
type: "for";
|
|
68
73
|
variable: string;
|
|
69
|
-
items:
|
|
74
|
+
items: WordNode[];
|
|
70
75
|
body: ASTNode;
|
|
71
76
|
}
|
|
72
77
|
export interface WhileNode {
|
|
@@ -80,31 +85,22 @@ export interface UntilNode {
|
|
|
80
85
|
body: ASTNode;
|
|
81
86
|
}
|
|
82
87
|
export interface CaseClause {
|
|
83
|
-
patterns:
|
|
88
|
+
patterns: WordNode[];
|
|
84
89
|
body: ASTNode;
|
|
85
90
|
}
|
|
86
91
|
export interface CaseNode {
|
|
87
92
|
type: "case";
|
|
88
|
-
word:
|
|
93
|
+
word: WordNode;
|
|
89
94
|
clauses: CaseClause[];
|
|
90
95
|
}
|
|
91
|
-
export
|
|
92
|
-
type: "arithmetic";
|
|
93
|
-
expression: string;
|
|
94
|
-
}
|
|
96
|
+
export declare function isWordNode(node: ASTNode | WordNode): node is WordNode;
|
|
95
97
|
export declare function isCommandNode(node: ASTNode): node is CommandNode;
|
|
96
98
|
export declare function isPipelineNode(node: ASTNode): node is PipelineNode;
|
|
97
99
|
export declare function isAndNode(node: ASTNode): node is AndNode;
|
|
98
100
|
export declare function isOrNode(node: ASTNode): node is OrNode;
|
|
99
101
|
export declare function isSequenceNode(node: ASTNode): node is SequenceNode;
|
|
100
|
-
export declare function isLiteralNode(node: ASTNode): node is LiteralNode;
|
|
101
|
-
export declare function isVariableNode(node: ASTNode): node is VariableNode;
|
|
102
|
-
export declare function isSubstitutionNode(node: ASTNode): node is SubstitutionNode;
|
|
103
|
-
export declare function isGlobNode(node: ASTNode): node is GlobNode;
|
|
104
|
-
export declare function isConcatNode(node: ASTNode): node is ConcatNode;
|
|
105
102
|
export declare function isIfNode(node: ASTNode): node is IfNode;
|
|
106
103
|
export declare function isForNode(node: ASTNode): node is ForNode;
|
|
107
104
|
export declare function isWhileNode(node: ASTNode): node is WhileNode;
|
|
108
105
|
export declare function isUntilNode(node: ASTNode): node is UntilNode;
|
|
109
106
|
export declare function isCaseNode(node: ASTNode): node is CaseNode;
|
|
110
|
-
export declare function isArithmeticNode(node: ASTNode): node is ArithmeticNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Parser, parse } from "./parser.ts";
|
|
2
|
-
export type { ASTNode, Redirect, RedirectMode, CommandNode, PipelineNode, AndNode, OrNode, SequenceNode,
|
|
3
|
-
export { isCommandNode, isPipelineNode, isAndNode, isOrNode, isSequenceNode,
|
|
2
|
+
export type { ASTNode, Redirect, RedirectMode, CommandNode, PipelineNode, AndNode, OrNode, SequenceNode, WordNode, WordPart, TextPart, VariablePart, SubstitutionPart, ArithmeticPart, IfNode, ForNode, WhileNode, UntilNode, CaseNode, CaseClause, } from "./ast.ts";
|
|
3
|
+
export { isWordNode, isCommandNode, isPipelineNode, isAndNode, isOrNode, isSequenceNode, isIfNode, isForNode, isWhileNode, isUntilNode, isCaseNode, } from "./ast.ts";
|
|
@@ -19,12 +19,15 @@ export declare class Parser {
|
|
|
19
19
|
private parseCasePattern;
|
|
20
20
|
private parseCaseBody;
|
|
21
21
|
private parseCompoundList;
|
|
22
|
+
private createNoopCommand;
|
|
23
|
+
private createTextWord;
|
|
22
24
|
private isCompoundListTerminator;
|
|
23
25
|
private checkKeyword;
|
|
24
26
|
private expectKeyword;
|
|
25
27
|
private parseCommand;
|
|
26
28
|
private parseWordArg;
|
|
27
|
-
private
|
|
29
|
+
private tokenToWord;
|
|
30
|
+
private tokenToWordParts;
|
|
28
31
|
private parseDoubleQuoteParts;
|
|
29
32
|
private parseHeredocContent;
|
|
30
33
|
private parseRedirect;
|
package/package.json
CHANGED