- if ch == "\"" and not slash then break; end
- str = str..ch;
- end
- str = str:gsub("\\.", {["\\b"]="\b", ["\\d"]="\d", ["\\e"]="\e", ["\\f"]="\f", ["\\n"]="\n", ["\\r"]="\r", ["\\s"]="\s", ["\\t"]="\t", ["\\v"]="\v", ["\\\""]="\"", ["\\'"]="'", ["\\\\"]="\\"});
- return str;
-end
-local function readSpecialString()
- read("<"); read("<"); -- read <<
- local str = "";
- if peek() == "\"" then
- str = readString();
- elseif peek() ~= ">" then
- error();
+ if slash then
+ slash = slash..ch;
+ if not escapes[slash] then error("Unknown escape sequence: "..slash); end
+ str = str..escapes[slash];
+ slash = nil;
+ elseif ch == "\"" then
+ break;
+ elseif ch == "\\" then
+ slash = ch;
+ else
+ str = str..ch;
+ end