1 local function snext(t, state)
7 if k ~= "__sorted" then
8 table.insert(t.__sorted, k)
11 table.sort(t.__sorted)
15 for i, v in ipairs(t.__sorted) do
17 key = t.__sorted[i + 1]
34 local function parse_pair(pair, value_first)
35 if pair:sub(1, 1) == "#" then
39 local idx = pair:find(" ")
42 local first, second = pair:sub(1, idx - 1), pair:sub(idx + 1)
44 if value_first and first:sub(1, 1) ~= "[" then
54 function parse_spec(name, value_first)
55 local f = io.open("../spec/" .. name, "r")
60 if l:sub(1, 1) == "\t" then
61 local key, val = parse_pair(l:sub(2), value_first)
66 table.insert(top, key)
69 local key, val = parse_pair(l, value_first)
84 local casemap = parse_spec("casemap")
86 function camel_case(snake)
87 if casemap[snake] then
94 local idx = snake:find("_") or #snake + 1
97 .. snake:sub(1, 1):upper()
98 .. snake:sub(2, idx - 1)
100 snake = snake:sub(idx + 1)