From ac25e20b9f94505175841d9a8da7253f8996926d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 28 Sep 2017 17:49:15 -0700 Subject: Kinda mostly working, except for closure vars like in lib/secrets.nom. --- lib/secrets.nom | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'lib/secrets.nom') diff --git a/lib/secrets.nom b/lib/secrets.nom index 052ee6c..b6274ab 100644 --- a/lib/secrets.nom +++ b/lib/secrets.nom @@ -1,33 +1,30 @@ require "lib/core.nom" -macro block [with secrets %block] =: ".." +compile (with secrets %block) to block: ".." |local secrets = {} - |\(%block's "value") as lua\ - -macro block [with secrets as %secret_name %block] =: ".." - |local \%secret_name as value\ = {} - |\(%block's "value") as lua\ + |\(%block as lua statements) # Access the lua variable that should be within scope -macro [secrets] =: "secrets" +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)" -macro [secret %key, secret value of %key, secret value for %key] =: - if ((%key's "type") != "Var"): - error ".." - |Wrong type, expected Var, but got: \%key's "type"\ - ".."|secrets[\repr (%key's "value")\] +enable debugging +with secrets: + secret %foo = 5 + rule (plumb %) =: + secret %foo = % + rule (frop) =: + secret %foo -macro block [secret %key = %new_value] =: - lua block ".." - |if vars.key.type ~= "Var" then - | nomsu:error("Assignment operation has the wrong type for the left hand side. " - | .."Expected Var, but got: "..vars.key.type) - |end - |if vars.new_value.type ~= "Thunk" then - | nomsu:error("Assignment operation has the wrong type for the right hand side. " - | .."Expected Thunk, but got: "..vars.new_value.type.."\\nMaybe you used '=' instead of '=:'?") - |end - ".." - |local ret - |\lua expr "nomsu:tree_to_lua(vars.new_value.value)"\ - |secrets[\repr (%key's "value")\] = ret +say (frop) +pumb 99 +say (frop) -- cgit v1.2.3