diff options
| author | olive <olive@olive.ooo> | 2026-09-25 17:42:35 +0100 |
|---|---|---|
| committer | olive <olive@olive.ooo> | 2026-09-25 17:42:35 +0100 |
| commit | 67d882819b908d8178a890c12a1734de8ba7cf12 (patch) | |
| tree | be9a35c3a8044184370db4a29a7fa688adae0bfa | |
| parent | 00060d7965d42386e15dca6361683b72e430808c (diff) | |
| -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 |
