boolangery / py-lua-parser

A Lua parser and AST builder written in Python.
MIT License
115 stars 36 forks source link

Literal string gets evaluated as Lua code #51

Open bendrissou opened 9 months ago

bendrissou commented 9 months ago

Hi,

When a Lua string starts with prefix \u, the string is parsed as Lua code. For example:

a="\u9"

Returns the following output:

line 1:2 token recognition error at: '"\u'
line 1:6 token recognition error at: '"\n'
{
    "Chunk": {
        "body": {
            "Block": {
                "body": [
                    {
                        "Assign": {
                            "targets": [
                                {
                                    "Name": {
                                        "id": "a",
                                        "start_char": 0,
                                        "stop_char": 0,
                                        "line": 1
                                    }
                                }
                            ],
                            "values": [
                                {
                                    "Number": {
                                        "n": 9,
                                        "start_char": 5,
                                        "stop_char": 5,
                                        "line": 1
                                    }
                                }
                            ],
                            "start_char": 0,
                            "stop_char": 5,
                            "line": 1
                        }
                    }
                ],
                "start_char": 0,
                "stop_char": 5,
                "line": 1
            }
        },
        "start_char": 0,
        "stop_char": 5,
        "line": 1
    }
}

Digit 9 is evaluated to Number. I was expecting everything enclosed in quotes to be String.

Is that correct?

bendrissou commented 1 month ago

Hi @boolangery

Any new updates on this?

Thank you.