Source file ast_generic_v1_t.ml

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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
(* Auto-generated from "ast_generic_v1.atd" *)
[@@@ocaml.warning "-27-32-33-35-39"]

type class_kind = [ `Class | `Interface | `Trait | `Object ]

type concat_string_kind = [
    `InterpolatedConcat
  | `SequenceConcat
  | `FString of string
  | `TaggedTemplateLiteral
]

type const_type = [ `Cbool | `Cint | `Cstr | `Cany ]

type container_operator = [ `Array | `List | `Set | `Dict | `Tuple ]

type function_kind = [
    `Function | `Method | `LambdaKind | `Arrow | `BlockCases
]

type incr_decr = [ `Incr | `Decr ]

type keyword_attribute = [
    `Static
  | `Volatile
  | `Extern
  | `Public
  | `Private
  | `Protected
  | `Abstract
  | `Final
  | `Override
  | `RecordClass
  | `AnnotationClass
  | `EnumClass
  | `SealedClass
  | `Var
  | `Let
  | `Mutable
  | `Const
  | `Optional
  | `NotNull
  | `Recursive
  | `MutuallyRecursive
  | `Generator
  | `Async
  | `Inline
  | `Ctor
  | `Dtor
  | `Getter
  | `Setter
  | `Unsafe
  | `DefaultImpl
  | `Lazy
  | `Throws
  | `Rethrows
  | `OtherKeyword of string
]

type operator = [
    `Plus | `Minus | `Mult | `Div | `Mod | `Pow | `FloorDiv | `MatMult | `LSL
  | `LSR | `ASR | `BitOr | `BitXor | `BitAnd | `BitNot | `BitClear | `And
  | `Or | `Xor | `Not | `Eq | `NotEq | `PhysEq | `NotPhysEq | `Lt | `LtE
  | `Gt | `GtE | `Cmp | `Concat | `Append | `RegexpMatch | `NotMatch | `Range
  | `RangeInclusive | `NotNullPostfix | `Length | `Elvis | `Nullish | `In
  | `NotIn | `Is | `NotIs | `Background | `Pipe
]

type prefix_postfix = [ `Prefix | `Postfix ]

type sid = int

type special = [
    `This
  | `Super
  | `Self
  | `Parent
  | `Eval
  | `Typeof
  | `Instanceof
  | `Sizeof
  | `Defined
  | `ConcatString of concat_string_kind
  | `EncodedString of string
  | `InterpolatedElement
  | `Spread
  | `HashSplat
  | `ForOf
  | `Op of operator
  | `IncrDecr of (incr_decr * prefix_postfix)
  | `Require
  | `OtherSpecial of string
]

type token_location = {
  str: string;
  charpos: int;
  line: int;
  column: int;
  filename: string
}

type token = [ `OriginTok of token_location | `FakeTok of string ]

type tok = token

type 'a bracket = (tok * 'a * tok)

type sc = tok

type variance = [ `Covariant | `Contravariant ]

type 'a wrap_ = ('a * tok)

type ident = string wrap_

type dotted_ident = ident list

type label = ident

type literal = [
    `Bool of bool wrap_
  | `Int of int option wrap_
  | `Float of float option wrap_
  | `Char of string wrap_
  | `String of string wrap_
  | `Regexp of (string wrap_ bracket * string wrap_ option)
  | `Atom of (tok * string wrap_)
  | `Unit of tok
  | `Null of tok
  | `Undefined of tok
  | `Imag of string wrap_
  | `Ratio of string wrap_
]

type module_name = [
    `DottedName of dotted_ident
  | `FileName of string wrap_
]

type resolved_name_kind = [
    `Global
  | `Local
  | `Param
  | `ImportedEntity of dotted_ident
  | `ImportedModule of module_name
  | `OtherResolvedNameKind of string
]

type resolved_name = (resolved_name_kind * sid)

type todo_kind = string wrap_

type xml_kind = [
    `XmlClassic of (tok * ident * tok * tok)
  | `XmlSingleton of (tok * ident * tok)
  | `XmlFragment of (tok * tok)
]

type alias = (ident * id_info)

and any = [
    `E of expr
  | `S of stmt
  | `T of type_
  | `P of pattern
  | `At of attribute
  | `Fld of field
  | `Ar of argument
  | `Pa of parameter
  | `Ta of type_argument
  | `Tp of type_parameter
  | `Ce of catch_exn
  | `Cs of case
  | `ForOrIfComp of for_or_if_comp
  | `En of entity
  | `I of ident
  | `Modn of module_name
  | `Di of dotted_ident
  | `Lbli of label_ident
  | `Str of string wrap_
  | `Tk of tok
  | `TodoK of todo_kind
  | `Anys of (any list)
]

and argument = [
    `Arg of expr
  | `ArgKwd of (ident * expr)
  | `ArgKwdOptional of (ident * expr)
  | `ArgType of type_
  | `OtherArg of (todo_kind * any list)
]

