glsl/glcpp: Swallow empty #pragma directives.
[mesa.git] / src / glsl / glcpp / glcpp-lex.l
index 2cfe203dacfa367d3ccbd60be4f7874b1b30ea8e..aeaf8abdf8a8851a96f9c2410cec0e090de54d1f 100644 (file)
@@ -250,7 +250,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
        }
 
        /* Single-line comments */
-<INITIAL,DEFINE>"//"[^\r\n]* {
+<INITIAL,DEFINE,HASH>"//"[^\r\n]* {
 }
 
        /* Multi-line comments */
@@ -287,12 +287,16 @@ HEXADECIMAL_INTEGER       0[xX][0-9a-fA-F]+[uU]?
        RETURN_STRING_TOKEN (VERSION_TOKEN);
 }
 
+       /* Swallow empty #pragma directives, (to avoid confusing the
+        * downstream compiler). */
+<HASH>pragma{HSPACE}*/[\r\n] {
+       BEGIN INITIAL;
+}
+
        /* glcpp doesn't handle #extension, #version, or #pragma directives.
         * Simply pass them through to the main compiler's lexer/parser. */
 <HASH>(extension|pragma)[^\r\n]* {
        BEGIN INITIAL;
-       yylineno++;
-       yycolumn = 0;
        RETURN_STRING_TOKEN (PRAGMA);
 }