if (token == ParserConsts::kw_template)
{
// There are some template defintions that are not working like
// within gcc headers (NB: This syntax is a GNU extension):
// extern template
// const codecvt<char, char, mbstate_t>&
// use_facet<codecvt<char, char, mbstate_t> >(const locale&);
m_Tokenizer.SetState(tsTemplateArgument);
wxString args = m_Tokenizer.GetToken();
token = m_Tokenizer.GetToken();
TRACE(_T("DoParse() : Template argument='%s', token ='%s'"), args.wx_str(), token.wx_str());
if (token==ParserConsts::kw_class)
{
m_Str.Clear();
if (m_Options.handleClasses)
HandleClass(ctClass, args);
else
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
else if (token==ParserConsts::kw_struct)
{
m_Str.Clear();
if (m_Options.handleClasses)
HandleClass(ctStructure, args);
else
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
else
{
SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
}
}
We should rethink the code above, for example, there are some template declaration like below:
template<typename _CharT, typename _Traits, typename _Alloc>
inline bool
operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
{ return __lhs.compare(__rhs) <= 0; }
at this time, the "token string" behind the template argument is not "class" nor "struct", but a general function declaration. So, I think we should use a variable like "template argument" to specify the current context".
For example:
When the parser eat these strings "template<typename _CharT, typename _Traits, typename _Alloc>", we can set the variable "template argument", then we continue our DoParse Loop. next we add a Token, we should attach this "template argument" context to the Token. So, This variable is just like other variables like: m_Str( store the type information) or m_EncounteredTypeNamespaces (store the namespace in data types).
Any way, checking the next token after the template argument is not a correct way.