diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-07-18 10:04:28 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-07-19 14:49:38 +0200 |
commit | 23085895d6c11081c16649107f5a0535671fc658 (patch) | |
tree | e5e373a0fbf241620f4f7c8271bfd074c60d41da /src/libs | |
parent | 61367fc6ab4242aacc8534dd857895afa67cb4d1 (diff) | |
download | qt-creator-23085895d6c11081c16649107f5a0535671fc658.tar.gz |
C++: handle @try statements in the parser.
No semantic analysis yet, but this prevents the parser from generating
bogus diagnostics.
Task-number: QTCREATORBUG-9309
Change-Id: I2ec575a8474cd51bfa97b17678d3da71ab8dcd7a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.cpp | 48 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.h | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 9c6804219b..9a9c9ced78 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -333,6 +333,7 @@ bool Parser::skipUntilStatement() case T_USING: return true; + case T_AT_TRY: case T_AT_SYNCHRONIZED: if (objCEnabled()) return true; @@ -3106,6 +3107,9 @@ bool Parser::parseStatement(StatementAST *&node) return true; } + case T_AT_TRY: + return objCEnabled() && parseObjCTryStatement(node); + case T_AT_SYNCHRONIZED: return objCEnabled() && parseObjCSynchronizedStatement(node); @@ -4404,6 +4408,50 @@ bool Parser::parseObjCStringLiteral(ExpressionAST *&node) return true; } +/// objc-try-catch-statement: +/// @try compound-statement objc-catch-list[opt] +/// @try compound-statement objc-catch-list[opt] @finally compound-statement +/// +/// objc-catch-list: +/// @catch ( parameter-declaration ) compound-statement +/// objc-catch-list @catch ( catch-parameter-declaration ) compound-statement +/// catch-parameter-declaration: +/// parameter-declaration +/// '...' [OBJC2] +/// +bool Parser::parseObjCTryStatement(StatementAST *& /*node*/) +{ + DEBUG_THIS_RULE(); + if (LA() != T_AT_TRY) + return false; + + /*try_token =*/ consumeToken(); + StatementAST *body_statment; + parseCompoundStatement(body_statment); + while (LA() == T_AT_CATCH) { + /*catch_token =*/ consumeToken(); + unsigned lparen_token; + match(T_LPAREN, &lparen_token); + if (LA() == T_DOT_DOT_DOT) { + /*unsigned ellipsis_token =*/ consumeToken(); + } else { + ParameterDeclarationAST *exception_decl; + parseParameterDeclaration(exception_decl); + } + unsigned rparen_token; + match(T_RPAREN, &rparen_token); + StatementAST *catch_statement; + parseCompoundStatement(catch_statement); + } + + if (LA() == T_AT_FINALLY) { + StatementAST *finally_statement; + parseCompoundStatement(finally_statement); + } + + return true; +} + bool Parser::parseObjCSynchronizedStatement(StatementAST *&node) { DEBUG_THIS_RULE(); diff --git a/src/libs/3rdparty/cplusplus/Parser.h b/src/libs/3rdparty/cplusplus/Parser.h index 978b1f99a1..71c3afa11b 100644 --- a/src/libs/3rdparty/cplusplus/Parser.h +++ b/src/libs/3rdparty/cplusplus/Parser.h @@ -222,6 +222,7 @@ public: bool parseObjCProtocol(DeclarationAST *&node, SpecifierListAST *attributes = 0); + bool parseObjCTryStatement(StatementAST *&node); bool parseObjCSynchronizedStatement(StatementAST *&node); bool parseObjCEncodeExpression(ExpressionAST *&node); bool parseObjCProtocolExpression(ExpressionAST *&node); |