@morten:
Sorry for my poor English explanation. I don't have patch of blueshake included in my package.
@JGM:
Thanks for the encouragement.
The aim of this parser tester project was that all the "TRACE" logs were redirected to a standalone simple App instead of the "Debug Log" panel in the C::B host program. So, when you want to check whether the parsing(which involve the parserthread and tokenizer class) works correctly, you can check these log messages.
parsertest.cbp contains several source directly from the CC's source, in fact, I just add two extra source files. one is "parsertest.cpp" which create a simple GUI window, the other is "parser2.cpp" which is a minimal mimic of the "parser.cpp". All the header files were from CC source.
1, You download the ParsertesterV1.zip package, and extract the files to the "src/plugin/codecompletion/parser" folder, then open the parsertest.cbp.
2, build this project, also, you need to supply a file named "test.cpp" as the source file to be parsed.
3, run the generated APP, You will see, all the "TRACE" message were shown in the ParserTester mainframe.
4, A log.txt will be saved after testing, you can exam it.
Note:
To let the parsertest.cbp build successfully, I have change the Macros in the front of parserthread.cpp and tokenizer.cpp. For example:
In the parserthread.cpp
#ifdef PARSER_TEST
extern void ParserTrace(const wxChar* format, ...);
#define TRACE(format, args...)\
ParserTrace(format , ## args)
#else
#if PARSERTHREAD_DEBUG_OUTPUT
#define TRACE(format, args...)\
Manager::Get()->GetLogManager()->DebugLog(F( format , ## args))
#else
#define TRACE(format, args...)
#endif
#endif
So, the TRACE was replaces by the "ParserTrace" routing, which do the hack. This modification doesn't interrupt building the normal Codecompletion plugin, so the inference to the CC's source is minimal.
Also, this package, I have other improvements in the Tokenizer class.( even you don't have these improvement, you can still compile and build the parsertest.cbp)
one improvement is that I add "handling conditional preprocessor" in the Tokenizer::SkipUnwanted function. so, The first thing we are checking is if the CurrentChar is "#", we need to handle the "#if #else #elif #endif". I comment out these code in Tokenizer::DoGetToken()
// else if (c == '(')
// {
// m_IsOperator = false;
//
// // skip blocks () []
// if (!SkipBlock(CurrentChar()))
// return wxEmptyString;
//
// str = FixArgument(m_Buffer.Mid(start, m_TokenIndex - start));
// CompactSpaces(str);
// }
Because these code snippet never consider the #if like statement in the function argument.
Instead, I add another function called : Tokenizer::DoAdvanceGetToken
wxString Tokenizer::DoAdvanceGetToken()
{
wxString str = DoGetToken();
if ( str == _T("(") )
{
int braceLevel = 1;
wxString temp;
TokenizerState undoTokenizerState;
undoTokenizerState = m_State;
m_State = tsSkipNone;
do
{
temp = DoGetToken();
str << temp;
if ( temp == _T("(") )
{
braceLevel++;
}
else if (temp == _T(")"))
{
braceLevel--;
}
}
while( braceLevel>0 && (!temp.IsEmpty()) );
m_State = undoTokenizerState;
}
return str;
}
This is because the "(" and ")" should always be matched, so we still return a "(XXXX,YYYY)", but the conditional preprocessor code inside the function were stripped.
Here is another improvement, these improvement is only for parsing VC 2008/2005's header file correctly, as I stated in my previous posts.
EditWe have only tested this "parsertest" project under Windows.