Skip to content
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

Syntax error: unexpected ',' when inside multiline string '[[' #3

Open
ghost opened this issue Jan 31, 2022 · 2 comments
Open

Syntax error: unexpected ',' when inside multiline string '[[' #3

ghost opened this issue Jan 31, 2022 · 2 comments
Assignees
Labels
Domain - Parser This issue deals with the parser. (ast::parser) Type - Bug The library did something unexpected.

Comments

@ghost
Copy link

ghost commented Jan 31, 2022

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)
@danii danii self-assigned this Feb 14, 2022
@danii danii added Domain - Parser This issue deals with the parser. (ast::parser) Type - Bug The library did something unexpected. labels Feb 14, 2022
@danii
Copy link
Owner

danii commented Feb 14, 2022

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

@ghost
Copy link
Author

ghost commented Feb 14, 2022

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain - Parser This issue deals with the parser. (ast::parser) Type - Bug The library did something unexpected.
Projects
None yet
Development

No branches or pull requests

1 participant