summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2010-08-26 12:04:42 +0200
committerRoberto Raggi <roberto.raggi@nokia.com>2010-08-26 12:06:32 +0200
commite3551684eec6f9ff27bb63d29eb7f55e592900d8 (patch)
tree745071bdb8b3f192c9dc93ad886f2251e504e996 /src/shared
parent8c070031df143b2e28195c0833d012d4995a7ff5 (diff)
downloadqt-creator-e3551684eec6f9ff27bb63d29eb7f55e592900d8.tar.gz
Pass the enclosing ClassSpecifierAST node.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/cplusplus/Parser.cpp118
-rw-r--r--src/shared/cplusplus/Parser.h6
2 files changed, 56 insertions, 68 deletions
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp
index c4df234771..4a7dbd62f0 100644
--- a/src/shared/cplusplus/Parser.cpp
+++ b/src/shared/cplusplus/Parser.cpp
@@ -79,7 +79,7 @@ public:
: name(name)
{
for (int i = 0; i <= depth; ++i)
- fputc('-', stderr);
+ fputc('-', stderr);
++depth;
fprintf(stderr, " %s, ahead: '%s' (%d) - block-errors: %d\n", name, spell, idx, blocked);
@@ -501,7 +501,7 @@ bool Parser::parseNestedNameSpecifierOpt(NestedNameSpecifierListAST *&name, bool
bool Parser::parseName(NameAST *&node, bool acceptTemplateId)
{
DEBUG_THIS_RULE();
- unsigned global_scope_token = 0;
+ unsigned global_scope_token = 0;
switch (LA()) {
case T_COLON_COLON:
@@ -923,12 +923,12 @@ bool Parser::parseAsmDefinition(DeclarationAST *&node)
}
} else if (LA() == T_COLON_COLON) {
consumeToken();
- parseAsmOperandList();
+ parseAsmOperandList();
- if (LA() == T_COLON) {
- consumeToken();
- parseAsmClobberList();
- }
+ if (LA() == T_COLON) {
+ consumeToken();
+ parseAsmClobberList();
+ }
}
match(T_RPAREN, &ast->rparen_token);
match(T_SEMICOLON, &ast->semicolon_token);
@@ -1247,7 +1247,7 @@ bool Parser::parseDeclaratorOrAbstractDeclarator(DeclaratorAST *&node, Specifier
return parseAbstractDeclarator(node, decl_specifier_list);
}
-bool Parser::parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, bool declaringClass)
+bool Parser::parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, ClassSpecifierAST *)
{
DEBUG_THIS_RULE();
unsigned start = cursor();
@@ -1304,7 +1304,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
return false;
}
-bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, bool declaringClass)
+bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, ClassSpecifierAST *declaringClass)
{
DEBUG_THIS_RULE();
if (! parseCoreDeclarator(node, decl_specifier_list, declaringClass))
@@ -2299,10 +2299,9 @@ bool Parser::parseEnumerator(EnumeratorListAST *&node)
}
bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list,
- bool declaringClass) // ### rewrite me
+ ClassSpecifierAST *declaringClass) // ### rewrite me
{
DEBUG_THIS_RULE();
- unsigned start = cursor();
if (declaringClass && LA() == T_COLON) {
// anonymous bit-field declaration.
@@ -2318,17 +2317,6 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
consumeToken();
}
-#if 0
- if (declaringClass && node &&
- ! node->postfix_declarator_list &&
- node->core_declarator &&
- node->core_declarator->asNestedDeclarator()) {
- _translationUnit->warning(cursor(), "got here");
- rewind(start);
- return false;
- }
-#endif
-
if (declaringClass && LA() == T_COLON
&& (! node || ! node->postfix_declarator_list)) {
unsigned colon_token = consumeToken();
@@ -2682,7 +2670,7 @@ bool Parser::parseUnqualifiedName(NameAST *&node, bool acceptTemplateId)
if (acceptTemplateId && LA(2) == T_LESS && parseTemplateId(node)) {
if (! _templateArguments || (LA() == T_COMMA || LA() == T_GREATER ||
LA() == T_LPAREN || LA() == T_RPAREN ||
- LA() == T_STAR || LA() == T_AMPER || // ptr-operators
+ LA() == T_STAR || LA() == T_AMPER || // ptr-operators
LA() == T_COLON_COLON))
return true;
}
@@ -2908,7 +2896,7 @@ bool Parser::maybeAmbiguousStatement(DeclarationStatementAST *ast, StatementAST
}
rewind(end);
- (void) blockErrors(blocked);
+ (void) blockErrors(blocked);
return maybeAmbiguous;
}
@@ -2938,42 +2926,42 @@ bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node)
node = as_expression; // well, at least for now.
if (BinaryExpressionAST *binary = expression->asBinaryExpression()) {
- const int binop = _translationUnit->tokenKind(binary->binary_op_token);
- if (binop == T_EQUAL) {
- if (binary->left_expression->asBinaryExpression() != 0) {
- (void) blockErrors(blocked);
- node = as_expression;
- return true;
- }
- }
+ const int binop = _translationUnit->tokenKind(binary->binary_op_token);
+ if (binop == T_EQUAL) {
+ if (binary->left_expression->asBinaryExpression() != 0) {
+ (void) blockErrors(blocked);
+ node = as_expression;
+ return true;
+ }
+ }
} else if (CallAST *call = expression->asCall()) {
- if (call->base_expression->asIdExpression() != 0) {
- (void) blockErrors(blocked);
- node = as_expression;
- return true;
- }
+ if (call->base_expression->asIdExpression() != 0) {
+ (void) blockErrors(blocked);
+ node = as_expression;
+ return true;
+ }
}
rewind(start);
DeclarationAST *declaration = 0;
if (parseSimpleDeclaration(declaration)) {
- SimpleDeclarationAST *simple = declaration->asSimpleDeclaration();
- if (simple->semicolon_token == semicolon_token && simple->decl_specifier_list && simple->declarator_list) {
- DeclarationStatementAST *as_declaration = new (_pool) DeclarationStatementAST;
- as_declaration->declaration = declaration;
-
- if (simple->decl_specifier_list != 0 && simple->declarator_list != 0) {
- node = as_declaration;
- (void) blockErrors(blocked);
- return true;
- }
-
- ExpressionOrDeclarationStatementAST *ast = new (_pool) ExpressionOrDeclarationStatementAST;
- ast->declaration = as_declaration;
- ast->expression = as_expression;
- node = ast;
- }
+ SimpleDeclarationAST *simple = declaration->asSimpleDeclaration();
+ if (simple->semicolon_token == semicolon_token && simple->decl_specifier_list && simple->declarator_list) {
+ DeclarationStatementAST *as_declaration = new (_pool) DeclarationStatementAST;
+ as_declaration->declaration = declaration;
+
+ if (simple->decl_specifier_list != 0 && simple->declarator_list != 0) {
+ node = as_declaration;
+ (void) blockErrors(blocked);
+ return true;
+ }
+
+ ExpressionOrDeclarationStatementAST *ast = new (_pool) ExpressionOrDeclarationStatementAST;
+ ast->declaration = as_declaration;
+ ast->expression = as_expression;
+ node = ast;
+ }
}
rewind(semicolon_token + 1);
(void) blockErrors(blocked);
@@ -3008,11 +2996,11 @@ bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node)
if (DeclarationStatementAST *as_declaration = node->asDeclarationStatement()) {
StatementAST *as_expression = 0;
if (maybeAmbiguousStatement(as_declaration, as_expression)) {
- // it's an ambiguous expression-or-declaration statement.
- ExpressionOrDeclarationStatementAST *ast = new (_pool) ExpressionOrDeclarationStatementAST;
- ast->declaration = as_declaration;
- ast->expression = as_expression;
- node = ast;
+ // it's an ambiguous expression-or-declaration statement.
+ ExpressionOrDeclarationStatementAST *ast = new (_pool) ExpressionOrDeclarationStatementAST;
+ ast->declaration = as_declaration;
+ ast->expression = as_expression;
+ node = ast;
}
}
}
@@ -3093,7 +3081,7 @@ bool Parser::parseForeachStatement(StatementAST *&node)
bool blocked = blockErrors(true);
if (parseTypeSpecifier(ast->type_specifier_list))
- parseDeclarator(ast->declarator, ast->type_specifier_list);
+ parseDeclarator(ast->declarator, ast->type_specifier_list);
if (! ast->type_specifier_list || ! ast->declarator) {
ast->type_specifier_list = 0;
@@ -3136,7 +3124,7 @@ bool Parser::parseForStatement(StatementAST *&node)
ast->lparen_token = lparen_token;
if (parseTypeSpecifier(ast->type_specifier_list))
- parseDeclarator(ast->declarator, ast->type_specifier_list);
+ parseDeclarator(ast->declarator, ast->type_specifier_list);
if ((ast->type_specifier_list || ast->declarator) && !peekAtObjCContextKeyword(Token_in)) {
// woops, probably parsed too much: "in" got parsed as a declarator. Let's redo it:
@@ -3553,11 +3541,11 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node, ClassSpecifierAST *de
startOfNamedTypeSpecifier = cursor();
if (parseName(named_type_specifier)) {
- if (LA() == T_LPAREN && identifier(named_type_specifier) == className(declaringClass)) {
- // looks like a constructor declaration
- rewind(startOfNamedTypeSpecifier);
- break;
- }
+ if (LA() == T_LPAREN && identifier(named_type_specifier) == className(declaringClass)) {
+ // looks like a constructor declaration
+ rewind(startOfNamedTypeSpecifier);
+ break;
+ }
NamedTypeSpecifierAST *spec = new (_pool) NamedTypeSpecifierAST;
diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h
index d5e0257f19..60c9defb5d 100644
--- a/src/shared/cplusplus/Parser.h
+++ b/src/shared/cplusplus/Parser.h
@@ -114,8 +114,8 @@ public:
bool parseDeclaration(DeclarationAST *&node);
bool parseSimpleDeclaration(DeclarationAST *&node, ClassSpecifierAST *declaringClass = 0);
bool parseDeclarationStatement(StatementAST *&node);
- bool parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, bool declaringClass);
- bool parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, bool declaringClass = false);
+ bool parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, ClassSpecifierAST *declaringClass);
+ bool parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, ClassSpecifierAST *declaringClass = 0);
bool parseDeleteExpression(ExpressionAST *&node);
bool parseDoStatement(StatementAST *&node);
bool parseElaboratedTypeSpecifier(SpecifierListAST *&node);
@@ -134,7 +134,7 @@ public:
bool parseFunctionBody(StatementAST *&node);
bool parseIfStatement(StatementAST *&node);
bool parseInclusiveOrExpression(ExpressionAST *&node);
- bool parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, bool declaringClass);
+ bool parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, ClassSpecifierAST *declaringClass);
bool parseInitializerList(ExpressionListAST *&node);
bool parseInitializer(ExpressionAST *&node, unsigned *equals_token);
bool parseInitializerClause(ExpressionAST *&node);