nomsu/lib/secrets.nom
Bruce Hill dcd3391b36 Updated to undo some of the block/thunk stuff. Thunks are thunks, and
expressions can be grouped with parens, and they have a clear
distinction.
2017-10-02 17:21:22 -07:00

23 lines
717 B
Plaintext

require "lib/core.nom"
compile [with secrets %block] to code: ".."
|do;
| local secrets = {}
| \(%block as lua statements)
|end;
# Access the lua variable that should be within scope
compile [secrets] to: "secrets"
compile [secret %key; secret value of %key; secret value for %key] to:
assert ((%key's "type") == "Var") ".."
|Wrong type, expected Var, but got: \(%key's "type")
"secrets[\(repr (%key's "value"))]"
compile [secret %key = %new_value] to code:
assert ((%key's "type") == "Var") ".."
|Wrong type, expected Var, but got: \(%key's "type")
"secrets[\(repr (%key's "value"))] = \(%new_value as lua)"
rule [rules about secrecy] =: ["with secrets %"]