tree-sitter / tree-sitter-c

C grammar for tree-sitter
MIT License
225 stars 100 forks source link

bug: quotes are mismatched with some inline asm statements #191

Closed Un1q32 closed 6 months ago

Un1q32 commented 6 months ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.20.9

Describe the bug

Quotes are mismatched

Steps To Reproduce/Bad Parse Tree

(translation_unit [0, 0] - [9, 0] (function_definition [0, 0] - [8, 1] type: (primitive_type [0, 0] - [0, 3]) declarator: (function_declarator [0, 4] - [0, 10] declarator: (identifier [0, 4] - [0, 8]) parameters: (parameter_list [0, 8] - [0, 10])) body: (compound_statement [0, 11] - [8, 1] (declaration [1, 2] - [1, 10] type: (primitive_type [1, 2] - [1, 5]) declarator: (identifier [1, 6] - [1, 9])) (expression_statement [2, 2] - [7, 4] (gnu_asm_expression [2, 2] - [7, 3] assembly_code: (string_literal [3, 4] - [3, 10] (string_content [3, 5] - [3, 9])) output_operands: (gnu_asm_output_operand_list [4, 4] - [4, 21] operand: (gnu_asm_output_operand [4, 6] - [4, 21] symbol: (identifier [4, 7] - [4, 10]) constraint: (string_literal [4, 12] - [4, 16] (string_content [4, 13] - [4, 15])) value: (identifier [4, 17] - [4, 20]))) input_operands: (gnu_asm_input_operand_list [5, 4] - [5, 5]) clobbers: (gnu_asm_clobber_list [6, 4] - [6, 17] register: (string_literal [6, 6] - [6, 11] (string_content [6, 7] - [6, 10])) register: (string_literal [6, 13] - [6, 17] (string_content [6, 14] - [6, 16]))) (ERROR [6, 18] - [6, 21] (identifier [6, 19] - [6, 20]))))))) test.c 0 ms (ERROR [6, 18] - [6, 21])

Expected Behavior/Parse Tree

Quotes shouldn't be mismatched

Repro

int main() {
  int var;
  __asm__(
    "nop;"
    : [var] "=r"(var)
    :
    : "eax", "ra" "x"
  );
}