blob: 5bb42e5338970450ebc24ed2b3b8b2585c7c5253 (
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
|
(.module:
[library
[lux #*
[control
["<>" parser
["<b>" binary (#+ Parser)]]]
[data
[format
["_" binary (#+ Writer)]]]]]
["." / #_
["#." version]
[phase
[analysis
["." module]]]
[///
[meta
[archive
["." signature]
["." key (#+ Key)]]]]])
... TODO: Remove #module_hash, #imports & #module_state ASAP.
... TODO: Not just from this parser, but from the lux.Module type.
(def: .public writer
(Writer .Module)
(let [definition (: (Writer Definition)
($_ _.and _.bit _.type _.code _.any))
labels (: (Writer [Text (List Text)])
(_.and _.text (_.list _.text)))
global_type (: (Writer [Bit Type (Either [Text (List Text)]
[Text (List Text)])])
($_ _.and _.bit _.type (_.or labels labels)))
global_label (: (Writer .Label)
($_ _.and _.bit _.type (_.list _.text) _.nat))
name (: (Writer Name)
(_.and _.text _.text))
alias (: (Writer Alias)
(_.and _.text _.text))
global (: (Writer Global)
(_.or/5 definition
global_type
global_label
global_label
alias))]
($_ _.and
... #module_hash
_.nat
... #module_aliases
(_.list alias)
... #definitions
(_.list (_.and _.text global))
... #imports
(_.list _.text)
... #module_annotations
(_.maybe _.code)
... #module_state
_.any)))
(def: .public parser
(Parser .Module)
(let [definition (: (Parser Definition)
($_ <>.and <b>.bit <b>.type <b>.code <b>.any))
labels (: (Parser [Text (List Text)])
(<>.and <b>.text (<b>.list <b>.text)))
global_type (: (Parser [Bit Type (Either [Text (List Text)]
[Text (List Text)])])
($_ <>.and <b>.bit <b>.type (<b>.or labels labels)))
global_label (: (Parser .Label)
($_ <>.and <b>.bit <b>.type (<b>.list <b>.text) <b>.nat))
name (: (Parser Name)
(<>.and <b>.text <b>.text))
alias (: (Parser Alias)
(<>.and <b>.text <b>.text))
global (: (Parser Global)
(<b>.or/5 definition
global_type
global_label
global_label
alias))]
($_ <>.and
... #module_hash
<b>.nat
... #module_aliases
(<b>.list alias)
... #definitions
(<b>.list (<>.and <b>.text global))
... #imports
(<b>.list <b>.text)
... #module_annotations
(<b>.maybe <b>.code)
... #module_state
(\ <>.monad in #.Cached))))
(def: .public key
(Key .Module)
(key.key {#signature.name (name_of ..compiler)
#signature.version /version.version}
(module.empty 0)))
|