summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2015-11-09 08:17:49 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-11-09 08:17:49 +0000
commit3a3c54b1912f5d86bb8e8e57839dbda010b1661b (patch)
treedcd3a4ef4e9b28aae67d26c9c68fb5ddb2203bfc
parentc70b3b1a7159dcd2f860d000777129a6021707ab (diff)
downloadlace-3a3c54b1912f5d86bb8e8e57839dbda010b1661b.tar.bz2
Support the concent that compile_one_line() might return many rules for that one line
-rw-r--r--lib/lace/compiler.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/lace/compiler.lua b/lib/lace/compiler.lua
index a3610c3..86c96df 100644
--- a/lib/lace/compiler.lua
+++ b/lib/lace/compiler.lua
@@ -75,7 +75,11 @@ local function compile_one_line(compcontext, line)
args[i] = line.content[i].str
end
- return cmdfn(compcontext, unpack(args))
+ local linerule, err = cmdfn(compcontext, unpack(args))
+ if type(linerule) ~= "table" then
+ return linerule, err
+ end
+ return {linerule}, err
end
--- Internal ruleset compilation.
@@ -133,13 +137,16 @@ local function internal_compile_ruleset(compcontext, sourcename, content, suppre
if line.type == "rule" then
-- worth trying to parse a rule
_setposition(compcontext, ruleset, i)
- local rule, msg = compile_one_line(compcontext, line)
- if type(rule) ~= "table" then
- return rule, err.augment(msg, ruleset.content, i)
+ local rules, msg = compile_one_line(compcontext, line)
+ if type(rules) ~= "table" then
+ return rules, err.augment(msg, ruleset.content, i)
+ end
+ for j = 1, #rules do
+ local rule = rules[j]
+ rule.linenr = i
+ rule.source = ruleset.content
+ ruleset.rules[#ruleset.rules+1] = rule
end
- rule.linenr = i
- rule.source = ruleset.content
- ruleset.rules[#ruleset.rules+1] = rule
end
end