blob: 6cc10a3c25a36cf04ce6a5243cc62ff8b318e2bf (
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
|
(.module:
[library
[lux "*"
[abstract
[equivalence {"+" Equivalence}]]]])
(implementation: .public equivalence
(Equivalence Location)
(def: (= reference subject)
(and ("lux text =" (value@ .#module reference) (value@ .#module subject))
("lux i64 =" (value@ .#line reference) (value@ .#line subject))
("lux i64 =" (value@ .#column reference) (value@ .#column subject)))))
(def: .public dummy
Location
[.#module ""
.#line 0
.#column 0])
(macro: .public (here tokens compiler)
(case tokens
{.#End}
(let [location (value@ .#location compiler)]
{.#Right [compiler
(list (` (.: .Location
[(~ [..dummy {.#Text (value@ .#module location)}])
(~ [..dummy {.#Nat (value@ .#line location)}])
(~ [..dummy {.#Nat (value@ .#column location)}])])))]})
_
{.#Left (`` (("lux in-module" (~~ (static .prelude_module)) wrong_syntax_error) (name_of ..here)))}))
(def: .public (format it)
(-> Location Text)
(let [separator ","
[file line column] it]
($_ "lux text concat"
"@"
(`` (("lux in-module" (~~ (static .prelude_module)) .text#encoded) file)) separator
(`` (("lux in-module" (~~ (static .prelude_module)) .nat#encoded) line)) separator
(`` (("lux in-module" (~~ (static .prelude_module)) .nat#encoded) column)))))
(def: \n
("lux i64 char" +10))
(def: .public (with location error)
(-> Location Text Text)
($_ "lux text concat" (..format location) \n
error))
|