-
Notifications
You must be signed in to change notification settings - Fork 2
/
iota.ts
49 lines (45 loc) · 1.18 KB
/
iota.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
// The simplest lambda calculus based language. Too bad the advanced type
// checking breaks TSC.
// @ts-nocheck
import { Node } from "./lambda.js"
import * as Z from "./parsers/parser-5.js"
const Iota = new Node.Lambda(
"x",
// @ts-ignore
new Node.Application(
// @ts-ignore
new Node.Application(
// @ts-ignore
new Node.Name("x"),
// @ts-ignore
new Node.Lambda(
"x",
// @ts-ignore
new Node.Lambda(
"y",
// @ts-ignore
new Node.Lambda(
"z",
// @ts-ignore
new Node.Application(
// @ts-ignore
new Node.Application(new Node.Name("x"), new Node.Name("z")),
// @ts-ignore
new Node.Application(new Node.Name("y"), new Node.Name("z")),
),
),
),
),
),
),
// @ts-ignore
new Node.Lambda("x", new Node.Lambda("y", new Node.Name("x"))),
)
export const Script: Z.Parser<Node.Node> = Z.lazy(() =>
Z.any(
Z.text("1").value<Node.Node>(Iota),
Z.seq(Z.text("0"), Script, Script).map<Node.Node>(
([, left, right]) => new (Node.Application as any)(left, right),
),
),
)