-
-
Notifications
You must be signed in to change notification settings - Fork 183
Open
Labels
Description
Did you check the tree-sitter docs?
- I have read all the tree-sitter docs if it relates to using the parser
Is your feature request related to a problem? Please describe.
Hello,
I tried to implement support for the "typeof" C23 feature.
The following snippet of code is valid:
typeof(int) a;
However it raises an error when parsed with the tree-sitter-c grammar.
Describe the solution you'd like
I tried to add the following line in the grammar.js file, in type_specifier:
$.typeof_specifier,
And later in that same file I added:
typeof_specifier: $ => seq(
choice('__typeof', '__typeof__'),
'(',
choice($.expression, $.type_descriptor),
')',
),
Unfortunately this is not enough: The grammar still parses the line above as a function declaration, and obviously it fails and produces an ERROR node.
How can I force the parsing of a typeof(x) as a type_specifier instead of a function declaration?
Thanks.
Describe alternatives you've considered
None considered.
Additional context
No response
Reactions are currently unavailable