Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ronisbr opened this issue Jun 21, 2023 · 2 comments
Open

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

ronisbr opened this issue Jun 21, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ronisbr
Copy link

ronisbr commented Jun 21, 2023

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.

@ronisbr ronisbr changed the title The grammar cannot handle correctly the symbol :end The grammar cannot handle correctly the symbols :begin and :end Jun 21, 2023
@savq savq added the bug Something isn't working label Jun 24, 2023
@savq
Copy link
Collaborator

savq commented Jun 24, 2023

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
Copy link
Author

ronisbr commented Jun 24, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants