blob: 3c7383dd1d61f614feae495a9b997260b089e611 (
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
|
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
(.require
[library
[lux (.except)
[control
["<>" parser]]
[data
["[0]" binary
["_" \\format (.only Format)]
["<[1]>" \\parser (.only Parser)]]]
[meta
["[0]" version]]]]
["[0]" /
[analysis
["[0]" module]]
[///
[meta
[archive
["[0]" signature]
["[0]" key (.only Key)]]]]])
... TODO: Remove #module_hash, #imports & #module_state ASAP.
... TODO: Not just from this parser, but from the lux.Module type.
(def .public format
(Format .Module)
(let [definition (is (Format Definition)
(all _.and _.type _.any))
alias (is (Format Alias)
(_.and _.text _.text))
global (is (Format Global)
(all _.or
definition
alias
definition))]
(all _.and
... #module_hash
_.nat
... #module_aliases
(_.list alias)
... #definitions
(_.list (_.and _.text (_.and _.bit global)))
... #imports
(_.list _.text)
... #module_state
_.any)))
(def .public parser
(Parser .Module)
(let [definition (is (Parser Definition)
(all <>.and
<binary>.type
<binary>.any))
alias (is (Parser Alias)
(all <>.and
<binary>.text
<binary>.text))
global (is (Parser Global)
(all <binary>.or
definition
alias
definition))]
(all <>.and
... #module_hash
<binary>.nat
... #module_aliases
(<binary>.list alias)
... #definitions
(<binary>.list (<>.and <binary>.text (<>.and <binary>.bit global)))
... #imports
(<binary>.list <binary>.text)
... #module_state
(of <>.monad in {.#Cached}))))
(def .public key
(Key .Module)
(key.key [signature.#name (symbol ..compiler)
signature.#version version.latest]
(module.empty 0)))
|