and arguments = argument list bracket

and attribute = [
    `KeywordAttr of keyword_attribute wrap_
  | `NamedAttr of (tok * name * arguments)
  | `OtherAttribute of (todo_kind * any list)
]

and case = [
    `Case of (tok * pattern)
  | `Default of tok
  | `CaseEqualExpr of (tok * expr)
  | `OtherCase of (todo_kind * any list)
]

and case_and_body = [ `CasesAndBody of (case list * stmt) ]

and catch = (tok * catch_exn * stmt)

and catch_exn = [
    `CatchPattern of pattern
  | `CatchParam of parameter_classic
  | `OtherCatch of (todo_kind * any list)
]

and class_definition = {
  ckind: class_kind wrap_;
  cextends: class_parent list;
  cimplements: type_ list;
  cmixins: type_ list;
  cparams: parameters;
  cbody: field list bracket
}

and class_parent = (type_ * arguments option)

and comprehension = (expr * for_or_if_comp list)

and condition = [ `Cond of expr | `OtherCond of (todo_kind * any list) ]

and definition = (entity * definition_kind)

and definition_kind = [
    `FuncDef of function_definition
  | `VarDef of variable_definition
  | `ClassDef of class_definition
  | `EnumEntryDef of enum_entry_definition
  | `TypeDef of type_definition
  | `ModuleDef of module_definition
  | `MacroDef of macro_definition
  | `Signature of type_
  | `UseOuterDecl of tok
  | `OtherDef of (todo_kind * any list)
]

and directive = [
    `ImportFrom of (tok * module_name * (ident * alias option) list)
  | `ImportAs of (tok * module_name * alias option)
  | `ImportAll of (tok * module_name * tok)
  | `Package of (tok * dotted_ident)
  | `PackageEnd of tok
  | `Pragma of (ident * any list)
  | `OtherDirective of (todo_kind * any list)
]

and entity = {
  name: entity_name;
  attrs: attribute list;
  tparams: type_parameters
}

and entity_name = [
    `EN of name
  | `EDynamic of expr
  | `EPattern of pattern
  | `OtherEntity of (todo_kind * any list)
]

and enum_entry_definition = {
  ee_args: arguments option;
  ee_body: field list bracket option
}

and expr = [
    `L of literal
  | `Container of (container_operator * expr list bracket)
  | `Comprehension of (container_operator * comprehension bracket)
  | `Record of field list bracket
  | `Constructor of (name * expr list bracket)
  | `N of name
  | `IdSpecial of special wrap_
  | `Call of (expr * arguments)
  | `New of (tok * type_ * arguments)
  | `Xml of xml
  | `Assign of (expr * tok * expr)
  | `AssignOp of (expr * operator wrap_ * expr)
  | `LetPattern of (pattern * expr)
  | `DotAccess of (expr * tok * field_name)
  | `ArrayAccess of (expr * expr bracket)
  | `SliceAccess
      of (expr * (expr option * expr option * expr option) bracket)
  | `Lambda of function_definition
  | `AnonClass of class_definition
  | `Conditional of (expr * expr * expr)
  | `Yield of (tok * expr option * bool)
  | `Await of (tok * expr)
  | `Cast of (type_ * expr)
  | `Seq of expr list
  | `Ref of (tok * expr)
  | `DeRef of (tok * expr)
  | `Ellipsis of tok
  | `ParenExpr of expr bracket
  | `StmtExpr of stmt
  | `OtherExpr of (todo_kind * any list)
]

and field = [ `F of stmt ]

and field_name = [ `FN of name | `FDynamic of expr ]

and finally = (tok * stmt)

and for_each = (pattern * tok * expr)

and for_header = [
    `ForClassic of (for_var_or_expr list * expr option * expr option)
  | `ForEach of for_each
  | `MultiForEach of multi_for_each list
  | `ForIn of (for_var_or_expr list * expr list)
]

and for_or_if_comp = [
    `CompFor of (tok * pattern * tok * expr)
  | `CompIf of (tok * expr)
]

and for_var_or_expr = [
    `ForInitVar of (entity * variable_definition)
  | `ForInitExpr of expr
]

and function_body = [
    `FBStmt of stmt
  | `FBExpr of expr
  | `FBDecl of sc
  | `FBNothing
]

and function_definition = {
  fkind: function_kind wrap_;
  fparams: parameters;
  frettype: type_ option;
  fbody: function_body
}

and id_info = {
  id_resolved: resolved_name option;
  id_type: type_ option;
  id_svalue: svalue option
}

and item = stmt

and label_ident = [
    `LNone
  | `LId of label
  | `LInt of int wrap_
  | `LDynamic of expr
]

and macro_definition = { macroparams: ident list; macrobody: any list }

and module_definition = { mbody: module_definition_kind }

