glcpp: Add #error support.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 2 Jul 2010 22:31:26 +0000 (15:31 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 3 Jul 2010 01:03:58 +0000 (18:03 -0700)
src/glsl/glcpp/glcpp-lex.l

index afddd7ddb321e4c7bac6310aea44e0b1236da257..6a91b09954a65b6963b2ea9fb4cc68916db0f186 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "glcpp.h"
 #include "glcpp-parse.h"
@@ -139,6 +140,13 @@ HEXADECIMAL_INTEGER        0[xX][0-9a-fA-F]+[uU]?
        }
 }
 
+{HASH}error.* {
+       char *p;
+       for (p = yytext; !isalpha(p[0]); p++); /* skip "  #   " */
+       p += 5; /* skip "error" */
+       glcpp_error(yylloc, yyextra, "#error%s", p);
+}
+
 {HASH}define{HSPACE}+/{IDENTIFIER}"(" {
        yyextra->space_tokens = 0;
        return HASH_DEFINE_FUNC;