codes like this can not be parsed .SubCls1,SubCls2 can not be recognized .
#include <iostream>
#include <map>
using namespace std;
typedef class MyClass
{
int x;
int y;
}SubCls1,SubCls2;
int main()
{
SubCls1 cls;
cout << "Hello world!" << endl;
return 0;
}
here is the patch.
Index: parserthread.cpp
===================================================================
--- parserthread.cpp (revision 5696)
+++ parserthread.cpp (working copy)
@@ -1256,12 +1256,19 @@
// no vars are defined on a typedef, only types
// In the former example, aa is not part of the typedef.
if (m_ParsingTypedef)
+ {
+ m_Str.Clear();
+ ReadClsNames(newToken->m_Name);
+// m_ParsingTypedef = false;
break;
-
- m_Str = newToken->m_Name;
- ReadVarNames();
- m_Str.Clear();
- break;
+ }
+ else
+ {
+ m_Str = newToken->m_Name;
+ ReadVarNames();
+ m_Str.Clear();
+ break;
+ }
}
else if (next==ParserConsts::opbrace)
{
@@ -1295,12 +1302,19 @@
// no vars are defined on a typedef, only types
// In the former example, aa is not part of the typedef.
if (m_ParsingTypedef)
+ {
+ m_Str.Clear();
+ ReadClsNames(newToken->m_Name);
+// m_ParsingTypedef = false;
break;
-
- m_Str = newToken->m_Name;
- ReadVarNames();
- m_Str.Clear();
- break;
+ }
+ else
+ {
+ m_Str = newToken->m_Name;
+ ReadVarNames();
+ m_Str.Clear();
+ break;
+ }
}
else if (next==ParserConsts::semicolon) // forward decl; we don't care
break;
@@ -1719,3 +1735,36 @@
tdef->m_ActualType = ancestor + args;
}
}
+void ParserThread::ReadClsNames(wxString& ancestor)
+{
+ while (1)
+ {
+ wxString current = m_Tokenizer.GetToken();
+
+ if (current.IsEmpty())
+ break;
+ if (current==ParserConsts::comma)
+ continue;
+ else if (current==ParserConsts::semicolon)
+ {
+ m_Tokenizer.UngetToken();
+ break;
+ }
+ else if (wxIsalpha(current.GetChar(0)))
+ {
+// if ( m_Filename == _T("F:\\fortest\\main.cpp"))
+// Manager::Get()->GetLogManager()->DebugLog(F(_T("Adding variable '%s' as '%s' to '%s'"), current.c_str(), m_Str.c_str(), (m_pLastParent?m_pLastParent->m_Name.c_str():_T("<no-parent>"))));
+ Token* newToken = DoAddToken(tkClass, current, m_Tokenizer.GetLineNumber());
+ if (!newToken)
+ break;
+ else
+ {
+ wxString tempAncestor = ancestor;
+ newToken->m_AncestorsString = tempAncestor;
+ }
+
+ }
+ else // unexpected
+ break;
+ }
+}
Index: parserthread.h
===================================================================
--- parserthread.h (revision 5696)
+++ parserthread.h (working copy)
@@ -89,6 +89,7 @@
void HandlePreprocessorBlocks(const wxString& preproc);
void HandleNamespace();
void ReadVarNames();
+ void ReadClsNames(wxString& ancestor);
void HandleClass(EClassType ct);
void HandleFunction(const wxString& name, bool isOperator = false);
void HandleEnum();
by the way ,Ihave not test it completely .welcome to test and report bugs .
[attachment deleted by admin]