tree-sitter-grammars / tree-sitter-odin

Odin grammar for tree-sitter
MIT License
17 stars 4 forks source link

bug: Block comments inside strings are parsed as comments #17

Closed terickson001 closed 4 months ago

terickson001 commented 4 months ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

The following code produces a block comment that spans over the second print statement. The trailing space on the first string is important, without it, the error does not occur.

package main

main :: proc() {
    fmt.printf("/* ")
    fmt.printf("*/")
}

Steps To Reproduce/Bad Parse Tree

(package_declaration) ; [1:1 - 12]
 (identifier) ; [1:9 - 12]
(procedure_declaration) ; [3:1 - 6:1]
 (identifier) ; [3:1 - 4]
 (procedure) ; [3:9 - 6:1]
  (parameters) ; [3:13 - 14]
  (block) ; [3:16 - 6:1]
   (member_expression) ; [4:2 - 5:17]
    (identifier) ; [4:2 - 4]
    (call_expression) ; [4:6 - 5:17]
     function: (identifier) ; [4:6 - 11]
     argument: (string) ; [4:13 - 5:16]

Expected Behavior/Parse Tree

I expect the parse tree to contain 2 function calls, and 2 strings

Repro

No response

amaanq commented 4 months ago

thanks, fixed