diff options
Diffstat (limited to 'config.lua')
| -rw-r--r-- | config.lua | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,4 +1,3 @@ -local function partial(f,x) return function(...) return f(x,...) end end local function kv_syntax(block,line) local k,v = line:match"^([a-z0-9_-]+)%s*=%s*(.*)$" @@ -22,7 +21,8 @@ local schema = { local function parse_file(file) local blocks = {} for k in pairs(schema) do blocks[k] = {} end - local line_handler = function() error("line outside of block") end + local line_handler = function(block,line) error("line outside of block") end + local block for line in file:lines() do line = line:gsub(";.*$",""):gsub("^%s*",""):gsub("%s*$","") @@ -31,11 +31,11 @@ local function parse_file(file) local block_type, block_name = line:match"%[%s*(%S+)%s+(%S+)%s*%]" if block_type then local blocks_of_this_type = assert(blocks[block_type],"no such block type "..block_type) - local block = {} + block = {} blocks_of_this_type[block_name] = block - line_handler = partial(schema[block_type], block) + line_handler = schema[block_type] else - line_handler(line) + line_handler(block, line) end ::next:: end |
