tree-sitter / tree-sitter-julia

Julia grammar for tree-sitter
MIT License
95 stars 33 forks source link

Parse failure with block comment in struct definition #56

Open fredrikekre opened 2 years ago

fredrikekre commented 2 years ago

Source:

struct Foo
    bar::Int
    #= const =# ibaz::Int
end

Playground:

struct_definition [0, 0] - [3, 3]
  name: identifier [0, 7] - [0, 10]
  typed_expression [1, 4] - [2, 25]
    typed_expression [1, 4] - [2, 20]
      identifier [1, 4] - [1, 7]
      ERROR [1, 9] - [1, 12]
        identifier [1, 9] - [1, 12]
      block_comment [2, 4] - [2, 15]
      identifier [2, 16] - [2, 20]
    identifier [2, 22] - [2, 25]

Note the i in front of baz -- I discovered this since my real member name started with i. If I remove it the parser trips up at another location, which seems pretty weird, but not sure if it has some significance.

Source:

struct Foo
    bar::Int
    #= const =# baz::Int
end

Playground:

struct_definition [0, 0] - [3, 3]
  name: identifier [0, 7] - [0, 10]
  typed_expression [1, 4] - [2, 24]
    typed_expression [1, 4] - [1, 12]
      identifier [1, 4] - [1, 7]
      identifier [1, 9] - [1, 12]
    block_comment [2, 4] - [2, 15]
    ERROR [2, 16] - [2, 19]
      identifier [2, 16] - [2, 19]
    identifier [2, 21] - [2, 24]
fredrikekre commented 3 months ago

Still an issue but the i doesn't matter anymore:

struct Foo
    bar::Int
    #= const =# baz::Int
end
(struct_definition) ; [1:1 - 4:3]
 name: (identifier) ; [1:8 - 10]
 (typed_expression) ; [2:5 - 3:24]
  (typed_expression) ; [2:5 - 12]
   (identifier) ; [2:5 - 7]
   (identifier) ; [2:10 - 12]
  (block_comment) ; [3:5 - 15]
  (ERROR) ; [3:17 - 19]
  (identifier) ; [3:22 - 24]