return last;
end
+local escapes = {
+ ["\\0"] = "\0";
+ ["\\'"] = "'";
+ ["\\\""] = "\"";
+ ["\\b"] = "\b";
+ ["\\n"] = "\n";
+ ["\\r"] = "\r";
+ ["\\t"] = "\t";
+ ["\\Z"] = "\26";
+ ["\\\\"] = "\\";
+ ["\\%"] = "%";
+ ["\\_"] = "_";
+}
local function unescape(s)
- if s == "\\'" then return "'"; end
- if s == "\\n" then return "\n"; end
- if s == "\\\\" then return "\\"; end
- error("Unknown escape sequence: "..s);
+ return escapes[s] or error("Unknown escape sequence: "..s);
end
local function readString()
read("'");
for name, data in pairs(t) do
local m = map[name];
if m then
+ if #data > 0 and #data[1] ~= #m then
+ print("[warning] expected "..#m.." columns for table `"..name.."`, found "..#data[1]);
+ end
for i=1,#data do
local row = data[i];
- for j=1,#row do
+ for j=1,#m do
row[m[j]] = row[j];
row[j] = nil;
end