Commit 5d2f3a89 authored by Craig Barnes's avatar Craig Barnes

Disallow "\z" escape sequences and improve error messages

parent ed3bd970
Pipeline #7688425 passed with stage
in 37 seconds
......@@ -43,6 +43,7 @@ are deliberately not supported to simplify cross-version compatibility:
* Hexadecimal floating point literals (e.g. `0x1.5p-3`).
* Hexadecimal escape sequences in strings (e.g. `"\xFF"`)
* Whitespace escape sequences in strings (e.g. `"\z"`)
* Unicode escape sequences in strings (e.g. `"\u{1F311}"`)
### Beyond the scope of LTCN
......
......@@ -168,11 +168,11 @@ local grammar = {
Escape = P"\\" / "" * (
S"abfnrtv'\n\r\"\\" / unescape_map
+ P"z" * V"Space"^0 / ""
+ R"09" * R"09"^-2 / tonumber / char
+ updateffp"valid escape sequence"
);
SingleQuotedString = P"'" * Cs((V"Escape" + (P(1) - S"'\r\n"))^0) * symb"'";
DoubleQuotedString = P'"' * Cs((V"Escape" + (P(1) - S'"\r\n'))^0) * symb'"';
SingleQuotedString = P"'" * Cs((V"Escape" + (P(1) - S"'\r\n\\"))^0) * symb"'";
DoubleQuotedString = P'"' * Cs((V"Escape" + (P(1) - S'"\r\n\\'))^0) * symb'"';
ShortString = V"DoubleQuotedString" + V"SingleQuotedString";
String = V"LongString" + V"ShortString";
......
......@@ -31,6 +31,9 @@ assertError("{x = .}", 1, 6)
assertError("{x = .e+2}", 1, 6)
assertError("{x = 918273645.f}", 1, 16)
assertError("{x = 009520000.000.222}", 1, 19)
assertError('{x = "\\j"}', 1, 8)
assertError('{x = "\\"}', 1, 9)
assertError('{x = "\\z\n x"}', 1, 8) -- Lua 5.2 \z escape not accepted by LTCN
-- TODO: assertError('{xyz = "\256"}', 1, 9)
assertArgError({})
......
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