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

Fix unsigned long parsing

Open marschattha opened this issue 1 year ago • 0 comments

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.

marschattha avatar Mar 15 '24 19:03 marschattha