Skip to content

fix(parse): read Lua 5.4 string escapes - #96

Merged
wolfy-j merged 3 commits into
mainfrom
fix/lexer-escapes-lua54
Nov 15, 2026
Merged

wolfy-j merged 3 commits into
mainfrom
fix/lexer-escapes-lua54

Conversation

@wolfy-j

@wolfy-j wolfy-j commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

The lexer accepted Lua 5.4 escapes as literal characters: "\x41" became "x41", "\u{E4}" became "u{E4}", and \z did not skip whitespace. Unknown escapes were also accepted.

Implement \xXX, \u{...} and \z with the Lua 5.4 syntax and error rules. Unicode escapes support the same extended values as utf8.char, up to 0x7FFFFFFF. Both paths now share internal.AppendUTF8Esc; the duplicate encoder from merged #94 is removed. Decimal escapes and escaped newlines retain their existing behavior.

Unknown escapes now produce compile errors. For example, a literal backslash for a regular expression must be escaped as "\\d" rather than "\d".

Validation:

  • Escape regressions cover hex digits, 1–6 byte encodings, whitespace and CRLF handling, line accounting, bounds and malformed escapes. The original missing-escape cases fail before the fix.
  • Shared encoder boundary tests and combined UTF-8/escape regressions pass under the race detector. A cross-library test checks that escaped literals and utf8.char produce identical bytes at every encoding boundary.
  • A read-only parse scan of 5,624 existing Lua files in Framework, Session, Dataflow, Keeper, Userspace and Kickside reports zero invalid escapes and zero other parse errors.
  • The original revision passed the full fixture corpus and all 12 CI checks. This revision also composes merged fix(utf8lib): port the Lua 5.4 utf8 library #94/fix(stringlib): return integers for byte values, positions and counts #95 and awaits fresh CI.

@wolfy-j
wolfy-j requested a review from skhaz November 15, 2026 20:20
@wolfy-j
wolfy-j requested a review from skhaz November 15, 2026 20:24
@wolfy-j
wolfy-j merged commit 591aa2a into main Nov 15, 2026
12 checks passed
@wolfy-j
wolfy-j deleted the fix/lexer-escapes-lua54 branch November 15, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants