fwcd / tree-sitter-kotlin

Kotlin grammar for Tree-sitter
https://fwcd.github.io/tree-sitter-kotlin
MIT License
126 stars 52 forks source link

Fix unsigned long parsing #116

Closed marschattha closed 2 months ago

marschattha commented 6 months ago

Currently if you try to parse a hexadecimal unsigned long it gives an error and returns the wrong tree.

For example parsing 0xfff0000000000000UL returns

(source_file
  (ERROR
    (hex_literal)
    (simple_identifier)))

And it completely goes bonkers if there is a list of hexadecimal unsigned longs, [0xfff0000000000000UL, 0xfff0000000000000UL] returns something like:

(source_file
  (collection_literal
    (infix_expression
      (infix_expression 
        (hex_literal)
        (simple_identifier)
        (ERROR)
        (hex_literal))
      (simple_identifier))
      (simple_identifier))))

And gets worse with the length of the array.

For some reason https://github.com/fwcd/tree-sitter-kotlin/blob/260afd9a92bac51b3a4546303103c3d40a430639/grammar.js#L1179 is not working correctly.

This PR moves the check for L into regex in above line to work around the issue.