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

Parser error when combining block statement and indexing with begin #130

Closed
cvigilv opened this issue Feb 23, 2024 · 1 comment
Closed

Comments

@cvigilv
Copy link

cvigilv commented Feb 23, 2024

Hi! I am currently seeing the following error whenever I want to parse the following example:

X = [1,2,3]

result = begin
    x = X[begin]
    y = X[begin+1]
    z = X[begin+2]
end

I get the following tree:

(ERROR ; [0, 0] - [7, 0]
  (assignment ; [0, 0] - [0, 11]
    (identifier) ; [0, 0] - [0, 1]
    (operator) ; [0, 2] - [0, 3]
    (vector_expression ; [0, 4] - [0, 11]
      (integer_literal) ; [0, 5] - [0, 6]
      (integer_literal) ; [0, 7] - [0, 8]
      (integer_literal))) ; [0, 9] - [0, 10]
  (identifier) ; [2, 0] - [2, 6]
  (assignment ; [3, 4] - [3, 16]
    (identifier) ; [3, 4] - [3, 5]
    (operator) ; [3, 6] - [3, 7]
    (index_expression ; [3, 8] - [3, 16]
      (identifier) ; [3, 8] - [3, 9]
      (vector_expression ; [3, 9] - [3, 16]
        (identifier)))) ; [3, 10] - [3, 15]
  (identifier) ; [4, 4] - [4, 5]
  (identifier) ; [4, 8] - [4, 9]
  (matrix_row ; [4, 10] - [4, 15]
    (identifier)) ; [4, 10] - [4, 15]
  (ERROR ; [4, 15] - [7, 0]
    (unary_expression ; [4, 15] - [4, 17]
      (operator) ; [4, 15] - [4, 16]
      (integer_literal)) ; [4, 16] - [4, 17]
    (ERROR) ; [4, 17] - [4, 18]
    (identifier) ; [5, 4] - [5, 5]
    (identifier) ; [5, 8] - [5, 9]
    (compound_statement ; [5, 10] - [6, 3]
      (unary_expression ; [5, 15] - [5, 17]
        (operator) ; [5, 15] - [5, 16]
        (integer_literal)) ; [5, 16] - [5, 17]
      (ERROR)))) ; [5, 17] - [5, 18]

But not when I invert the order of the elements inside the slicing, for example:

X = [1,2,3]

result = begin
    x = X[begin]
    y = X[1+begin]
    z = X[2+begin]
end

where I obtain the following tree:

(source_file ; [0, 0] - [7, 0]
  (assignment ; [0, 0] - [0, 11]
    (identifier) ; [0, 0] - [0, 1]
    (operator) ; [0, 2] - [0, 3]
    (vector_expression ; [0, 4] - [0, 11]
      (integer_literal) ; [0, 5] - [0, 6]
      (integer_literal) ; [0, 7] - [0, 8]
      (integer_literal))) ; [0, 9] - [0, 10]
  (assignment ; [2, 0] - [6, 3]
    (identifier) ; [2, 0] - [2, 6]
    (operator) ; [2, 7] - [2, 8]
    (compound_statement ; [2, 9] - [6, 3]
      (assignment ; [3, 4] - [3, 16]
        (identifier) ; [3, 4] - [3, 5]
        (operator) ; [3, 6] - [3, 7]
        (index_expression ; [3, 8] - [3, 16]
          (identifier) ; [3, 8] - [3, 9]
          (vector_expression ; [3, 9] - [3, 16]
            (identifier)))) ; [3, 10] - [3, 15]
      (assignment ; [4, 4] - [4, 18]
        (identifier) ; [4, 4] - [4, 5]
        (operator) ; [4, 6] - [4, 7]
        (index_expression ; [4, 8] - [4, 18]
          (identifier) ; [4, 8] - [4, 9]
          (vector_expression ; [4, 9] - [4, 18]
            (binary_expression ; [4, 10] - [4, 17]
              (integer_literal) ; [4, 10] - [4, 11]
              (operator) ; [4, 11] - [4, 12]
              (identifier))))) ; [4, 12] - [4, 17]
      (assignment ; [5, 4] - [5, 18]
        (identifier) ; [5, 4] - [5, 5]
        (operator) ; [5, 6] - [5, 7]
        (index_expression ; [5, 8] - [5, 18]
          (identifier) ; [5, 8] - [5, 9]
          (vector_expression ; [5, 9] - [5, 18]
            (binary_expression ; [5, 10] - [5, 17]
              (integer_literal) ; [5, 10] - [5, 11]
              (operator) ; [5, 11] - [5, 12]
              (identifier)))))))) ; [5, 12] - [5, 17]

This may be related to #127

@savq
Copy link
Collaborator

savq commented Feb 23, 2024

Yes, it's the same error as 127. I'll close this as a duplicate to not get confused later.

@savq savq closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants