metalua icon indicating copy to clipboard operation
metalua copied to clipboard

`\` is not properly handled in strings

Open KINFOO opened this issue 13 years ago • 3 comments

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.

KINFOO avatar Nov 08 '12 16:11 KINFOO

@fab13n close this issue if you find the patch good enough.

KINFOO avatar Jan 25 '13 17:01 KINFOO

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.

wanghc78 avatar Jun 19 '14 01:06 wanghc78

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".

wanghc78 avatar Jul 22 '14 21:07 wanghc78