tree-sitter-c icon indicating copy to clipboard operation
tree-sitter-c copied to clipboard

bug: Incorrect handling for TRUE statements

Open ashamedbit opened this issue 1 year ago • 0 comments

Did you check existing issues?

  • [X] I have read all the tree-sitter docs if it relates to using the parser
  • [X] I have searched the existing issues of tree-sitter-c

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

0.22.3

Describe the bug

When the argument TRUE is used it identifies it as a boolean when it could be an identifier. Note; that stdbool defines only 'true' not 'TRUE'.

Steps To Reproduce/Bad Parse Tree

static const char TRUE = "a"; B312 = (SinCosSeries(TRUE, ssig2, csig2, Ca, 6 -1) - SinCosSeries(TRUE, ssig1, csig1, Ca, 6 -1));

translation_unit [0, 0] - [3, 0] declaration [0, 0] - [0, 29] storage_class_specifier [0, 0] - [0, 6] type_qualifier [0, 7] - [0, 12] type: primitive_type [0, 13] - [0, 17] declarator: init_declarator [0, 18] - [0, 28] declarator: identifier [0, 18] - [0, 22] value: string_literal [0, 25] - [0, 28] string_content [0, 26] - [0, 27] expression_statement [1, 0] - [2, 54] assignment_expression [1, 0] - [2, 53] left: identifier [1, 0] - [1, 4] right: parenthesized_expression [1, 7] - [2, 53] binary_expression [1, 8] - [2, 52] left: call_expression [1, 8] - [1, 50] function: identifier [1, 8] - [1, 20] arguments: argument_list [1, 20] - [1, 50] true [1, 21] - [1, 25] identifier [1, 27] - [1, 32] identifier [1, 34] - [1, 39] identifier [1, 41] - [1, 43] binary_expression [1, 45] - [1, 49] left: number_literal [1, 45] - [1, 46] right: number_literal [1, 48] - [1, 49] right: call_expression [2, 10] - [2, 52] function: identifier [2, 10] - [2, 22] arguments: argument_list [2, 22] - [2, 52] true [2, 23] - [2, 27] identifier [2, 29] - [2, 34] identifier [2, 36] - [2, 41] identifier [2, 43] - [2, 45] binary_expression [2, 47] - [2, 51] left: number_literal [2, 47] - [2, 48] right: number_literal [2, 50] - [2, 51]

Expected Behavior/Parse Tree

TRUE should be an identifier in this case

Repro

static const char TRUE = "a";
B312 = (SinCosSeries(TRUE, ssig2, csig2, Ca, 6 -1) -
          SinCosSeries(TRUE, ssig1, csig1, Ca, 6 -1));

ashamedbit avatar Oct 15 '24 17:10 ashamedbit