ReFreezed / DumbLuaParser

Lua parsing library capable of optimizing and minifying code.
http://refreezed.com/luaparser/
MIT License
33 stars 3 forks source link

Error processing escape character in strings #6

Open foul11 opened 11 months ago

foul11 commented 11 months ago

Very simple code for demo:

local parser = require('dumbParser')

local ast = parser.parse('print("\\x00")') -- passed string: print("\x00")
--local ast = parser.parseExpression('print("\\x00")') -- same thing
--local ast = parser.parseFile('test.lua') -- same thing

parser.printTree(ast) -- toLua gives the same effect
                      -- lua51:        ... ARG1 literal (string="x00") / Wrong.
                      -- lua53/luajit: ... ARG1 literal (string="{NUL}") / OK.

local ast = parser.parse('print("\\\\x00")') -- passed string: print("\\x00") / OK
--local ast = parser.parse('print("\\0000")') -- passed string: print("\0000") / OK
--local ast = parser.parse('print("\\1000")') -- passed string: print("\1000") / OK

parser.printTree(ast) -- toLua gives the same effect
                      -- lua51:        ... ARG1 literal (string="\x00") / OK.
                      -- lua53/luajit: ... ARG1 literal (string="\x00") / OK.

This affects the recording of escape characters.