and module_definition_kind = [
    `ModuleAlias of dotted_ident
  | `ModuleStruct of (dotted_ident option * item list)
  | `OtherModule of (todo_kind * any list)
]

and multi_for_each = [ `FE of for_each | `FECond of (for_each * tok * expr) ]

and name = [ `Id of (ident * id_info) | `IdQualified of qualified_info ]

and or_type_element = [
    `OrConstructor of (ident * type_ list)
  | `OrEnum of (ident * expr option)
  | `OrUnion of (ident * type_)
  | `OtherOr of (todo_kind * any list)
]

and parameter = [
    `ParamClassic of parameter_classic
  | `ParamPattern of pattern
  | `ParamRest of (tok * parameter_classic)
  | `ParamHashSplat of (tok * parameter_classic)
  | `OtherParam of (todo_kind * any list)
]

and parameter_classic = {
  pname: ident option;
  ptype: type_ option;
  pdefault: expr option;
  pattrs: attribute list;
  pinfo: id_info
}

and parameters = parameter list

and pattern = [
    `PatLiteral of literal
  | `PatConstructor of (name * pattern list)
  | `PatRecord of (dotted_ident * pattern) list bracket
  | `PatId of (ident * id_info)
  | `PatTuple of pattern list bracket
  | `PatList of pattern list bracket
  | `PatKeyVal of (pattern * pattern)
  | `PatUnderscore of tok
  | `PatDisj of (pattern * pattern)
  | `PatTyped of (pattern * type_)
  | `PatWhen of (pattern * expr)
  | `PatAs of (pattern * (ident * id_info))
  | `PatType of type_
  | `OtherPat of (todo_kind * any list)
]

and qualified_info = {
  name_last: (ident * type_arguments option);
  name_middle: qualifier option;
  name_top: tok option;
  name_info: id_info
}

and qualifier = [
    `QDots of (ident * type_arguments option) list
  | `QExpr of (expr * tok)
]

and stmt = [
    `ExprStmt of (expr * sc)
  | `Block of stmt list bracket
  | `If of (tok * condition * stmt * stmt option)
  | `While of (tok * condition * stmt)
  | `Return of (tok * expr option * sc)
  | `DoWhile of (tok * stmt * expr)
  | `For of (tok * for_header * stmt)
  | `Switch of (tok * condition option * case_and_body list)
  | `Continue of (tok * label_ident * sc)
  | `Break of (tok * label_ident * sc)
  | `Label of (label * stmt)
  | `Goto of (tok * label)
  | `Throw of (tok * expr * sc)
  | `Try of (tok * stmt * catch list * finally option)
  | `WithUsingResource of (tok * stmt list * stmt)
  | `Assert of (tok * arguments * sc)
  | `DefStmt of definition
  | `DirectiveStmt of directive
  | `OtherStmt of (todo_kind * any list)
]

and svalue = [
    `Lit of literal
  | `Cst of const_type
  | `Sym of expr
  | `NotCst
]

and type_ = [
    `TyN of name
  | `TyApply of (type_ * type_arguments)
  | `TyFun of (parameter list * type_)
  | `TyArray of (expr option bracket * type_)
  | `TyTuple of type_ list bracket
  | `TyVar of ident
  | `TyAny of tok
  | `TyPointer of (tok * type_)
  | `TyRef of (tok * type_)
  | `TyQuestion of (type_ * tok)
  | `TyRest of (tok * type_)
  | `TyAnd of (type_ * tok * type_)
  | `TyOr of (type_ * tok * type_)
  | `TyRecordAnon of (class_kind wrap_ * field list bracket)
  | `TyExpr of expr
  | `OtherType of (todo_kind * any list)
]

and type_argument = [
    `TA of type_
  | `TAWildcard of (tok * (bool wrap_ * type_) option)
  | `TAExpr of expr
  | `OtherTypeArg of (todo_kind * any list)
]

and type_arguments = type_argument list bracket

and type_definition = { tbody: type_definition_kind }

and type_definition_kind = [
    `OrType of or_type_element list
  | `AndType of field list bracket
  | `AliasType of type_
  | `NewType of type_
  | `AbstractType of tok
  | `Exception of (ident * type_ list)
  | `OtherTypeKind of (todo_kind * any list)
]

and type_parameter = [
    `TP of type_parameter_classic
  | `OtherTypeParam of (todo_kind * any list)
]

and type_parameter_classic = {
  tp_id: ident;
  tp_attrs: attribute list;
  tp_bounds: type_ list;
  tp_default: type_ option;
  tp_variance: variance wrap_ option
}

and type_parameters = type_parameter list

and variable_definition = { vinit: expr option; vtype: type_ option }

and xml = {
  xml_kind: xml_kind;
  xml_attrs: xml_attribute list;
  xml_body: xml_body list
}

and xml_attr_value = expr

and xml_attribute = [
    `XmlAttr of (ident * tok * xml_attr_value)
  | `XmlAttrExpr of expr bracket
]

and xml_body = [
    `XmlText of string wrap_
  | `XmlExpr of expr option bracket
  | `XmlXml of xml
]

type program = item list