diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-20 03:06:15 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-20 03:06:15 -0700 |
| commit | 6e46f042fdc30507b1add6432124d80f20dc86f5 (patch) | |
| tree | 186e462945800478f05dd23b2ab62e1fbc4e7afe /lib/secrets.nom | |
| parent | a6cd8907c8ff03a07f9a706abe01c81e63d25d79 (diff) | |
Mostly working overhaul again that strips out ending lines with "..",
and simplifies a lot of the code. Also stripped out Expression, which
was just a useless level of indirection.
Diffstat (limited to 'lib/secrets.nom')
| -rw-r--r-- | lib/secrets.nom | 41 |
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 |
