From 6e46f042fdc30507b1add6432124d80f20dc86f5 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 20 Sep 2017 03:06:15 -0700 Subject: 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. --- lib/secrets.nom | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'lib/secrets.nom') 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 -- cgit v1.2.3