diff options
author | con <qtc-committer@nokia.com> | 2009-10-26 13:51:56 +0100 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2009-10-26 13:51:56 +0100 |
commit | 441ece365aba579eeb66acb509df466f5029c580 (patch) | |
tree | b4f8ac51e0203bad62c301f0c891b9246a15ad6a /src/shared/cplusplus/Parser.cpp | |
parent | 4504aec7deb2f0abcd6a71e094bbcfb4edd5154d (diff) | |
parent | 3c0ca8c18881bc26fd8946bc2651fa89b10a1329 (diff) | |
download | qt-creator-441ece365aba579eeb66acb509df466f5029c580.tar.gz |
Merge commit 'origin/1.3'
Conflicts:
src/plugins/cpptools/cppcodecompletion.h
src/plugins/debugger/gdb/gdbengine.cpp
src/plugins/qmleditor/QmlEditor.pluginspec
Diffstat (limited to 'src/shared/cplusplus/Parser.cpp')
-rw-r--r-- | src/shared/cplusplus/Parser.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 8f3bd549ce..835b2c11c8 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -88,6 +88,30 @@ int DebugRule::depth = 0; # define DEBUG_THIS_RULE() do {} while (0) #endif +class Parser::Rewind +{ + Parser *_parser; + MemoryPool::State _state; + +public: + inline Rewind(Parser *parser) + : _parser(parser) {} + + inline void operator()(unsigned tokenIndex) + { rewind(tokenIndex); } + + inline void mark() + { _state = _parser->_pool->state(); } + + inline void rewind(unsigned tokenIndex) + { + _parser->rewind(tokenIndex); + + if (_state.isValid()) + _parser->_pool->rewind(_state); + } +}; + Parser::Parser(TranslationUnit *unit) : _translationUnit(unit), _control(_translationUnit->control()), @@ -302,6 +326,9 @@ bool Parser::parseClassOrNamespaceName(NameAST *&node) bool Parser::parseTemplateId(NameAST *&node) { DEBUG_THIS_RULE(); + + const unsigned start = cursor(); + if (LA() == T_IDENTIFIER && LA(2) == T_LESS) { TemplateIdAST *ast = new (_pool) TemplateIdAST; ast->identifier_token = consumeToken(); @@ -315,6 +342,9 @@ bool Parser::parseTemplateId(NameAST *&node) } } } + + rewind(start); + return false; } @@ -660,8 +690,27 @@ bool Parser::parseOperatorFunctionId(NameAST *&node) return true; } +Parser::TemplateArgumentListEntry *Parser::templateArgumentListEntry(unsigned tokenIndex) +{ + for (unsigned i = 0; i < _templateArgumentList.size(); ++i) { + TemplateArgumentListEntry *entry = &_templateArgumentList[i]; + if (entry->index == tokenIndex) + return entry; + } + + return 0; +} + bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) { + if (TemplateArgumentListEntry *entry = templateArgumentListEntry(cursor())) { + rewind(entry->cursor); + node = entry->ast; + return entry->ast != 0; + } + + unsigned start = cursor(); + DEBUG_THIS_RULE(); TemplateArgumentListAST **template_argument_ptr = &node; ExpressionAST *template_argument = 0; @@ -679,8 +728,13 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node) template_argument_ptr = &(*template_argument_ptr)->next; } } + + _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), node)); return true; } + + _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), 0)); + return false; } @@ -4541,6 +4595,7 @@ bool Parser::parseObjCMethodDefinitionList(DeclarationListAST *&node) last->next = new (_pool) ObjCSynthesizedPropertyListAST; last = last->next; + last->synthesized_property = new (_pool) ObjCSynthesizedPropertyAST; match(T_IDENTIFIER, &(last->synthesized_property->property_identifier)); if (LA() == T_EQUAL) { |