Closed genotrance closed 6 years ago
Seems this way for function declarations too:
const char * Soloud_getErrorString(Soloud * aSoloud, int aErrorCode);
(declaration 4156 4225
(type_qualifier 4156 4161)
(primitive_type 4162 4166)
(pointer_declarator 4167 4224
(function_declarator 4169 4224
(identifier 4169 4190)
(parameter_list 4190 4224
(parameter_declaration 4191 4207
(type_identifier 4191 4197)
(pointer_declarator 4198 4207
(identifier 4200 4207)
)
)
(parameter_declaration 4209 4223
(primitive_type 4209 4212)
(identifier 4213 4223)
)
)
)
)
)
Just want to confirm the rationale for such a structure before I look into utilizing it.
Yeah, that's the correct structure for a C AST. Conceptually, the *
operator is attached to the variable being declared, it's not attached to the type. This is somewhat unique to the C family of languages.
Consider these examples:
int *a, *b; // a and b are both pointers
int (*a), (*b); // same as above
typedef void *A; // A is a void pointer
typedef void (*A); // same as above
One good overview of how these "declarators" work in C is here: https://msdn.microsoft.com/en-us/library/tb971bed.aspx.
Thank you for clarifying. I'll proceed accordingly.
Results in:
Instead of grouping
void *
together, tree-sitter groups* Bus
together instead.I would have expected: