When parsing string (function arguments):
I see:
a variable Token named "pmsg" is added, but its basetype is "const" which is wrong.
wxString ParserThread::GetTokenBaseType()
{
TRACE(_T("GetTokenBaseType() : Searching within m_Str='%s'"), m_Str.wx_str());
// Compensate for spaces between namespaces (e.g. NAMESPACE :: SomeType)
// which is valid C++ construct.
// Also, spaces that follow a semicolon are removed.
int pos = 0;
while (pos < (int)m_Str.Length())
{
if ( (m_Str.GetChar(pos) == ParserConsts::space_chr)
&& ( ( (pos > 0)
&& (m_Str.GetChar(pos - 1) == ParserConsts::colon_chr) )
|| ( (pos < (int)m_Str.Length() - 1)
&& (m_Str.GetChar(pos + 1) == ParserConsts::colon_chr) ) ) )
{
m_Str.Remove(pos, 1);
}
else
++pos;
}
TRACE(_T("GetTokenBaseType() : Compensated m_Str='%s'"), m_Str.wx_str());
// TODO (Morten#5#): Handle stuff like the following gracefully:
// int __cdecl __MINGW_NOTHROW vscanf (const char * __restrict__, __VALIST);
// m_Str contains the full text before the token's declaration
// an example m_Str value would be: const wxString&
// what we do here is locate the actual return value (wxString in this example)
// it will be needed by code completion code ;)
pos = m_Str.Length() - 1;
// we walk m_Str backwards until we find a non-space character which also is
// not * or &
// const wxString&
// in this example, we would stop here ^
while ( (pos >= 0)
&& ( wxIsspace(m_Str.GetChar(pos))
|| (m_Str.GetChar(pos) == ParserConsts::ptr_chr)
|| (m_Str.GetChar(pos) == ParserConsts::ref_chr)) )
{
--pos;
}
if (pos >= 0)
{
// we have the end of the word we're interested in
int end = pos;
// continue walking backwards until we find the start of the word
// const wxString&
// in this example, we would stop here ^
while ( (pos >= 0)
&& ( wxIsalnum(m_Str.GetChar(pos))
|| (m_Str.GetChar(pos) == ParserConsts::underscore_chr)
|| (m_Str.GetChar(pos) == ParserConsts::colon_chr)) )
{
--pos;
}
TRACE(_T("GetTokenBaseType() : Found '%s'"), m_Str.Mid(pos + 1, end - pos).wx_str());
return m_Str.Mid(pos + 1, end - pos);
}
TRACE(_T("GetTokenBaseType() : Returning '%s'"), m_Str.wx_str());
return m_Str; // token ends at start of phrase
}
For the above function: the input string is "Msg const", but the output string (basetype) is "const", well, this is the reason of bug.