Skip to content

Commit

Permalink
Ignore variadic template parameters
Browse files Browse the repository at this point in the history
- ignore default template parameters
  • Loading branch information
mrbean-bremen authored and usiems committed Nov 9, 2023
1 parent 1ccf493 commit 7be0dd9
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion generator/parser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ bool Parser::parseDeclaration(DeclarationAST *&node)
switch(token_stream.lookAhead())
{
case ';':
// ignore ellipse in constructs like
// using T1 = T2<f<Args>...>;
case Token_ellipsis:
nextToken();
return true;

Expand Down Expand Up @@ -1543,6 +1546,17 @@ bool Parser::parseTemplateParameterList(const ListNode<TemplateParameterAST*> *&
}
}

if (token_stream.lookAhead() == Token_ellipsis)
{
// ignore variadic template parameters as in
// template<class Tuple, std::size_t... I>
token_stream.nextToken();
if (token_stream.lookAhead() == Token_identifier)
{
token_stream.nextToken();
}
}

return true;
}

Expand All @@ -1556,7 +1570,13 @@ bool Parser::parseTemplateParameter(TemplateParameterAST *&node)
if ((tk == Token_class || tk == Token_typename || tk == Token_template)
&& parseTypeParameter(ast->type_parameter))
{
// nothing to do
if (token_stream.lookAhead() == '=' || token_stream.lookAhead() == Token_assign)
{
// default template parameter
token_stream.nextToken();
TypeSpecifierAST* typeNode = 0;
parseTypeSpecifier(typeNode);
}
}
else if (!parseParameterDeclaration(ast->parameter_declaration))
return false;
Expand All @@ -1581,6 +1601,12 @@ bool Parser::parseTypeParameter(TypeParameterAST *&node)
{
nextToken(); // skip class

if (token_stream.lookAhead() == Token_ellipsis)
{
// skip variadic parameters in template parameter list
nextToken();
}

// parse optional name
if(parseName(ast->name, true))
{
Expand Down Expand Up @@ -2252,6 +2278,13 @@ bool Parser::parseInitDeclarator(InitDeclaratorAST *&node)
{
std::size_t start = token_stream.cursor();

if (token_stream.lookAhead(0) == Token_ellipsis)
{
// for now just ignore variadic parameters
token_stream.nextToken();
return true;
}

DeclaratorAST *decl = 0;
if (!parseDeclarator(decl))
{
Expand Down

0 comments on commit 7be0dd9

Please sign in to comment.