-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.ts
122 lines (104 loc) · 2.03 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//deno-lint-ignore-file no-explicit-any
import { Operation, YAMLParsedNode } from "./deps.ts";
export interface PSEnv {
eval(value: PSValue, scope?: PSMap): Operation<PSValue>;
call(fn: PSFn, arg: PSValue, options?: PSMap): Operation<PSValue>;
}
export interface PSModule {
location: string;
source: PSValue;
value: PSValue;
imports: {
module: PSModule;
bindings: {
name: string;
alias?: string;
all: boolean;
}[];
}[];
}
export type PSValue =
| PSNumber
| PSBoolean
| PSString
| PSTemplate
| PSRef
| PSList
| PSMap
| PSFn
| PSFnCall
| PSExternal;
export type PSMapKey =
| PSNumber
| PSBoolean
| PSString
| PSRef;
export type PSMapEntry = [PSMapKey, PSValue];
export type PSLiteral<T extends PSValue = PSValue> = T & {
node: YAMLParsedNode;
};
export interface PSNumber {
type: "number";
value: number;
}
export interface PSBoolean {
type: "boolean";
value: boolean;
}
export interface PSString {
type: "string";
value: string;
quote?: "single" | "double";
}
export interface PSTemplate {
type: "template";
value: PSString;
expressions: { expression: PSValue; range: [number, number] }[];
}
export interface PSRef {
type: "ref";
value: PSString;
key: string;
path: string[];
}
export interface PSList {
type: "list";
value: PSValue[];
}
export interface PSMap {
type: "map";
value: Pick<Map<PSMapKey, PSValue>, "get" | "set" | "entries">;
}
export interface PSExternal {
type: "external";
value: any;
view?(path: string[], value: any): PSValue | void;
}
export interface PSFn {
type: "fn";
param: { name: string };
value: {
type: "native";
call(cxt: PSFnCallContext): Operation<PSValue>;
} | {
type: "platformscript";
head: PSString;
body: PSValue;
};
}
export interface PSFnCall {
type: "fncall";
value: PSRef | PSFn;
arg: PSValue;
rest: PSMap;
source: PSMap;
}
export interface PSFnCallContext {
fn: PSFn;
arg: PSValue;
rest: PSMap;
env: PSEnv;
}
export interface PSFnParam {
name: string;
}