Talk about escape sequences and ambiguity with \u

This commit is contained in:
Alexander McCord 2022-08-17 13:31:40 -07:00 committed by GitHub
parent 0e118b54bb
commit 77ba1eda87
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,6 +139,13 @@ local foo: `foo`
local bar: `bar{baz}`
```
String interpolation syntax will also support escape sequences. Except `\u{...}`, there is no ambiguity with other escape sequences. If `\u{...}` occurs within a string interpolation literal, it takes priority.
```lua
local foo = `foo\tbar` -- "foo bar"
local bar = `\u{0041} \u{42}` -- "A B"
```
## Drawbacks
If we want to use backticks for other purposes, it may introduce some potential ambiguity. One option to solve that is to only ever produce string interpolation tokens from the context of an expression. This is messy but doable because the parser and the lexer are already implemented to work in tandem. The other option is to pick a different delimiter syntax to keep backticks available for use in the future.