mojoshader_preprocessor.c
changeset 723 6d58b504cc6e
parent 701 08e5a289abad
child 727 6978fac0fa31
equal deleted inserted replaced
722:d483a61ef502 723:6d58b504cc6e
    24     MOJOSHADER_print_debug_token("LEXER", s->token, s->tokenlen, retval);
    24     MOJOSHADER_print_debug_token("LEXER", s->token, s->tokenlen, retval);
    25     return retval;
    25     return retval;
    26 } // debug_preprocessor_lexer
    26 } // debug_preprocessor_lexer
    27 #define preprocessor_lexer(s) debug_preprocessor_lexer(s)
    27 #define preprocessor_lexer(s) debug_preprocessor_lexer(s)
    28 #endif
    28 #endif
       
    29 
       
    30 #if DEBUG_TOKENIZER
       
    31 static void print_debug_lexing_position(IncludeState *s)
       
    32 {
       
    33     printf("NOW LEXING %s:%d ...\n", s->filename, s->line);
       
    34 } // print_debug_lexing_position
       
    35 #else
       
    36 #define print_debug_lexing_position(s)
       
    37 #endif
       
    38 
    29 
    39 
    30 
    40 
    31 // Simple linked list to cache source filenames, so we don't have to copy
    41 // Simple linked list to cache source filenames, so we don't have to copy
    32 //  the same string over and over for each opcode.
    42 //  the same string over and over for each opcode.
    33 typedef struct FilenameCache
    43 typedef struct FilenameCache
   567     state->line = linenum;
   577     state->line = linenum;
   568     state->defines = defs;
   578     state->defines = defs;
   569     state->next = ctx->include_stack;
   579     state->next = ctx->include_stack;
   570     state->asm_comments = ctx->asm_comments;
   580     state->asm_comments = ctx->asm_comments;
   571 
   581 
       
   582     print_debug_lexing_position(state);
       
   583 
   572     ctx->include_stack = state;
   584     ctx->include_stack = state;
   573 
   585 
   574     return 1;
   586     return 1;
   575 } // push_source
   587 } // push_source
   576 
   588 
   607         free_define(ctx, def);
   619         free_define(ctx, def);
   608         def = next;
   620         def = next;
   609     } // while
   621     } // while
   610 
   622 
   611     ctx->include_stack = state->next;
   623     ctx->include_stack = state->next;
       
   624 
       
   625     print_debug_lexing_position(ctx->include_stack);
       
   626 
   612     put_include(ctx, state);
   627     put_include(ctx, state);
   613 } // pop_source
   628 } // pop_source
   614 
   629 
   615 
   630 
   616 static void close_define_include(const char *data, MOJOSHADER_malloc m,
   631 static void close_define_include(const char *data, MOJOSHADER_malloc m,
  1833                 continue;  // pushed the include_stack.
  1848                 continue;  // pushed the include_stack.
  1834         } // else if
  1849         } // else if
  1835 
  1850 
  1836         else if (token == ((Token) '\n'))
  1851         else if (token == ((Token) '\n'))
  1837         {
  1852         {
       
  1853             print_debug_lexing_position(state);
  1838             // preprocessor is line-oriented, nothing else gets newlines.
  1854             // preprocessor is line-oriented, nothing else gets newlines.
  1839             continue;  // get the next thing.
  1855             continue;  // get the next thing.
  1840         } // else if
  1856         } // else if
  1841 
  1857 
  1842         assert(!skipping);
  1858         assert(!skipping);