usagi-coffee / tree-sitter-abl

OpenEdge ABL grammar for tree-sitter
MIT License
7 stars 1 forks source link

Wrong precedence of logical operators #7

Closed jchros closed 1 year ago

jchros commented 1 year ago

While working on #6, I identified a case where the parser emits an incorrect syntax tree, for the following code:

y = x < 10 OR x = 10.

Here's the emitted syntax tree:

(source_code
  (statement
    (variable_assignment
      (assignment
        (identifier)
        (expression
          (comparison
            (expression
              (identifier))
            (comparator)
            (expression
              (logical_expression
                (expression
                  (number_literal))
                (logical_operator)
                (expression
                  (comparison
                    (expression
                      (identifier))
                    (comparator)
                    (expression
                      (number_literal)))))))))
      (terminator))))

The code is parsed as if it were equivalent to:

y = (x < (10 OR (x = 10))).

But the OpenEdge ABL parses it as:

y = ((x < 10) OR (x = 10)).