-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathprelude.lkt
524 lines (415 loc) · 8.84 KB
/
prelude.lkt
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
# In this file, the RootNode__ type designates the root node type from the
# Langkit spec importing this prelude. See the ``Decl`` environment spec for
# more details.
|" Trait implicitly implemented by all types
generic[T]
trait BasicTrait {
@builtin
@property
fun is_null(): Bool
@builtin
@property
fun singleton(): Array[T]
@builtin
generic[U]
fun do(do_fn: (T)->U, default_val: U = null[U]): U
@builtin
@property
fun as_entity(): Entity[T]
@builtin
@property
fun as_bare_entity(): Entity[T]
@builtin
fun to_builder(): NodeBuilder[T]
}
@builtin
struct Int {
@builtin
fun as_big_int(): BigInt
}
@builtin
struct BigInt {
@builtin
fun as_int(): Int
}
@builtin
struct Symbol {
@builtin
fun image(): String
}
@builtin
struct Regexp {
}
@builtin
@open
enum Bool {
case false, true
}
@builtin
trait Sized {
@builtin
fun length(): Int
}
@builtin
generic[T]
trait Indexable {
@builtin
fun __call__(index: Int): T
}
@builtin
generic[T]
trait Iterable {
@builtin
generic[U]
fun map(map_fn: (T)->U): Array[U]
@builtin
generic[U]
fun imap(map_fn: (T, Int)->U): Array[U]
@builtin
generic[U]
fun mapcat(map_fn: (T)->Array[U]): Array[U]
@builtin
generic[U]
fun imapcat(map_fn: (T, Int)->Array[U]): Array[U]
@builtin
fun filter(filter_fn: (T)->Bool): Array[T]
@builtin
fun ifilter(filter_fn: (T, Int)->Bool): Array[T]
@builtin
generic[U]
fun filtermap(map_fn: (T)->U, filter_fn: (T)->Bool): Array[U]
@builtin
generic[U]
fun ifiltermap(map_fn: (T, Int)->U, filter_fn: (T, Int)->Bool): Array[U]
@builtin
fun find(filter_fn: (T)->Bool): T
@builtin
fun take_while(pred_fn: (T)->Bool): Array[T]
@builtin
fun itake_while(pred_fn: (T, Int)->Bool): Array[T]
@builtin
fun empty(): Bool
@builtin
fun contains(elt: T): Bool
@builtin
fun all(logic_fn: (T)->Bool): Bool
@builtin
fun iall(logic_fn: (T, Int)->Bool): Bool
@builtin
fun any(logic_fn: (T)->Bool): Bool
@builtin
fun iany(logic_fn: (T, Int)->Bool): Bool
@builtin
fun logic_all(logic_fn: (T)->Equation): Equation
@builtin
fun ilogic_all(logic_fn: (T, Int)->Equation): Equation
@builtin
fun logic_any(logic_fn: (T)->Equation): Equation
@builtin
fun ilogic_any(logic_fn: (T, Int)->Equation): Equation
}
@builtin
generic[T]
struct Array implements Sized, Indexable[T], Iterable[T] {
@builtin
fun to_iterator(): Iterator[T]
@builtin
fun unique(): Array[T]
@builtin
fun env_group(with_md: Metadata = null[Metadata]): LexicalEnv
}
@builtin
generic[T]
struct Iterator {
}
@builtin
generic[T]
trait Node {
@builtin
@property
fun parent(): T
@builtin
@property
fun node_env(): LexicalEnv
@builtin
@property
fun children_env(): LexicalEnv
@builtin
@property
fun unit(): AnalysisUnit
@builtin
fun parents(with_self: Bool = true): Array[T]
@builtin
@property
fun children(): Array[T]
@builtin
@property
fun text(): String
@builtin
fun ple_root(): RootNode__
@builtin
fun can_reach(from_node: RootNode__): Bool
@builtin
fun token_start(): Token
@builtin
fun token_end(): Token
@builtin
@property
fun child_index(): Int
@builtin
@property
fun previous_sibling(): Entity[RootNode__]
@builtin
@property
fun next_sibling(): Entity[RootNode__]
@builtin
fun is_ghost(): Bool
@builtin
fun full_sloc_image(): String
}
@builtin
generic[class T]
class ASTList: RootNode__ implements Sized, Indexable[T], Iterable[T] {
@builtin
fun as_array(): Array[T]
}
@builtin
generic[class T]
class NodeBuilder {
@builtin
fun build(parent: RootNode__): T
}
@builtin
struct Char {
}
@builtin
struct String implements Sized, Indexable[Char], Iterable[Char] {
@builtin
@property
fun to_symbol(): Symbol
@builtin
fun join(strings: Array[String]): String
}
@builtin
struct LogicVar {
@builtin
fun get_value(): Entity[RootNode__]
}
@builtin
struct LogicContext {
ref_node: Entity[RootNode__]
decl_node: Entity[RootNode__]
}
dynvar logic_context: LogicContext
@builtin
struct Equation {
@builtin
@property
fun solve(): Bool
@builtin
@property
fun solve_with_diagnostics(): SolverResult
}
@builtin
struct PropertyError {
exception_message: String = "PropertyError exception"
}
@builtin
struct PreconditionFailure {
exception_message: String = "PreconditionFailure exception"
}
@builtin
@ignore_constructor_arg
struct RefCategories {
}
@builtin
enum LookupKind {
case recursive, flat, minimal
}
@builtin
struct LexicalEnv {
@builtin
fun get(
symbol: Symbol,
from: RootNode__ = null[RootNode__],
lookup: LookupKind = LookupKind.recursive,
categories: RefCategories = null[RefCategories]
): Array[Entity[RootNode__]]
@builtin
fun get_first(
symbol: Symbol,
from: RootNode__ = null[RootNode__],
lookup: LookupKind = LookupKind.recursive,
categories: RefCategories = null[RefCategories]
): Entity[RootNode__]
@builtin
@property
fun env_node(): RootNode__
@builtin
@property
fun env_orphan(): LexicalEnv
@builtin
@property
fun env_parent(): LexicalEnv
@builtin
fun is_visible_from(base_env: LexicalEnv): Bool
@builtin
fun shed_rebindings(info: EntityInfo): EntityInfo
@builtin
fun rebind_env(r: EnvRebindings): LexicalEnv
}
@builtin
enum DesignatedEnvKind {
case none, current_env, named_env, direct_env
}
@builtin
struct DesignatedEnv {
kind: DesignatedEnvKind
env_name: Symbol
direct_env: LexicalEnv
}
@builtin
enum AnalysisUnitKind {
case unit_specification, unit_body
}
@builtin
trait AnalysisUnit {
@builtin
@property
fun root(): RootNode__
@builtin
fun is_referenced_from(unit: AnalysisUnit): Bool
}
@builtin
struct EnvRebindings {
old_env: LexicalEnv
new_env: LexicalEnv
get_parent: EnvRebindings
@builtin
fun append_rebinding(
old_env: LexicalEnv,
new_env: LexicalEnv
): EnvRebindings
@builtin
fun concat_rebindings(rhs: EnvRebindings): EnvRebindings
}
@builtin
struct EnvAssoc {
key: Symbol
value: RootNode__
dest_env: DesignatedEnv
metadata: Metadata
}
@builtin
struct InnerEnvAssoc {
key: Symbol
value: RootNode__
rebindings: EnvRebindings = null[EnvRebindings]
metadata: Metadata = null[Metadata]
}
@builtin
@open
enum RefKind {
case transitive, prioritary, normal
}
@builtin
struct EnvAction {
}
@builtin
fun set_initial_env(env: DesignatedEnv): EnvAction
@builtin
fun add_env(
no_parent: Bool = false,
transitive_parent: Bool = false,
names: Array[Symbol] = null
): EnvAction
@builtin
fun add_single_to_env(mapping: EnvAssoc): EnvAction
@builtin
fun add_all_to_env(mappings: Array[EnvAssoc]): EnvAction
@builtin
fun add_to_env_kv(
key: Symbol,
value: RootNode__,
dest_env: DesignatedEnv = null,
metadata: Metadata = null
): EnvAction
@builtin
generic[T]
fun do(expr: T): EnvAction
@builtin
fun handle_children(): EnvAction
@builtin
fun reference(
nodes: Array[RootNode__],
through: ()->LexicalEnv,
kind: RefKind = normal,
dest_env: LexicalEnv = null,
cond: Bool = true,
category: String = null,
shed_corresponding_rebindings: Bool = false
): EnvAction
@builtin
struct EntityInfo {
|" The metadata associated to the AST node
md: Metadata
rebindings: EnvRebindings
from_rebound: Bool
}
@builtin
generic[N]
struct Entity {
node: N
info: EntityInfo
}
@builtin
trait TokenNode {
@builtin
@property
fun symbol(): Symbol
}
@builtin
struct SolverDiagnostic {
template: String
args: Array[Entity[RootNode__]]
location: RootNode__
contexts: Array[LogicContext]
round: Int
}
@builtin
struct SolverResult {
success: Bool
diagnostics: Array[SolverDiagnostic] = null[Array[SolverDiagnostic]]
}
@builtin
struct Token {
}
@builtin
struct SourceLocation {
}
struct __internal {
|" Placeholder type when the langkit specification does not have a type
|" annotated with ``@metadata``.
|"
|" This is hidden in its own scope and later has a reference in the
|" global lexical environemnt so that if no type is designated as metadata,
|" this types serves as fallback.
@metadata
struct __EmptyMetadata {
}
}
@builtin
trait ErrorNode {
}
@builtin
struct Address {
}
@builtin
fun dynamic_lexical_env(
assocs_getter: ()->Array[InnerEnvAssoc],
assoc_resolver: ()->Entity[RootNode__] = null,
transitive_parent: Bool = true
): LexicalEnv
@builtin
fun domain(var: LogicVar, values: Array[Entity[RootNode__]]): Equation
dynvar error_location: RootNode__