-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the varargs ellipsis a named node #31
Comments
The |
Can you provide some info on how to detect this in the tree? I see there's two extra unnamed nodes but not sure how to detect that it is Edit: never mind, figured this out. |
I checked the code that handles variadic arguments, I think it is flawed and won't be simply fixed by giving
commaSep(choice(
$.parameter_declaration,
$.optional_parameter_declaration,
$.variadic_parameter_declaration,
'...'
)),
variadic_parameter_declaration: $ => seq(
$._declaration_specifiers,
field('declarator', choice(
$.variadic_declarator,
alias($.variadic_reference_declarator, $.reference_declarator)
))
), this will result in
variadic_declarator: $ => seq(
'...',
optional($.identifier)
), the some concrete examples: tree-sitter-cpp: void function(..., int a)
{} accept
clang: ./test.cpp:1:6: error: variable has incomplete type 'void'
void function(..., int a)
^
./test.cpp:1:15: error: expected expression
void function(..., int a)
^
./test.cpp:1:24: error: expected '(' for function-style cast or type construction
void function(..., int a)
~~~ ^
./test.cpp:1:26: error: expected ';' after top level declarator
void function(..., int a)
^
;
4 errors generated. tree-sitter-cpp void function(char ... a)
{} accept
clang:
I think this should be labeled as |
No information is provided about the ellipsis in the AST.
AST is:
The text was updated successfully, but these errors were encountered: