cppparser: hack fix for method defs in parentheses

This commit is contained in:
rdb 2019-10-07 21:42:48 +02:00
parent 0247f9e3fa
commit fb5440bd07
2 changed files with 4313 additions and 4223 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1218,6 +1218,35 @@ constructor_prototype:
CPPInstanceIdentifier *ii = new CPPInstanceIdentifier($1);
ii->add_func_modifier($4, $6);
$$ = new CPPInstance(type, ii, 0, @1.file);
}
/* This is a hack to support functions with the identifier enveloped by a
pair of parentheses. */
| TYPENAME_IDENTIFIER '(' IDENTIFIER ')' '('
{
// Create a scope for this function.
CPPScope *scope = new CPPScope($3->get_scope(current_scope, global_scope),
$3->_names.back(), V_private);
// It still needs to be able to pick up any template arguments, if this is
// a definition for a method template. Add a fake "using" declaration to
// accomplish this.
scope->_using.insert(current_scope);
push_scope(scope);
}
function_parameter_list ')' function_post
{
pop_scope();
CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer);
if (type == nullptr) {
yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1);
}
assert(type != nullptr);
CPPInstanceIdentifier *ii = new CPPInstanceIdentifier($3);
ii->add_func_modifier($7, $9);
$$ = new CPPInstance(type, ii, 0, @1.file);
}
| TYPENAME_IDENTIFIER '('