tree-sitter-teal icon indicating copy to clipboard operation
tree-sitter-teal copied to clipboard

Does not handle multiple nested parentheses

Open HiPhish opened this issue 1 month ago • 0 comments

Take the following Teal script:

print((((('Hello world!')))))

This is valid Teal and valid Lua, in fact after compiling the Teal code to Lua I get the same code. However, the tree differs between the two parsers. This parser gives me:

(program ; [0, 0] - [2, 0]
  (function_call ; [0, 0] - [0, 29]
    called_object: (identifier) ; [0, 0] - [0, 5]
    arguments: (arguments ; [0, 5] - [0, 29]
      (string ; [0, 10] - [0, 24]
        content: (string_content))))) ; [0, 11] - [0, 23]

The Lua parser gives me:

(chunk ; [0, 0] - [2, 0]
  (function_call ; [0, 0] - [0, 29]
    name: (identifier) ; [0, 0] - [0, 5]
    arguments: (arguments ; [0, 5] - [0, 29]
      (parenthesized_expression ; [0, 6] - [0, 28]
        (parenthesized_expression ; [0, 7] - [0, 27]
          (parenthesized_expression ; [0, 8] - [0, 26]
            (parenthesized_expression ; [0, 9] - [0, 25]
              (string ; [0, 10] - [0, 24]
                content: (string_content))))))))) ; [0, 11] - [0, 23]

As you can see every level of nesting gives me one more level in the tree. I need these level in my Neovim plugin HiPhish/rainbow-delimiters.nvim to properly highlight the different pairs.

HiPhish avatar May 07 '24 06:05 HiPhish