diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-05-13 11:09:05 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-05-13 11:09:05 +0100 |
commit | 3b3dae2b6ad232e5c9b8d7d5d29e0c8aa3e22da1 (patch) | |
tree | 2b2fb274129dde74a611d9ec845c3ae9b7f9ef8b | |
parent | 24e3686cdc8b7b55959b3d3747f1f4ae93fd5258 (diff) | |
download | lace-3b3dae2b6ad232e5c9b8d7d5d29e0c8aa3e22da1.tar.gz |
Support checking defines in anyof/allof
-rw-r--r-- | lib/lace/builtin.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/lace/builtin.lua b/lib/lace/builtin.lua index da728a3..5f32811 100644 --- a/lib/lace/builtin.lua +++ b/lib/lace/builtin.lua @@ -237,10 +237,22 @@ local function _compile_any_all_of(compcontext, mtype, first, second, ...) return err.error("Expected at least two names, only got one", {1, 2}) end + -- Now check that all the arguments we were given make sense... + local cond = {first, second, ...} + compcontext._lace.defined = (compcontext._lace.defined or {}) + for i, dname in ipairs(cond) do + if dname:sub(1,1) == "!" then + dname = dname:sub(2) + end + if not compcontext._lace.defined[dname] then + return err.error("Undefined name used in "..mtype.." ("..dname..")", {i + 1}) + end + end + local rule = { fn = _do_any_all_of, } - rule.args = { rule, { first, second, ...}, mtype == "anyof" } + rule.args = { rule, cond, mtype == "anyof" } return rule end |