metalua
metalua copied to clipboard
`\` is not properly handled in strings
Running the following I get:
M> ast = mlc.luastring_to_ast([[local s ='\ ']])
Evaluation error:
lexer.lua:284: Unknown escape sequence '\ '
stack traceback:
[C]: in function 'error'
lexer.lua:284: in function <lexer.lua:279>
[C]: in function 'gsub'
lexer.lua:290: in function 'unescape_string'
lexer.lua:410: in function '?'
lexer.lua:340: in function 'extract'
lexer.lua:508: in function 'peek'
lexer.lua:584: in function 'lineinfo_right'
gg.lua:604: in function 'parse'
gg.lua:51: in function <gg.lua:50>
(tail call): ?
...
gg.lua:51: in function 'chunk'
compiler/mlc.mlua:133: in function 'f'
compiler/mlc.mlua:165: in function 'luastring_to_ast'
stdin:1: in main chunk
[C]: in function 'xpcall'
/d/metalua/build/lib/metalua/metaloop.mlua:56: in function 'run'
compiler/metalua.mlua:251: in function 'main'
compiler/metalua.mlua:258: in main chunk
(tail call): ?
[C]: ?
Whereas, lua interpreter accepts it.
@fab13n close this issue if you find the patch good enough.
There is another issue may be related to this one. The parser cannot accept a crossing line long string with "".
str = "Hello\
world!"
The parser in koneke Lua eclipse tool has the same problem.
Regarding the previous example, the problem happens only in windows platform's line separator. The metalua parser cannot accept the sequence of "\r\n", but can accept "\n".