Print out current source/line number when debugging any parser/lexer.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 06 Mar 2009 22:56:44 -0500
changeset 723 6d58b504cc6e
parent 722 d483a61ef502
child 724 e96f140736f0
Print out current source/line number when debugging any parser/lexer.
mojoshader_preprocessor.c
--- a/mojoshader_preprocessor.c	Fri Mar 06 19:34:06 2009 -0500
+++ b/mojoshader_preprocessor.c	Fri Mar 06 22:56:44 2009 -0500
@@ -27,6 +27,16 @@
 #define preprocessor_lexer(s) debug_preprocessor_lexer(s)
 #endif
 
+#if DEBUG_TOKENIZER
+static void print_debug_lexing_position(IncludeState *s)
+{
+    printf("NOW LEXING %s:%d ...\n", s->filename, s->line);
+} // print_debug_lexing_position
+#else
+#define print_debug_lexing_position(s)
+#endif
+
+
 
 // Simple linked list to cache source filenames, so we don't have to copy
 //  the same string over and over for each opcode.
@@ -569,6 +579,8 @@
     state->next = ctx->include_stack;
     state->asm_comments = ctx->asm_comments;
 
+    print_debug_lexing_position(state);
+
     ctx->include_stack = state;
 
     return 1;
@@ -609,6 +621,9 @@
     } // while
 
     ctx->include_stack = state->next;
+
+    print_debug_lexing_position(ctx->include_stack);
+
     put_include(ctx, state);
 } // pop_source
 
@@ -1835,6 +1850,7 @@
 
         else if (token == ((Token) '\n'))
         {
+            print_debug_lexing_position(state);
             // preprocessor is line-oriented, nothing else gets newlines.
             continue;  // get the next thing.
         } // else if