-
-
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)
Playground, tree-sitter-c 0.23.4 (Python binding)
Describe the bug
An old style function that returns pointer types will be not parsed as a function_definition. Instead, it is split into a sequence of declarations and a compound_statement. The first parameter declaration is treated as part of the function declarator, and if it is of pointer type, an ERROR node emits.
Steps To Reproduce/Bad Parse Tree
In the Playground, parsing the following code:
int* func(a)
int* a;
{
}
Expected Behavior/Parse Tree
The erroneous parse tree is as follows:
[translation_unit](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 4] - [6, 0]
[declaration](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 4] - [2, 11]
type: [primitive_type](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 4] - [1, 7]
declarator: [pointer_declarator](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 7] - [2, 10]
[*](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 7] - [1, 8]
declarator: [function_declarator](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 9] - [2, 10]
declarator: [identifier](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 9] - [1, 13]
parameters: [parameter_list](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 13] - [1, 16]
[(](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 13] - [1, 14]
[parameter_declaration](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 14] - [1, 15]
type: [type_identifier](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 14] - [1, 15]
[)](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [1, 15] - [1, 16]
[identifier](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [2, 4] - [2, 7]
[ERROR](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [2, 7] - [2, 8]
[*](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [2, 7] - [2, 8]
[identifier](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [2, 9] - [2, 10]
[;](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [2, 10] - [2, 11]
[compound_statement](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [3, 4] - [4, 5]
[{](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [3, 4] - [3, 5]
[}](https://tree-sitter.github.io/tree-sitter/7-playground.html#) [4, 4] - [4, 5]