blob: f1a451383ff91763dc5c0f0ad6daa657f473cfc2 (
plain)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
import {DocComment} from ast;
// == Modules ==
struct RustModule {
field name: List[RustIdentifier];
field items: List[RustItem];
}
// == Items ==
sum RustItem {
variant RustEnum;
variant RustFunction;
variant RustInherentImpl;
variant RustStructStruct;
variant RustTraitImpl;
}
// === Functions ===
struct RustFunction {
field visibility: Option[RustVisibility];
field name: RustIdentifier;
field params: List[RustFunctionParam];
field returnType: Option[RustType];
field body: Option[RustBlockExpression];
}
struct RustFunctionParam {
field name: RustIdentifier;
field type: RustType;
}
// === Structs ===
struct RustStructStruct {
field attributes: List[RustOuterAttribute];
field name: RustIdentifier;
field fields: List[RustStructField];
field docComment: DocComment;
}
struct RustStructField {
field name: RustIdentifier;
field type: RustType;
}
struct RustTupleField {
field type: RustType;
}
// === Enumerations ===
struct RustEnum {
field attributes: List[RustOuterAttribute];
field name: RustIdentifier;
field variants: List[RustEnumVariant];
field docComment: DocComment;
}
struct RustEnumVariant {
field name: RustIdentifier;
field fields: RustEnumVariantFields;
}
sum RustEnumVariantFields {
variant RustEnumVariantNoFields;
variant RustEnumVariantTuple;
}
struct RustEnumVariantNoFields {
}
struct RustEnumVariantTuple {
field fields: List[RustTupleField];
}
// === Implementations ===
struct RustInherentImpl {
field type: RustType;
field items: List[RustAssociatedItem];
}
struct RustTraitImpl {
field implementedTrait: RustPath;
field type: RustType;
field items: List[RustAssociatedItem];
}
// === Associated items ===
sum RustAssociatedItem {
variant RustFunction;
}
// == Attributes ==
struct RustOuterAttribute {
field path: RustPath;
field input: Option[String];
}
// == Statements ==
sum RustStatement {
variant RustExpressionStatement;
variant RustLetStatement;
}
struct RustExpressionStatement {
field expression: RustExpression;
}
struct RustLetStatement {
field variableName: RustIdentifier;
field mutable: Bool;
field value: RustExpression;
}
// == Expressions ==
sum RustExpression {
variant RustArrayRepeatExpression;
variant RustBinaryExpression;
variant RustBlockExpression;
variant RustBoolLiteral;
variant RustCallExpression;
variant RustClosureExpression;
variant RustFieldExpression;
variant RustIfExpression;
variant RustIndexExpression;
variant RustIntegerLiteral;
variant RustIteratorLoopExpression;
variant RustMatchExpression;
variant RustPath;
variant RustPrefixExpression;
variant RustRangeExpr;
variant RustStringLiteral;
variant RustStructExpression;
variant RustTryPropagationExpression;
variant RustTupleExpression;
variant RustTypeCastExpression;
variant RustVecRepeatExpression;
}
sum RustLiteralExpression {
variant RustBoolLiteral;
variant RustIntegerLiteral;
}
struct RustArrayRepeatExpression {
field repeatOperand: RustExpression;
field lengthOperand: RustExpression;
}
struct RustBinaryExpression {
field operator: RustBinaryOperator;
field left: RustExpression;
field right: RustExpression;
}
enum RustBinaryOperator {
variant add;
variant equal;
variant lessThan;
variant notEqual;
}
struct RustBlockExpression {
field statements: List[RustStatement];
field finalOperand: Option[RustExpression];
}
struct RustBoolLiteral {
field value: Bool;
}
struct RustCallExpression {
field function: RustExpression;
field args: List[RustExpression];
}
struct RustClosureExpression {
field params: List[RustPattern];
field body: RustExpression;
}
struct RustFieldExpression {
field containerOperand: RustExpression;
field fieldName: RustIdentifier;
}
struct RustIfExpression {
field condition: RustExpression;
field ifTrue: RustBlockExpression;
field ifFalse: RustBlockExpression;
}
struct RustIndexExpression {
field indexed: RustExpression;
field index: RustExpression;
}
struct RustIntegerLiteral {
field value: Int64;
field type: Option[RustIdentifier];
}
struct RustIteratorLoopExpression {
field pattern: RustPattern;
field elements: RustExpression;
field body: RustBlockExpression;
}
struct RustMatchExpression {
field scrutinee: RustExpression;
field arms: List[RustMatchArm];
}
struct RustMatchArm {
field pattern: RustPattern;
field body: RustExpression;
}
struct RustPrefixExpression {
field operator: RustPrefixOperator;
field operand: RustExpression;
}
enum RustPrefixOperator {
variant borrow;
variant borrowMutable;
variant dereference;
}
struct RustRangeExpr {
field start: RustExpression;
field end: RustExpression;
}
struct RustStringLiteral {
field value: String;
}
struct RustStructExpression {
field structPath: RustPath;
field fieldValues: List[RustStructExprField];
}
struct RustStructExprField {
field name: RustIdentifier;
field value: RustExpression;
}
struct RustTryPropagationExpression {
field operand: RustExpression;
}
struct RustTupleExpression {
field elements: List[RustExpression];
}
struct RustTypeCastExpression {
field left: RustExpression;
field right: RustType;
}
struct RustVecRepeatExpression {
field repeatOperand: RustExpression;
field lengthOperand: RustExpression;
}
// == Patterns ==
sum RustPattern {
variant RustIdentifierPattern;
variant RustLiteralPattern;
variant RustPathPattern;
variant RustTupleStructPattern;
variant RustWildcardPattern;
}
struct RustIdentifierPattern {
field variableName: RustIdentifier;
}
struct RustLiteralPattern {
field literal: RustLiteralExpression;
}
struct RustPathPattern {
field path: RustPath;
}
struct RustTupleStructPattern {
field constructor: RustPath;
field items: List[RustPattern];
}
struct RustWildcardPattern {}
// == Types ==
sum RustType {
variant RustImplTraitType;
variant RustMutableReferenceType;
variant RustPath;
variant RustSharedReferenceType;
variant RustTraitObjectType;
variant RustTupleType;
}
struct RustImplTraitType {
field trait: RustPath;
}
struct RustMutableReferenceType {
field referencedType: RustType;
}
struct RustSharedReferenceType {
field referencedType: RustType;
}
struct RustTraitObjectType {
field bounds: List[RustPath];
}
struct RustTupleType {
field elementTypes: List[RustType];
}
// == Paths ==
struct RustPath {
field segments: List[RustPathSegment];
}
struct RustPathSegment {
field pathIdentSegment: RustPathIdentSegment;
field args: Option[List[RustType]];
}
sum RustPathIdentSegment {
variant RustPathIdentSegmentCrate;
variant RustPathIdentSegmentGlobal;
variant RustPathIdentSegmentIdentifier;
variant RustPathIdentSegmentSelfType;
}
struct RustPathIdentSegmentCrate {
}
struct RustPathIdentSegmentGlobal {
}
struct RustPathIdentSegmentIdentifier {
field name: RustIdentifier;
}
struct RustPathIdentSegmentSelfType {
}
// == Visibility ==
enum RustVisibility {
variant pub;
}
// == Identifiers ==
struct RustIdentifier {
field value: String;
}
|