-
-
Notifications
You must be signed in to change notification settings - Fork 169
Open
Labels
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)
tree-sitter 0.25.8 (f2f197b6b27ce75c280c20f131d4f71e906b86f7)
Describe the bug
code:
typedef enum __attribute__((packed)) {
BT_CTL_STATE_IDLE,
BT_CTL_STATE_CONNECTING_LAST,
BT_CTL_STATE_DISCOVERING_NEW,
BT_CTL_STATE_CONNECTED
} bt_ctl_state_t;
Steps To Reproduce/Bad Parse Tree
- make file with mentoned code.
- run tree-sitter parse
- you will see incorrect tree:
(translation_unit [9, 0] - [24, 0]
(type_definition [9, 0] - [9, 36]
type: (enum_specifier [9, 8] - [9, 26]
name: (type_identifier [9, 13] - [9, 26]))
declarator: (parenthesized_declarator [9, 26] - [9, 36]
(parenthesized_declarator [9, 27] - [9, 35]
(type_identifier [9, 28] - [9, 34]))))
(compound_statement [9, 37] - [14, 1]
(expression_statement [10, 4] - [13, 26]
(comma_expression [10, 4] - [13, 26]
left: (identifier [10, 4] - [10, 21])
right: (comma_expression [11, 4] - [13, 26]
left: (identifier [11, 4] - [11, 32])
right: (comma_expression [12, 4] - [13, 26]
left: (identifier [12, 4] - [12, 32])
right: (identifier [13, 4] - [13, 26]))))))
(type_identifier [14, 2] - [14, 16])
(comment [16, 0] - [23, 2]))
Expected Behavior/Parse Tree
tree should be like:
(translation_unit [9, 0] - [24, 0]
(type_definition [9, 0] - [14, 17]
type: (enum_specifier [9, 8] - [14, 1]
...
something about __attribute__((packed))
...
body: (enumerator_list [9, 13] - [14, 1]
(enumerator [10, 4] - [10, 21]
name: (identifier [10, 4] - [10, 21]))
(enumerator [11, 4] - [11, 32]
name: (identifier [11, 4] - [11, 32]))
(enumerator [12, 4] - [12, 32]
name: (identifier [12, 4] - [12, 32]))
(enumerator [13, 4] - [13, 26]
name: (identifier [13, 4] - [13, 26]))))
declarator: (type_identifier [14, 2] - [14, 16]))
(comment [16, 0] - [23, 2]))
Repro
// Example code that causes the issue
void foo() {
// Code that fails to parse, or causes an error
}