-
Notifications
You must be signed in to change notification settings - Fork 1
/
ast.d.ts
198 lines (168 loc) · 3.7 KB
/
ast.d.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
type DataType = "bool" | "string" | "int" | "object" | "array";
type BinaryOperator = "&&" | "||" | "??";
type EqualityOperator = "==" | "!=";
type RelationalOperator = ">" | ">=" | "<" | "<=";
type AdditiveOperator = "+" | "-";
type MultiplicativeOperator = "*" | "|" | "%";
type UnaryOperator = "!" | "-" | "+";
type LeftRightOperator =
| BinaryOperator
| EqualityOperator
| RelationalOperator
| AdditiveOperator
| MultiplicativeOperator
| UnaryOperator;
interface BinaryExpression {
type: "BinaryExpression";
operator: LeftRightOperator;
left: Expression;
right: Expression;
}
interface IndexedProperty {
type: "IndexedProperty";
property: NumberLiteral;
}
interface DotIdentifierProperty {
type: "DotIdentifierProperty";
property: Identifier;
}
interface FunctionCallProperty {
type: "FunctionCallProperty";
property: FunctionCall;
}
interface ColonProperty {
type: "ColonProperty";
property: Identifier;
}
interface MemberExpression {
type: "MemberExpression";
object: Expression;
property:
| IndexedProperty
| DotIdentifierProperty
| FunctionCallProperty
| ColonProperty;
}
type Expression = BinaryExpression | PrimaryExpression | MemberExpression;
interface TargetScopeDeclaration {
type: "TargetScopeDeclaration";
scope: "subscription" | "tenant" | "managementGroup" | "resourceGroup";
}
interface ImportDeclaration {
type: "ImportDeclaration";
name: string;
// decorators: Decorator[];
// dataType: DataType;
// expression: Expression;
}
interface ParameterDeclaration {
type: "ParameterDeclaration";
name: string;
decorators: Decorator[];
dataType: DataType;
expression: Expression;
}
interface VariableDeclaration {
type: "VariableDeclaration";
name: string;
decorators: Decorator[];
expression: Expression;
}
interface ResourceDeclaration {
type: "ResourceDeclaration";
name: string;
decorators: Decorator[];
module: StringLiteral;
existing: "existing";
expression: BObject;
}
interface ModuleDeclaration {
type: "ModuleDeclaration";
decorators: Decorator[];
name: string;
module: StringLiteral;
expression: Expression;
}
interface OutputDeclaration {
type: "OutputDeclaration";
id: string;
decorators: Decorator[];
dataType: DataType;
expression: Expression;
}
interface Decorator {
type: Decorator;
expression: FunctionCall; // OR mem expr . functioncall
}
interface Identifier {
type: "Identifier";
name: string;
}
interface TemplateLiteral {
type: "TemplateLiteral";
expressions: Expression[];
quasis: StringLiteral[];
}
interface StringLiteral {
type: "String";
value: string;
}
interface NumberLiteral {
type: "Number";
value: number;
raw: string;
}
interface BooleanLiteral {
type: "Boolean";
value: boolean;
raw: string;
}
interface NullLiteral {
type: "Null";
value: null;
raw: string;
}
type LiteralValue = BooleanLiteral | NullLiteral | NumberLiteral;
interface BArray {
type: "ArrayExpression";
elements: Expression[];
}
interface BObjectProperty {
key: Identifier | StringLiteral | TemplateLiteral;
value: Expression;
}
interface BObject {
type: "Object";
properties: BObjectProperty[];
}
interface FunctionCall {
type: "FunctionCall";
name: string;
args?: Expression[];
}
type Statement =
| ParameterDeclaration
| VariableDeclaration
| ImportDeclaration
| ModuleDeclaration
| OutputDeclaration
| ResourceDeclaration
| TargetScopeDeclaration;
type PrimaryExpression =
| StringLiteral
| TemplateLiteral
| BArray
| BObject
| FunctionCall
| LiteralValue
| Identifier
| TemplateElement;
interface TemplateElement {
type: "TemplateElement";
value: string;
tail: boolean;
}
interface AST {
type: "Bicep";
body: Statement[];
}