blob: 8a689bda05e9964743a26627930cc12a9ddda053 (
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
|
require "lib/core.nom"
macro block: with secrets %block
..=: ".."
|local secrets = {}
|\((%block's "value")'s "value") as lua block\
macro block: with secrets as %secret_name %block
..=: ".."
|local \%secret_name as value\ = {}
|\((%block's "value")'s "value") as lua block\
macro: secrets
..=: "secrets"
macro:
secret %key
secret value of %key
secret value for %key
..=:
if (((%key ->"value")->"type") != "Var"):
error ".."
|Wrong type, expected Var, but got: \(%key ->"value")->"type"\
".."|secrets[\repr ((%key -> "value")->"value")\]
macro block: secret %key = %value
..=:
lua block ".."
|if vars.key.value.type ~= "Var" then
| compiler:error("Assignment operation has the wrong type for the left hand side. "
| .."Expected Var, but got: "..vars.key.value.type)
|end
|if vars.value.value.type ~= "Thunk" then
| compiler:error("Assignment operation has the wrong type for the right hand side. "
| .."Expected Thunk, but got: "..vars.value.value.type.."\\nMaybe you used '=' instead of '=:'?")
|end
".."|do
| local ret
| \lua expr "compiler:tree_to_lua(vars.value.value.value, 'Statement')"\
| secrets[\repr ((%key -> "value")->"value")\] = ret
|end
|