Allow debug output directly from the lexer, before preprocessor eats.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 15 Feb 2009 02:49:40 -0500
changeset 630 e6bd53dd1f91
parent 629 d886403c6609
child 631 5045dcc9fdaf
Allow debug output directly from the lexer, before preprocessor eats.
mojoshader_internal.h
mojoshader_preprocessor.c
--- a/mojoshader_internal.h	Sun Feb 15 02:46:08 2009 -0500
+++ b/mojoshader_internal.h	Sun Feb 15 02:49:40 2009 -0500
@@ -19,9 +19,11 @@
 
 #include "mojoshader.h"
 
+#define DEBUG_LEXER 0
 #define DEBUG_PREPROCESSOR 0
 #define DEBUG_ASSEMBLY_PARSER 0
-#define DEBUG_TOKENIZER ((DEBUG_PREPROCESSOR) || (DEBUG_ASSEMBLY_PARSER))
+#define DEBUG_TOKENIZER \
+    (DEBUG_PREPROCESSOR || DEBUG_ASSEMBLY_PARSER || DEBUG_LEXER)
 
 #if (defined(__APPLE__) && defined(__MACH__))
 #define PLATFORM_MACOSX 1
--- a/mojoshader_preprocessor.c	Sun Feb 15 02:46:08 2009 -0500
+++ b/mojoshader_preprocessor.c	Sun Feb 15 02:49:40 2009 -0500
@@ -17,6 +17,18 @@
     #define print_debug_token(token, len, val)
 #endif
 
+#if DEBUG_LEXER
+static Token debug_preprocessor_internal_lexer(IncludeState *s)
+{
+    const Token retval = preprocessor_internal_lexer(s);
+    MOJOSHADER_print_debug_token("LEXER", s->token,
+                                 (unsigned int) (s->source - s->token),
+                                 retval);
+    return retval;
+} // debug_preprocessor_internal_lexer
+#define preprocessor_internal_lexer(s) debug_preprocessor_internal_lexer(s)
+#endif
+
 typedef struct DefineHash
 {
     MOJOSHADER_preprocessorDefine define;