-
Notifications
You must be signed in to change notification settings - Fork 2
Lua parser fails to find ending of string enclosed by level 1 long brackets if the last character of the string is a square bracket #7
Comments
Could you provide a minimal source code example as plain text? |
The reason for this is probably that the parsing for if (lexer->lookahead == '[' || lexer->lookahead == '=') {
// further down
if (lexer->lookahead == ']' || lexer->lookahead == '=') {
|
It's probably good to start with #6 which already cleaned up the parser code. |
We could also switch to https://github.com/MunifTanjim/tree-sitter-lua. It has the string start/end as separated nodes, which makes it easier for injections :) Looks like the project took some inspiration from the original repo that was forked. @MunifTanjim what's the status of your parser? I think it's more complete than this one :D And it doesn't have this issue return function()
local a = [=[]]=]
local b = [=[]=]
return a, b
end is parsed as (chunk [0, 0] - [5, 0]
(return_statement [0, 0] - [4, 3]
(function_definition [0, 7] - [4, 3]
parameters: (parameters [0, 15] - [0, 17])
body: (block [1, 2] - [3, 13]
local_declaration: (variable_declaration [1, 2] - [1, 19]
(assignment_statement [1, 8] - [1, 19]
(variable_list [1, 8] - [1, 9]
name: (identifier [1, 8] - [1, 9]))
(expression_list [1, 12] - [1, 19]
value: (string [1, 12] - [1, 19]))))
local_declaration: (variable_declaration [2, 2] - [2, 18]
(assignment_statement [2, 8] - [2, 18]
(variable_list [2, 8] - [2, 9]
name: (identifier [2, 8] - [2, 9]))
(expression_list [2, 12] - [2, 18]
value: (string [2, 12] - [2, 18]))))
(return_statement [3, 2] - [3, 13]
(identifier [3, 9] - [3, 10])
(identifier [3, 12] - [3, 13]))))))
|
It's complete as far as I know. It has corpus tests for all the possbile cases and can parse the whole I've been using it since August 2021 using this MunifTanjim/nvim-treesitter-lua#2 . Haven't face any issues in my daily usage yet. In case you wanna try it, the queries are available in this repo: https://github.com/MunifTanjim/nvim-treesitter-lua The only reason I haven't shared it anywhere yet is because it's not easily usable without building |
That sounds great! Any thoughts about switching to that parser? @theHamsta @vigoux |
Describe the bug
Lua parser fails to find ending of string enclosed by level 1 Lua long brackets if the last character of the string is a square bracket.
To Reproduce
Expected behavior
Lines 35 to 874 are highlighted correctly.
Output of
:checkhealth nvim-treesitter
Output of
nvim --version
Additional context
Screenshot:
The text was updated successfully, but these errors were encountered: