tree-sitter / tree-sitter-julia

Julia grammar for Tree-sitter
MIT License
93 stars 31 forks source link

The grammar cannot handle correctly the symbols :begin and :end #104

Open ronisbr opened 1 year ago

ronisbr commented 1 year ago

Hi!

The following code is valid:

if a == :end
    a = 1
else
    a = 2
end

However, the grammar thinks that the if statement ended in the :end.

The following code is also valid:

if a == :begin
    a = 1
else
    a = 2
end

But tree-sitter returns an error.

savq commented 1 year ago

Probably related to #92.

For now, as a workaround, you can enclose the symbols in parentheses:

if a == :(end)
    a = 1
else
    a = 2
end
(source_file [0, 0] - [10, 0]
  (if_statement [0, 0] - [4, 3]
    condition: (binary_expression [0, 3] - [0, 14]
      (identifier [0, 3] - [0, 4])
      (operator [0, 5] - [0, 7])
      (quote_expression [0, 8] - [0, 14]
        (parenthesized_expression [0, 9] - [0, 14]
          (identifier [0, 10] - [0, 13]))))
    (assignment [1, 4] - [1, 9]
      (identifier [1, 4] - [1, 5])
      (operator [1, 6] - [1, 7])
      (integer_literal [1, 8] - [1, 9]))
    alternative: (else_clause [2, 0] - [4, 0]
      (assignment [3, 4] - [3, 9]
        (identifier [3, 4] - [3, 5])
        (operator [3, 6] - [3, 7])
        (integer_literal [3, 8] - [3, 9]))))
ronisbr commented 1 year ago

Thanks!