Closed
Description
Did you check existing issues?
- I have read all the tree-sitter docs if it relates to using the parser
- I have searched the existing issues of tree-sitter-c
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version
)
No response
Describe the bug
Type qualifiers coming after a primitive (e.g. int short myint = 5
) are errors, where short
is treated like an identifier and myint
is treated as ERROR
.
Steps To Reproduce/Bad Parse Tree
(declaration) ; [1:1 - 19]
type: (primitive_type) ; [1:1 - 3]
declarator: (init_declarator) ; [1:5 - 18]
declarator: (identifier) ; [1:5 - 9]
(ERROR) ; [1:11 - 14]
(identifier) ; [1:11 - 14]
"=" ; [1:16 - 16]
value: (number_literal) ; [1:18 - 18]
";" ; [1:19 - 19]
(declaration) ; [2:1 - 19]
type: (sized_type_specifier) ; [2:1 - 9]
"short" ; [2:1 - 5]
type: (primitive_type) ; [2:7 - 9]
declarator: (init_declarator) ; [2:11 - 18]
declarator: (identifier) ; [2:11 - 14]
"=" ; [2:16 - 16]
value: (number_literal) ; [2:18 - 18]
";" ; [2:19 - 19]
Expected Behavior/Parse Tree
(declaration) ; [1:1 - 19]
type: (sized_type_specifier) ; [1:1 - 9]
type: (primitive_type) ; [1:1 - 3]
"short" ; [1:5 - 9]
declarator: (init_declarator) ; [1:11 - 18]
declarator: (identifier) ; [1:11 - 14]
"=" ; [1:16 - 16]
value: (number_literal) ; [1:18 - 18]
";" ; [1:19 - 19]
(declaration) ; [2:1 - 19]
type: (sized_type_specifier) ; [2:1 - 9]
"short" ; [2:1 - 5]
type: (primitive_type) ; [2:7 - 9]
declarator: (init_declarator) ; [2:11 - 18]
declarator: (identifier) ; [2:11 - 14]
"=" ; [2:16 - 16]
value: (number_literal) ; [2:18 - 18]
";" ; [2:19 - 19]
Repro
int short int1 = 5; // does not work
short int int2 = 5; // works