diff --git a/CppParser/include/Poco/CppParser/Enum.h b/CppParser/include/Poco/CppParser/Enum.h index d4305c5c1..8b7aad604 100644 --- a/CppParser/include/Poco/CppParser/Enum.h +++ b/CppParser/include/Poco/CppParser/Enum.h @@ -40,7 +40,12 @@ public: typedef std::vector Values; typedef Values::const_iterator Iterator; - Enum(const std::string& name, NameSpace* pNameSpace); + enum Flags + { + ENUM_IS_CLASS = 0x01 // C++11 enum class + }; + + Enum(const std::string& name, NameSpace* pNameSpace, int flags = 0); /// Creates the Enum. /// /// If name is the empty string, an internal name @@ -59,6 +64,8 @@ public: Iterator end() const; /// Returns an iterator for iterating over the Enum's EnumValue's. + int flags() const; + Symbol::Kind kind() const; std::string toString() const; @@ -67,10 +74,20 @@ protected: private: Values _values; + int _flags; static int _count; }; +// +// inlines +// +inline int Enum::flags() const +{ + return _flags; +} + + } } // namespace Poco::CppParser diff --git a/CppParser/src/Enum.cpp b/CppParser/src/Enum.cpp index ec156a15d..8ffb4b42c 100644 --- a/CppParser/src/Enum.cpp +++ b/CppParser/src/Enum.cpp @@ -28,8 +28,9 @@ namespace CppParser { int Enum::_count = 0; -Enum::Enum(const std::string& name, NameSpace* pNameSpace): - Symbol(processName(name), pNameSpace) +Enum::Enum(const std::string& name, NameSpace* pNameSpace, int flags): + Symbol(processName(name), pNameSpace), + _flags(flags) { } diff --git a/CppParser/src/Parser.cpp b/CppParser/src/Parser.cpp index 7ebbdac7a..b01145fe8 100644 --- a/CppParser/src/Parser.cpp +++ b/CppParser/src/Parser.cpp @@ -287,6 +287,7 @@ const Token* Parser::parseClass(const Token* pNext, std::string& decl) else syntaxError("class/struct name"); pNext = next(); + bool isFinal = false; if (isIdentifier(pNext) && pNext->asString() == "final") { @@ -398,6 +399,9 @@ const Token* Parser::parseClassMembers(const Token* pNext, Struct* /*pClass*/) case IdentifierToken::KW_TYPEDEF: pNext = parseTypeDef(pNext); break; + case IdentifierToken::KW_USING: + pNext = parseUsing(pNext); + break; case IdentifierToken::KW_ENUM: pNext = parseEnum(pNext); break; @@ -463,6 +467,8 @@ const Token* Parser::parseTemplateArgs(const Token* pNext, std::string& decl) ++depth; else if (isOperator(pNext, OperatorToken::OP_GT)) --depth; + else if (isOperator(pNext, OperatorToken::OP_SHR)) + depth -= 2; pNext = next(); } return pNext; @@ -483,6 +489,7 @@ const Token* Parser::parseTypeDef(const Token* pNext) } TypeDef* pTypeDef = new TypeDef(decl, currentNameSpace()); addSymbol(pTypeDef, line); + pNext = next(); _pCurrentSymbol = 0; return pNext; @@ -762,6 +769,8 @@ const Token* Parser::parseParameters(const Token* pNext, Function* pFunc) ++tdepth; else if (isOperator(pNext, OperatorToken::OP_GT)) --tdepth; + else if (isOperator(pNext, OperatorToken::OP_SHR)) + tdepth -= 2; pNext = next(); } if (isOperator(pNext, OperatorToken::OP_COMMA)) @@ -795,9 +804,17 @@ const Token* Parser::parseEnum(const Token* pNext) { poco_assert (isKeyword(pNext, IdentifierToken::KW_ENUM)); + int flags = 0; _pCurrentSymbol = 0; int line = _istr.getCurrentLineNumber(); pNext = next(); + + if (isKeyword(pNext, IdentifierToken::KW_CLASS)) + { + flags = Enum::ENUM_IS_CLASS; + pNext = next(); + } + std::string name; if (pNext->is(Token::IDENTIFIER_TOKEN)) { @@ -805,7 +822,7 @@ const Token* Parser::parseEnum(const Token* pNext) pNext = next(); } expectOperator(pNext, OperatorToken::OP_OPENBRACE, "{"); - Enum* pEnum = new Enum(name, currentNameSpace()); + Enum* pEnum = new Enum(name, currentNameSpace(), flags); addSymbol(pEnum, line); pNext = next(); while (pNext->is(Token::IDENTIFIER_TOKEN)) diff --git a/CppParser/src/TypeDef.cpp b/CppParser/src/TypeDef.cpp index b163e66d9..a8d015087 100644 --- a/CppParser/src/TypeDef.cpp +++ b/CppParser/src/TypeDef.cpp @@ -80,6 +80,7 @@ std::string TypeAlias::baseType() const std::string::size_type pos = 0; while (pos < decl.size() && std::isspace(decl[pos])) pos++; while (pos < decl.size() && decl[pos] != '=') pos++; + if (pos < decl.size() && decl[pos] == '=') pos++; decl.erase(0, pos); Poco::trimInPlace(decl); }