-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem with fix_str() in parser.lua #4
Comments
Can you please check whether this issue persists after latest changes? |
After latest changes, this bug still persists. x = "\\" Parsing this program throws the following error message: bug.lua:1:7: syntax error, unclosed string @undecidabot, do you have any thoughts on this? |
@andremm Hm, I can't seem to reproduce this bug (on latest commit of master). I'm pretty sure this case is already handled by https://github.com/andremm/lua-parser/blob/master/lua-parser/parser.lua#L415. I could reproduce the exact error message if there's only one backslash as in
but that wouldn't be a bug then. Are any of the other escape characters also having this issue? |
@undecidabot, this bug is a bit tricky. :) For instance, using the following test file (which I will call local parser = require "lua-parser.parser"
local pp = require "lua-parser.pp"
if #arg ~= 1 then
print("Usage: parse.lua <string>")
os.exit(1)
end
local ast, error_msg = parser.parse(arg[1], "example.lua")
if not ast then
print(error_msg)
os.exit(1)
end
pp.print(ast)
os.exit(0) Running As another example, using the following test file (which I will call local parser = require "lua-parser.parser"
local pp = require "lua-parser.pp"
local ast, error_msg = parser.parse('x = "\\"', "example.lua")
if not ast then
print(error_msg)
else
pp.print(ast)
end
local ast, error_msg = parser.parse("x = '\\'", "example.lua")
if not ast then
print(error_msg)
else
pp.print(ast)
end
os.exit(0) Both examples don't work when running However, both examples should work, as we can see in the following Lua test: Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
> x = '\\'
> print(x)
\
> x = "\\"
> print(x)
\
> |
@andremm It took a while, but I've figured it out. There is no bug 😄 For bug1.lua,
Similarly, for bug2.lua, the characters are being escaped, but this time by Lua. So again, there is only one backslash which is followed by the quote, making the string unclosed just as the error reports. If we change the This bug was definitely confusing, but I think we can mark it as resolved now 😄 |
You're right @undecidabot. I'm sorry I took too long to reply, but that's great that @bbblitz already closed the issue. Thanks for your feedback! |
When given the string
"\\a"
The fix_str() function will make this into
"\\\a"
Instead of the correct
"\a"
This is the same for all escaped characters. (\b,\n,\r ect.)
The text was updated successfully, but these errors were encountered: