Evergreen-lxl / Evergreen.lxl

🌳 Treesitter support for Lite XL.
MIT License
35 stars 7 forks source link

fix: error highlighting is broken with character literals #32

Closed TorchedSammy closed 1 year ago

TorchedSammy commented 1 year ago

original code:

void main() {
    if (t[0] == '\tn') {
        printf("bruh")
    }
}

treesitter ast:

(translation_unit [0, 0] - [5, 0]
  (function_definition [0, 0] - [4, 1]
    type: (primitive_type [0, 0] - [0, 4])
    declarator: (function_declarator [0, 5] - [0, 11]
      declarator: (identifier [0, 5] - [0, 9])
      parameters: (parameter_list [0, 9] - [0, 11]))
    body: (compound_statement [0, 12] - [4, 1]
      (if_statement [1, 1] - [3, 2]
        condition: (parenthesized_expression [1, 4] - [1, 19]
          (binary_expression [1, 5] - [1, 18]
            left: (subscript_expression [1, 5] - [1, 9]
              argument: (identifier [1, 5] - [1, 6])
              index: (number_literal [1, 7] - [1, 8]))
            right: (char_literal [1, 13] - [1, 18]
              (escape_sequence [1, 14] - [1, 16])
              (ERROR [1, 16] - [1, 17]
                (identifier [1, 16] - [1, 17])))))
        consequence: (compound_statement [1, 20] - [3, 2]
          (expression_statement [2, 2] - [2, 16]
            (call_expression [2, 2] - [2, 16]
              function: (identifier [2, 2] - [2, 8])
              arguments: (argument_list [2, 8] - [2, 16]
                (string_literal [2, 9] - [2, 15])))))))))