Commit 1917da96 authored by Craig Barnes's avatar Craig Barnes

Unescape decimal escape sequences in strings

parent 8e340921
Pipeline #7684824 passed with stage
in 37 seconds
......@@ -4,7 +4,7 @@ local C, Carg, Cb, Cc = lpeg.C, lpeg.Carg, lpeg.Cb, lpeg.Cc
local Cf, Cg, Cmt, Cs, Ct = lpeg.Cf, lpeg.Cg, lpeg.Cmt, lpeg.Cs, lpeg.Ct
local tonumber, type, iotype, open = tonumber, type, io.type, io.open
local concat, sort, pairs = table.concat, table.sort, pairs
local error = error
local char, error = string.char, error
local _ENV = nil
local escape_map = {
......@@ -169,6 +169,7 @@ local grammar = {
Escape = P"\\" / "" * (
S"abfnrtv'\n\r\"\\" / unescape_map
+ P"z" * V"Space"^0 / ""
+ R"09" * R"09"^-2 / tonumber / char
);
SingleQuotedString = P"'" * Cs((V"Escape" + (P(1) - S"'\r\n"))^0) * symb"'";
DoubleQuotedString = P'"' * Cs((V"Escape" + (P(1) - S'"\r\n'))^0) * symb'"';
......
{
1, -2, 3, -0xff, -0, true, false, 'hi', "hello",
{'a','b','c'}, field1 = 55, ["field2"] = 44.0e-3, --[false] = false,
decesc1 = "\33,\0339\0\255", decesc2 = '\0\00\000\1\2\3\9\09\009\0,\5.',
["\a\b\n\\'\""] = '"\n\t\r\\\r\n',
[0xff] = 0Xff, locals = 0x55, falsey = .5,
--[=[ foo=xyz ]] ]==] ]=] etc = 100, bla = [==[ ]=] ]==],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment