-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.yaml
More file actions
509 lines (458 loc) · 14.2 KB
/
lambda.yaml
File metadata and controls
509 lines (458 loc) · 14.2 KB
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
#
# CEKF - VM supporting amb
# Copyright (C) 2022-2024 Bill Hails
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
config:
name: lambda
description: Plain lambda structures generated by lambda conversion.
parserInfo: true
includes:
- utils.h
limited_includes:
- bigint.h
- tc.h
- tc_debug.h
- minlam_functions.h
structs:
LamLam:
meta:
brief: A lambda expression
description: >-
If isLazy is true,
all arguments are expected to be thunked (lazy).
data:
args: SymbolList
exp: LamExp
isLazy: bool=false
LamPrimApp:
meta:
brief: A primitive operation application
data:
type: LamPrimOp
exp1: LamExp
exp2: LamExp
replacement: LamExp=NULL
LamSequence:
meta:
brief: A sequence of lambda expressions e.g. (begin ...)
data:
exp: LamExp
next: LamSequence
LamArgs:
meta:
brief: Actual arguments to a LamApply.
data:
exp: LamExp
next: LamArgs
LamApply:
meta:
brief: A function application.
data:
function: LamExp
args: LamArgs
isBuiltin: bool=false
LamLookUp:
meta:
brief: A lookUp in a nameSpace
description: >-
Represents the evaluation of an expression
in a different nameSpace.
data:
nsId: int
nsSymbol: HashSymbol
exp: LamExp
LamLookUpSymbol:
meta:
brief: A lookUp of a symbol (constructor) in a nameSpace.
data:
nsId: int
nsSymbol: HashSymbol
symbol: HashSymbol
LamConstant:
meta:
brief: A constant type constructor with no arguments.
data:
name: HashSymbol # the name of the constructor
tag: int # the tag of the constructor
LamConstruct:
meta:
brief: A constructor application
data:
name: HashSymbol # the name of the constructor
tag: int # the tag of the constructor
args: LamArgs # the remaining arguments to make-vec
LamDeconstruct:
meta:
brief: A deconstruction of a constructor
description: >-
Used to extract fields from a constructed value.
data:
name: HashSymbol # name of the constructor being deconstructed
nsId: int # nameSpace of the constructor being deconstructed
vec: int # offset of the field in the vector
exp: LamExp # expression being deconstructed
LamTupleIndex:
meta:
brief: An index into a tuple
data:
vec: int # offset of the field in the untagged tuple vector
size: int # size of the tuple
exp: LamExp # expression being accessed
LamMakeVec:
meta:
brief: A vector constructor
description: >-
This structure represents the internal construction of a
type instance (represented as a vector) from a list of arguments.
data:
nArgs: int
args: LamArgs
LamIff:
meta:
brief: An if-then-else expression
data:
condition: LamExp
consequent: LamExp
alternative: LamExp
LamCond:
meta:
brief: A conditional expression with multiple cases.
description: >-
Used internally by the generated TPMC code, the cases can
be either integers (matcing type constructors) or characters
(matching literal characters). The type of the value must match
the type of the cases.
data:
value: LamExp
cases: LamCondCases
LamIntCondCases:
meta:
brief: Integer conditional cases
description: >-
Used internally by the generated TPMC for matching type constructor ids.
data:
constant: MaybeBigInt
body: LamExp
next: LamIntCondCases
LamCharCondCases:
meta:
brief: Character conditional cases
description: >-
Holds a list of character conditional cases
generated by the TPMC for matching literal characters.
data:
constant: character
body: LamExp
next: LamCharCondCases
LamMatch:
meta:
brief: An integer matching expression
description: >-
Matches an integer index against multiple lists of cases. Each list
of cases is associated with a body expression to be executed on match.
Again this is generated by the TPMC.
data:
index: LamExp
cases: LamMatchList
LamMatchList:
meta:
brief: A list of pattern matching cases
description: >-
One set of cases in a LamMatch.
data:
matches: LamIntList
body: LamExp
next: LamMatchList
LamIntList:
meta:
brief: A list of integers
description: >-
The list of integers in a LamMatchList.
Includes a namespace id and name (why?).
data:
item: int
name: HashSymbol
nsId: int
next: LamIntList
LamLet:
meta:
brief: A let expression
data:
bindings: LamBindings
body: LamExp
LamLetRec:
meta:
brief: A letrec expression
data:
bindings: LamBindings
body: LamExp
LamLetStar:
meta:
brief: A let* expression
data:
bindings: LamBindings
body: LamExp
LamBindings:
meta:
brief: Bindings in a let or letrec expression
data:
var: HashSymbol
val: LamExp
next: LamBindings
LamContext:
meta:
brief: A context for lambda expressions
data:
frame: LamInfoTable
aliases: LamAliasTable
macros: SymbolSet
parent: LamContext
LamAmb:
meta:
brief: An amb expression
data:
left: LamExp
right: LamExp
LamPrint:
meta:
brief: A print expression
description: >-
This structure represents a print expression that outputs
the value of an expression to the console.
data:
exp: LamExp
printer: LamExp=NULL
LamTypeOf:
meta:
brief: A typeOf expression
data:
exp: LamExp
typeString: LamExp=NULL # assgned by the type checker
LamTypeDefs:
meta:
brief: Type definitions in a lambda expression
description: >-
This structure holds type definitions.
It is prepended to Each letrec and any
typeDefs in the letrec are hoisted into this section.
data:
typeDefs: LamTypeDefList
body: LamExp
LamTypeDefList:
meta:
brief: A list of type definitions
description: >-
contained by a LamTypeDefs structure.
data:
typeDef: LamTypeDef
next: LamTypeDefList
LamTypeDef:
meta:
brief: A single type definition
data:
type: LamTypeSig # re-use
constructors: LamTypeConstructorList
LamTypeConstructorList:
meta:
brief: A list of type constructors forming the body of a typedef.
data:
constructor: LamTypeConstructor
next: LamTypeConstructorList
LamTypeSig:
meta:
brief: A type signature
description: >-
This structure represents a type signature that includes the
name of the type and its argument type variables.
data:
name: HashSymbol
args: LamTypeSigArgs
LamTypeTags:
meta:
brief: Tags for a type constructor
description: >-
This structure holds tags that are associated with a type
in the type constructor info metadata.
data:
tag: HashSymbol
next: LamTypeTags
LamTypeSigArgs:
meta:
brief: Argument type variables for a type signature
data:
name: HashSymbol
next: LamTypeSigArgs
LamTypeConstructor:
meta:
brief: A type constructor as part of a typedef.
data:
name: HashSymbol
type: LamTypeSig
args: LamTypeConstructorArgs
LamTypeConstructorArgs:
meta:
brief: Formal arguments for a type constructor
data:
arg: LamTypeConstructorType
next: LamTypeConstructorArgs
LamTypeFunction:
meta:
brief: A type function as a formal argument to a type constructor
data:
name: LamLookUpOrSymbol
args: LamTypeConstructorArgs
LamTypeConstructorInfo:
meta:
brief: Information about a type constructor
data:
name: HashSymbol
nsId: int
type: LamTypeConstructor
tags: LamTypeTags
needsVec: bool # does this need to be a vector?
arity: int # number of arguments to this constructor
size: int # number of alternatives
index: int # index into list of alternatives
enums:
LamPrimOp:
meta:
brief: Primitive operations
data:
- ADD
- SUB
- MUL
- DIV
- MOD
- GCD
- LCM
- CANON
- POW
- EQ
- NE
- GT
- LT
- GE
- LE
- CMP
- VEC
unions:
LamExp:
meta:
brief: A lambda expression
data:
amb: LamAmb
apply: LamApply
args: LamArgs # so that ANF normalize can be uniformly typed
back: void_ptr
bigInteger: MaybeBigInt
bindings: LamBindings # so that ANF normalize can be uniformly typed
callCC: LamExp
character: character
cond: LamCond
constant: LamConstant
construct: LamConstruct
constructor: LamTypeConstructorInfo
deconstruct: LamDeconstruct
env: void_ptr
error: void_ptr
iff: LamIff
lam: LamLam
let: LamLet
letRec: LamLetRec
letStar: LamLetStar
lookUp: LamLookUp
makeTuple: LamArgs
makeVec: LamMakeVec
match: LamMatch
nameSpaces: LamNameSpaceArray
prim: LamPrimApp
print: LamPrint
sequence: LamSequence
stdint: int
tag: LamExp
tupleIndex: LamTupleIndex
typeDefs: LamTypeDefs
typeOf: LamTypeOf
var: HashSymbol
LamLookUpOrSymbol:
meta:
brief: A lookUp or symbol in a nameSpace
description: >-
Represents either a lookUp of a symbol in a
nameSpace or a symbol in the current nameSpace.
data:
symbol: HashSymbol
lookUp: LamLookUpSymbol
LamCondCases:
meta:
brief: Cases for a LamCond
data:
integers: LamIntCondCases
characters: LamCharCondCases
LamTypeConstructorType:
meta:
brief: A type constructor type
description: >-
Defines the different types of arguments that can
be passed to a type constructor.
data:
integer: void_ptr
character: void_ptr
var: HashSymbol
function: LamTypeFunction
tuple: LamTypeConstructorArgs
LamInfo:
meta:
brief: Information about a symbol
data:
typeConstructorInfo: LamTypeConstructorInfo
nameSpaceInfo: LamContext
nsId: int
hashes:
LamInfoTable:
meta:
brief: Map from symbols to information about them
description: >-
This table holds information about symbols in the current context.
data:
entries: LamInfo
LamAliasTable:
meta:
brief: Map from symbols to their types in the body of a type constructor.
data:
entries: LamTypeConstructorType
LamExpTable:
meta:
brief: Map from symbols to lambda expressions
description: >-
This table holds lambda expressions that are associated with
symbols in the current context, used for macro arguments where
the expressions are passed in unevaluated.
data:
entries: LamExp
arrays:
LamNameSpaceArray:
meta:
brief: A list of nameSpaces
description: >-
This array holds the bodies of nameSpaces that are currently
in scope. The ubiquitous `ns_id` is an index into this array.
data:
entries: LamExp
primitives: !include primitives.yaml
external:
- !include tc.yaml
- !include utils.yaml