hematita
hematita copied to clipboard
Syntax error: unexpected ',' when inside multiline string '[['
Hi,
First of all thanks for this project. I would like to have more time and knowledge to help on hematita. :)
So, let's talk about bugs...the code below does not run on hematita_cli
, but on luajit works fine.
Error
$ hematita_cli print_html.lua
syntax error: unexpected ','
Code
-- print_html.lua
local html = [[
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
]]
local html_footer = [[
</body>
</html>
]]
print(html)
This bug is not reproducible for me. There is a chance that the error message is referencing a different comma inside of your file, if there is more than what you provided in your file. I wouldn't know where, but if I had to guess, it's in a for x, y in z do
loop (which is a known issue, although there isn't an open issue for it).
You are right.
I found the "issue". On luajit the code is ran normally, but your way of doing lexer first, in hematita
helps on detect undefined variables. That's a good thing, but for custom functions maybe could be an issue, which is my case. By the way, logon_exists
is a lua table (A custom one).
You can reproduce the "error" with this code:
function logon()
local html_header = [[
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
]]
local html_footer = [[
</body>
</html>
]]
print(html_header)
if logon_exists
then
local table_header = [[
<h2>Logon - (logon_exists)</h2>
<table>
<thead>
<tr><th>Key</th><th>Value</th></tr>
</thead><tbody>
]]
print(table_header)
for k,v in pairs(logon_exists) do
print("<tr>")
local key_column = "<td>" .. k .. "</td>"
local value_column = "<td>" .. v .. "</td>"
print(key_column)
print(value_column)
print("</tr>")
end
print ("</tbody></table>")
end
local html_footer = [[
</body>
</html>
]]
print(html_footer)
end
function main()
logon()
end
main()