Author Topic: ptest patches can be more convenient to test parser  (Read 7666 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
ptest patches can be more convenient to test parser
« on: March 21, 2010, 06:58:23 am »
Code
Index: src/plugins/codecompletion/parser/parserthread.cpp

===================================================================

--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6193)

+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)

@@ -21,12 +21,18 @@

 
 #define PARSERTHREAD_DEBUG_OUTPUT 0
 
+#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
 
 int THREAD_START       = wxNewId();
 int THREAD_END         = wxNewId();
@@ -1183,11 +1189,13 @@

         while (!token.IsEmpty() && token != ParserConsts::kw_endif)
             token = m_Tokenizer.GetToken();
         --m_PreprocessorIfCount;
-#if PARSERTHREAD_DEBUG_OUTPUT
+#if PARSERTHREAD_DEBUG_OUTPUT || defined PARSER_TEST
         int l = m_Tokenizer.GetNestingLevel();
 #endif
         m_Tokenizer.RestoreNestingLevel();
+#if PARSERTHREAD_DEBUG_OUTPUT || defined PARSER_TEST
         TRACE(_T("HandlePreprocessorBlocks() : Restoring nesting level: %d (was %d)"), m_Tokenizer.GetNestingLevel(), l);
+#endif
     }
     else if (preproc==ParserConsts::kw_endif) // #endif
         --m_PreprocessorIfCount;
Index: src/plugins/codecompletion/parser/tokenizer.cpp

===================================================================

--- src/plugins/codecompletion/parser/tokenizer.cpp (revision 6193)

+++ src/plugins/codecompletion/parser/tokenizer.cpp (working copy)

@@ -15,15 +15,22 @@

 #include "manager.h"
 #include <cctype>
 #include <globals.h>
+#include "logmanager.h"
 
 #define TOKENIZER_DEBUG_OUTPUT 0
 
+#ifdef PARSER_TEST
+    extern void ParserTrace(const wxChar* format, ...);
+    #define TRACE(format, args...)\
+    ParserTrace(format , ## args)
+#else
 #if TOKENIZER_DEBUG_OUTPUT
     #define TRACE(format, args...)\
     Manager::Get()->GetLogManager()->DebugLog(F( format , ## args))
 #else
     #define TRACE(format, args...)
 #endif
+#endif
 
 namespace TokenizerConsts
 {

Here is the parser test project: http://forums.codeblocks.org/index.php?action=dlattach;topic=12066.0;attach=4335

[attachment deleted by admin]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: ptest patches can be more convenient to test parser
« Reply #1 on: March 21, 2010, 08:04:52 am »
Let me explain more:

This patch can be applied directly to the trunk repo, and does no harm to the standard CC plugin source.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.