Skip to content

feat: add escape character support in double-quoted string literals#142

Open
osteele wants to merge 1 commit intomainfrom
string-escapes
Open

feat: add escape character support in double-quoted string literals#142
osteele wants to merge 1 commit intomainfrom
string-escapes

Conversation

@osteele
Copy link
Owner

@osteele osteele commented Feb 27, 2026

Summary

  • Support \", \\, \n, \t, \r escape sequences in double-quoted strings
  • Single-quoted strings remain literal (no escape processing), matching Ruby Liquid behavior
  • Unknown escape sequences pass through as-is (e.g., \x\x)

Closes #45

Changes

  • expressions/scanner.rl: Updated Ragel pattern for double-quoted strings to accept \ followed by any character; updated String action to call unescapeString() for double-quoted strings
  • expressions/scanner.go: Regenerated from scanner.rl
  • expressions/scanner_test.go: Added TestLexStringEscapes with 8 subtests

Test plan

  • All existing tests pass
  • New scanner tests cover: \\, \", \n, \t, \r, unknown escapes, single-quote passthrough, plain strings

Support \", \\, \n, \t, \r escape sequences in double-quoted strings.
Single-quoted strings remain literal (no escape processing).

Closes #45
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.

Escape charactors in string literals

1 participant