Commit 618173e0 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Fixed Q_ENUMS/Q_FLAGS parsing to handle namespaces.

parent 070d06c1
......@@ -1882,17 +1882,49 @@ bool Parser::parseQtEnumDeclaration(DeclarationAST *&node)
QtEnumDeclarationAST *ast = new (_pool) QtEnumDeclarationAST;
ast->enum_specifier_token = consumeToken();
match(T_LPAREN, &ast->lparen_token);
for (NameListAST **iter = &ast->enumerator_list; LA() == T_IDENTIFIER; iter = &(*iter)->next) {
for (NameListAST **iter = &ast->enumerator_list; LA() && LA() != T_RPAREN; iter = &(*iter)->next) {
NameAST *name_ast = 0;
if (!parseEnumName(name_ast))
break;
*iter = new (_pool) NameListAST;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = consumeToken();
(*iter)->value = name;
(*iter)->value = name_ast;
}
match(T_RPAREN, &ast->rparen_token);
node = ast;
return true;
}
bool Parser::parseEnumName(NameAST *&node)
{
DEBUG_THIS_RULE();
unsigned global_scope_token = 0;
if (LA() == T_COLON_COLON)
global_scope_token = consumeToken();
NestedNameSpecifierListAST *nested_name_specifier = 0;
parseNestedNameSpecifierOpt(nested_name_specifier,
/*acceptTemplateId=*/ true);
unsigned identifier_token = 0;
match(T_IDENTIFIER, &identifier_token);
if (global_scope_token == 0 && nested_name_specifier == 0
&& identifier_token == 0)
return false;
SimpleNameAST *name_ast = new (_pool) SimpleNameAST;
name_ast->identifier_token = identifier_token;
if (nested_name_specifier || global_scope_token) {
QualifiedNameAST *q_name_ast = new (_pool) QualifiedNameAST;
q_name_ast->nested_name_specifier_list = nested_name_specifier;
q_name_ast->unqualified_name = name_ast;
q_name_ast->global_scope_token = global_scope_token;
} else {
node = name_ast;
}
return true;
}
// q-flags-decl ::= 'Q_FLAGS' '(' q-flags-list? ')'
// q-flags-list ::= identifier
// q-flags-list ::= q-flags-list identifier
......@@ -1914,11 +1946,12 @@ bool Parser::parseQtFlags(DeclarationAST *&node)
QtFlagsDeclarationAST *ast = new (_pool) QtFlagsDeclarationAST;
ast->flags_specifier_token = consumeToken();
match(T_LPAREN, &ast->lparen_token);
for (NameListAST **iter = &ast->flag_enums_list; LA() == T_IDENTIFIER; iter = &(*iter)->next) {
for (NameListAST **iter = &ast->flag_enums_list; LA() && LA() != T_RPAREN; iter = &(*iter)->next) {
NameAST *name_ast = 0;
if (!parseEnumName(name_ast))
break;
*iter = new (_pool) NameListAST;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = consumeToken();
(*iter)->value = name;
(*iter)->value = name_ast;
}
match(T_RPAREN, &ast->rparen_token);
node = ast;
......
......@@ -80,6 +80,7 @@ public:
bool parseAccessDeclaration(DeclarationAST *&node);
bool parseQtPropertyDeclaration(DeclarationAST *&node);
bool parseQtEnumDeclaration(DeclarationAST *&node);
bool parseEnumName(NameAST *&node);
bool parseQtFlags(DeclarationAST *&node);
bool parseAdditiveExpression(ExpressionAST *&node);
bool parseAndExpression(ExpressionAST *&node);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment