aboutsummaryrefslogtreecommitdiff
path: root/lib/secrets.nom
diff options
context:
space:
mode:
Diffstat (limited to 'lib/secrets.nom')
-rw-r--r--lib/secrets.nom41
1 files changed, 17 insertions, 24 deletions
diff --git a/lib/secrets.nom b/lib/secrets.nom
index 8a689bd..4dd5a7a 100644
--- a/lib/secrets.nom
+++ b/lib/secrets.nom
@@ -1,41 +1,34 @@
require "lib/core.nom"
-macro block: with secrets %block
-..=: ".."
+macro block [with secrets %block] =: ".."
|local secrets = {}
- |\((%block's "value")'s "value") as lua block\
+ |\(%block's "value") as lua block\
-macro block: with secrets as %secret_name %block
-..=: ".."
+macro block [with secrets as %secret_name %block] =: ".."
|local \%secret_name as value\ = {}
- |\((%block's "value")'s "value") as lua block\
+ |\(%block's "value") as lua block\
-macro: secrets
-..=: "secrets"
+# Access the lua variable that should be within scope
+macro [secrets] =: "secrets"
-macro:
- secret %key
- secret value of %key
- secret value for %key
-..=:
- if (((%key ->"value")->"type") != "Var"):
+macro [secret %key, secret value of %key, secret value for %key] =:
+ if ((%key's "type") != "Var"):
error ".."
- |Wrong type, expected Var, but got: \(%key ->"value")->"type"\
- ".."|secrets[\repr ((%key -> "value")->"value")\]
+ |Wrong type, expected Var, but got: \%key's "type"\
+ ".."|secrets[\repr (%key's "value")\]
-macro block: secret %key = %value
-..=:
+macro block [secret %key = %new_value] =:
lua block ".."
- |if vars.key.value.type ~= "Var" then
+ |if vars.key.type ~= "Var" then
| compiler:error("Assignment operation has the wrong type for the left hand side. "
- | .."Expected Var, but got: "..vars.key.value.type)
+ | .."Expected Var, but got: "..vars.key.type)
|end
- |if vars.value.value.type ~= "Thunk" then
+ |if vars.new_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 '=:'?")
+ | .."Expected Thunk, but got: "..vars.new_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
+ | \lua expr "compiler:tree_to_lua(vars.new_value.value, 'Statement')"\
+ | secrets[\repr (%key's "value")\] = ret
|end