mojoshader_compiler.c
changeset 843 d557c4336242
parent 842 1ea7f51250fb
child 844 06494572317b
--- a/mojoshader_compiler.c	Sun Feb 21 01:02:34 2010 -0500
+++ b/mojoshader_compiler.c	Sun Feb 21 14:54:54 2010 -0500
@@ -482,6 +482,8 @@
     ErrorList *errors;
     Preprocessor *preprocessor;
     StringBucket *string_hashtable[256];
+    const char *sourcefile;
+    unsigned int sourceline;
     const char *usertypes[512];  // !!! FIXME: dynamic allocation
     int usertype_count;
     CompilationUnit *ast;  // Abstract Syntax Tree
@@ -522,7 +524,7 @@
 {
     // !!! FIXME: placeholder.
     (void) ctx;
-    printf("FAIL: %s\n", str);
+    printf("%s:%u: %s\n", ctx->sourcefile, ctx->sourceline, str);
 } // fail
 
 // These functions are mostly for construction and cleanup of nodes in the
@@ -1787,6 +1789,7 @@
     Token tokenval;
     const char *token;
     int lemon_token;
+    const char *fname;
 
     if (m == NULL) m = MOJOSHADER_internal_malloc;
     if (f == NULL) f = MOJOSHADER_internal_free;
@@ -1816,7 +1819,10 @@
             break;
         } // if
 
-        else if (tokenval == TOKEN_BAD_CHARS)
+        fname = preprocessor_sourcepos(ctx.preprocessor, &ctx.sourceline);
+        ctx.sourcefile = fname ? cache_string(&ctx, fname, strlen(fname)) : 0;
+
+        if (tokenval == TOKEN_BAD_CHARS)
         {
             fail(&ctx, "Bad characters in source file");
             continue;