Lua: multi-line string literals

This commit is contained in:
Zef Hemel
2024-10-07 09:08:36 +02:00
parent 41a856636a
commit 6c71862641
8 changed files with 140 additions and 24 deletions
+9 -5
View File
@@ -79,7 +79,7 @@ exp {
UnaryExpression |
TableConstructor |
FunctionDef { kw<"function"> FuncBody }
/*| Query*/
// | Query
}
Query {
@@ -154,10 +154,8 @@ TableConstructor { "{" (field (fieldsep field)* fieldsep?)? "}" }
@tokens {
CompareOp { "<" | ">" | $[<>=~/!] "=" }
TagIdentifier { @asciiLetter (@asciiLetter | @digit | "-" | "_" | "/" )* }
word { (std.asciiLetter | "_") (std.digit | std.asciiLetter | "_")* }
identifier { word }
@@ -165,11 +163,17 @@ TableConstructor { "{" (field (fieldsep field)* fieldsep?)? "}" }
stringEscape {
"\\" ($[abfnz"'\\] | digit digit? digit?) |
"\\x" hex hex |
// NOTE: this should really be /[0-7]hex{5}/ at max, but that's annoying to write
"\\u{" hex+ "}"
}
simpleString { "'" (stringEscape | ![\r\n\\'])* "'" | '"' (stringEscape | ![\r\n\\"])* '"'}
// Any sequence of characters except two consecutive ]]
longStringContent { (![\]] | $[\]] ![\]])* }
simpleString {
"'" (stringEscape | ![\r\n\\'])* "'" |
'"' (stringEscape | ![\r\n\\"])* '"' |
'[[' longStringContent ']]'
}
hex { $[0-9a-fA-F] }
digit { std.digit }