-/*
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-*/
-/* Based on
-ANSI C grammar, Lex specification
-
-In 1985, Jeff Lee published this Lex specification together with a Yacc
-grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted
-both to net.sources in 1987; that original, as mentioned in the answer
-to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net,
-file usenet/net.sources/ansi.c.grammar.Z.
-
-I intend to keep this version as close to the current C Standard grammar
-as possible; please let me know if you discover discrepancies.
-
-Jutta Degener, 1995
-*/
-
-D [0-9]
-L [a-zA-Z_]
-H [a-fA-F0-9]
-E [Ee][+-]?{D}+
-O [0-7]
-U [uU]
-
-/* TODO: double literals, which will likely require pre-processor rework */
-/* TODO: unsigned int literals, which will likely require pre-processor rework */
-
-%option nounput
-%{
-#include <stdio.h>
-#include <stdlib.h>
-#include "ParseHelper.h"
-#include "glslang_tab.cpp.h"
-
-/* windows only pragma */
-#ifdef _MSC_VER
-#pragma warning(disable : 4102)
-#endif
-
-int yy_input(char* buf, int max_size);
-TSourceLoc yylineno;
-
-#ifdef _WIN32
- extern int yyparse(TParseContext&);
- #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
-#else
- extern int yyparse(void*);
- #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
- #define parseContext (*((TParseContext*)(parseContextLocal)))
-#endif
-
-#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))
-
-%}
-
-%option noyywrap
-%option never-interactive
-%option outfile="gen_glslang.cpp"
-%x FIELDS
-
-
-%%
-<*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ };
-
-"attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); }
-"const" { pyylval->lex.line = yylineno; return(CONST); }
-"patch" { pyylval->lex.line = yylineno; return(PATCH); }
-"sample" { pyylval->lex.line = yylineno; return(SAMPLE); }
-"uniform" { pyylval->lex.line = yylineno; return(UNIFORM); }
-"buffer" { pyylval->lex.line = yylineno; return(BUFFER); }
-"shared" { pyylval->lex.line = yylineno; return(SHARED); }
-"coherent" { pyylval->lex.line = yylineno; return(COHERENT); }
-"volatile" { pyylval->lex.line = yylineno; return(VOLATILE); }
-"restrict" { pyylval->lex.line = yylineno; return(RESTRICT); }
-"readonly" { pyylval->lex.line = yylineno; return(READONLY); }
-"writeonly" { pyylval->lex.line = yylineno; return(WRITEONLY); }
-"varying" { pyylval->lex.line = yylineno; return(VARYING); }
-"layout" { pyylval->lex.line = yylineno; return(LAYOUT); }
-
-"break" { pyylval->lex.line = yylineno; return(BREAK); }
-"continue" { pyylval->lex.line = yylineno; return(CONTINUE); }
-"do" { pyylval->lex.line = yylineno; return(DO); }
-"for" { pyylval->lex.line = yylineno; return(FOR); }
-"while" { pyylval->lex.line = yylineno; return(WHILE); }
-"switch" { pyylval->lex.line = yylineno; return(SWITCH); }
-"case" { pyylval->lex.line = yylineno; return(CASE); }
-"default" { pyylval->lex.line = yylineno; return(DEFAULT); }
-
-"if" { pyylval->lex.line = yylineno; return(IF); }
-"else" { pyylval->lex.line = yylineno; return(ELSE); }
-
-"in" { pyylval->lex.line = yylineno; return(IN); }
-"out" { pyylval->lex.line = yylineno; return(OUT); }
-"inout" { pyylval->lex.line = yylineno; return(INOUT); }
-"centroid" { pyylval->lex.line = yylineno; return(CENTROID); }
-"noperspective" { pyylval->lex.line = yylineno; return(NOPERSPECTIVE); }
-"flat" { pyylval->lex.line = yylineno; return(FLAT); }
-"smooth" { pyylval->lex.line = yylineno; return(SMOOTH); }
-
-"precise" { pyylval->lex.line = yylineno; return(PRECISE); }
-"invariant" { pyylval->lex.line = yylineno; return(INVARIANT); }
-
-"precision" { pyylval->lex.line = yylineno; return(PRECISION); }
-"highp" { pyylval->lex.line = yylineno; return(HIGH_PRECISION); }
-"mediump" { pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); }
-"lowp" { pyylval->lex.line = yylineno; return(LOW_PRECISION); }
-
-"float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT); }
-"double" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DOUBLE); }
-"int" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT); }
-"uint" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(UINT); }
-"void" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID); }
-"bool" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL); }
-"true" { pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); }
-"false" { pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }
-
-"discard" { pyylval->lex.line = yylineno; return(DISCARD); }
-"return" { pyylval->lex.line = yylineno; return(RETURN); }
-"subroutine" { pyylval->lex.line = yylineno; return(SUBROUTINE); }
-
-"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2); }
-"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3); }
-"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT4); }
+/*\r
+//\r
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
+//All rights reserved.\r
+//\r
+//Redistribution and use in source and binary forms, with or without\r
+//modification, are permitted provided that the following conditions\r
+//are met:\r
+//\r
+// Redistributions of source code must retain the above copyright\r
+// notice, this list of conditions and the following disclaimer.\r
+//\r
+// Redistributions in binary form must reproduce the above\r
+// copyright notice, this list of conditions and the following\r
+// disclaimer in the documentation and/or other materials provided\r
+// with the distribution.\r
+//\r
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
+// contributors may be used to endorse or promote products derived\r
+// from this software without specific prior written permission.\r
+//\r
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+//POSSIBILITY OF SUCH DAMAGE.\r
+//\r
+*/\r
+/* Based on\r
+ANSI C grammar, Lex specification\r
+\r
+In 1985, Jeff Lee published this Lex specification together with a Yacc \r
+grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted \r
+both to net.sources in 1987; that original, as mentioned in the answer \r
+to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net, \r
+file usenet/net.sources/ansi.c.grammar.Z. \r
+\r
+I intend to keep this version as close to the current C Standard grammar \r
+as possible; please let me know if you discover discrepancies. \r
+\r
+Jutta Degener, 1995 \r
+*/\r
+\r
+D [0-9]\r
+L [a-zA-Z_]\r
+H [a-fA-F0-9]\r
+E [Ee][+-]?{D}+\r
+O [0-7]\r
+U [uU]\r
+F [fF]\r
+LF [lL][fF]\r
+\r
+/* TODO: double literals, which will likely require pre-processor rework */\r
+/* TODO: unsigned int literals, which will likely require pre-processor rework */\r
+\r
+%option nounput \r
+%{\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include "ParseHelper.h"\r
+#include "glslang_tab.cpp.h"\r
+\r
+/* windows only pragma */\r
+#ifdef _MSC_VER\r
+#pragma warning(disable : 4102)\r
+#endif\r
+\r
+int yy_input(char* buf, int max_size);\r
+TSourceLoc yylineno;\r
+\r
+#ifdef _WIN32\r
+ extern int yyparse(TParseContext&);\r
+ #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext) \r
+#else\r
+ extern int yyparse(void*);\r
+ #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)\r
+ #define parseContext (*((TParseContext*)(parseContextLocal))) \r
+#endif\r
+ \r
+#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))\r
+\r
+%}\r
+\r
+%option noyywrap\r
+%option never-interactive\r
+%option outfile="gen_glslang.cpp"\r
+%x FIELDS\r
+\r
+\r
+%%\r
+<*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ };\r
+\r
+"attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); }\r
+"const" { pyylval->lex.line = yylineno; return(CONST); }\r
+"patch" { pyylval->lex.line = yylineno; return(PATCH); }\r
+"sample" { pyylval->lex.line = yylineno; return(SAMPLE); }\r
+"uniform" { pyylval->lex.line = yylineno; return(UNIFORM); }\r
+"buffer" { pyylval->lex.line = yylineno; return(BUFFER); }\r
+"shared" { pyylval->lex.line = yylineno; return(SHARED); }\r
+"coherent" { pyylval->lex.line = yylineno; return(COHERENT); }\r
+"volatile" { pyylval->lex.line = yylineno; return(VOLATILE); }\r
+"restrict" { pyylval->lex.line = yylineno; return(RESTRICT); }\r
+"readonly" { pyylval->lex.line = yylineno; return(READONLY); }\r
+"writeonly" { pyylval->lex.line = yylineno; return(WRITEONLY); }\r
+"varying" { pyylval->lex.line = yylineno; return(VARYING); }\r
+"layout" { pyylval->lex.line = yylineno; return(LAYOUT); }\r
+\r
+"break" { pyylval->lex.line = yylineno; return(BREAK); }\r
+"continue" { pyylval->lex.line = yylineno; return(CONTINUE); }\r
+"do" { pyylval->lex.line = yylineno; return(DO); }\r
+"for" { pyylval->lex.line = yylineno; return(FOR); }\r
+"while" { pyylval->lex.line = yylineno; return(WHILE); }\r
+"switch" { pyylval->lex.line = yylineno; return(SWITCH); }\r
+"case" { pyylval->lex.line = yylineno; return(CASE); }\r
+"default" { pyylval->lex.line = yylineno; return(DEFAULT); }\r
+\r
+"if" { pyylval->lex.line = yylineno; return(IF); }\r
+"else" { pyylval->lex.line = yylineno; return(ELSE); }\r
+\r
+"in" { pyylval->lex.line = yylineno; return(IN); }\r
+"out" { pyylval->lex.line = yylineno; return(OUT); }\r
+"inout" { pyylval->lex.line = yylineno; return(INOUT); }\r
+"centroid" { pyylval->lex.line = yylineno; return(CENTROID); }\r
+"noperspective" { pyylval->lex.line = yylineno; return(NOPERSPECTIVE); }\r
+"flat" { pyylval->lex.line = yylineno; return(FLAT); }\r
+"smooth" { pyylval->lex.line = yylineno; return(SMOOTH); }\r
+\r
+"precise" { pyylval->lex.line = yylineno; return(PRECISE); }\r
+"invariant" { pyylval->lex.line = yylineno; return(INVARIANT); }\r
+\r
+"precision" { pyylval->lex.line = yylineno; return(PRECISION); }\r
+"highp" { pyylval->lex.line = yylineno; return(HIGH_PRECISION); }\r
+"mediump" { pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); }\r
+"lowp" { pyylval->lex.line = yylineno; return(LOW_PRECISION); }\r
+\r
+"float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT); }\r
+"double" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DOUBLE); }\r
+"int" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT); }\r
+"uint" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(UINT); }\r
+"void" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID); }\r
+"bool" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL); }\r
+"true" { pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); }\r
+"false" { pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }\r
+\r
+"discard" { pyylval->lex.line = yylineno; return(DISCARD); }\r
+"return" { pyylval->lex.line = yylineno; return(RETURN); }\r
+"subroutine" { pyylval->lex.line = yylineno; return(SUBROUTINE); }\r
+\r
+"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2); }\r
+"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3); }\r
+"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT4); }\r
\r
"mat2x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X2); }\r
"mat2x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X3); }\r
"dmat4x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X3); }\r
"dmat4x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X4); }\r
"atomic_uint" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(ATOMIC_UINT); }\r
-
-"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }
-"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }
-"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }
-"dvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC2); }
-"dvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC3); }
-"dvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC4); }
-"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }
-"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }
-"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }
-"uvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC2); }
-"uvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC3); }
-"uvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC4); }
-"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }
-"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }
-"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }
-
-"sampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; }
-"sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }
-"sampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER3D; }
-"samplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }
-"sampler1DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DSHADOW; }
-"sampler2DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DSHADOW; }
-
-"sampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DRECT; }
-"isampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2DRECT; }
-"usampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2DRECT; }
-"sampler2DRectShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DRECTSHADOW; }
-
-"samplerCubeShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBESHADOW; }
-"sampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DARRAY; }
-"sampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DARRAY; }
-"sampler1DArrayShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DARRAYSHADOW; }
-"sampler2DArrayShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DARRAYSHADOW; }
-"isampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER1D; }
-"isampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2D; }
-"isampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER3D; }
-"isamplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLERCUBE; }
-"isampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER1DARRAY; }
-"isampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2DARRAY; }
-"usampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER1D; }
-"usampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2D; }
-"usampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER3D; }
-"usamplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLERCUBE; }
-"usampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER1DARRAY; }
-"usampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2DARRAY; }
+\r
+"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }\r
+"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }\r
+"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }\r
+"dvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC2); }\r
+"dvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC3); }\r
+"dvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC4); }\r
+"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }\r
+"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }\r
+"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }\r
+"uvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC2); }\r
+"uvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC3); }\r
+"uvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC4); }\r
+"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }\r
+"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }\r
+"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }\r
+\r
+"sampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; }\r
+"sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }\r
+"sampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER3D; }\r
+"samplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }\r
+"sampler1DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DSHADOW; }\r
+"sampler2DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DSHADOW; }\r
+\r
+"sampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DRECT; }\r
+"isampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2DRECT; }\r
+"usampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2DRECT; }\r
+"sampler2DRectShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DRECTSHADOW; }\r
+\r
+"samplerCubeShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBESHADOW; }\r
+"sampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DARRAY; }\r
+"sampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DARRAY; }\r
+"sampler1DArrayShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DARRAYSHADOW; }\r
+"sampler2DArrayShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DARRAYSHADOW; }\r
+"isampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER1D; }\r
+"isampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2D; }\r
+"isampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER3D; }\r
+"isamplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLERCUBE; }\r
+"isampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER1DARRAY; }\r
+"isampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2DARRAY; }\r
+"usampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER1D; }\r
+"usampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2D; }\r
+"usampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER3D; }\r
+"usamplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLERCUBE; }\r
+"usampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER1DARRAY; }\r
+"usampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2DARRAY; }\r
\r
"samplerBuffer" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(SAMPLERBUFFER); }\r
"isamplerBuffer" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(ISAMPLERBUFFER); }\r
"image2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(IMAGE2DMSARRAY); }\r
"iimage2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(IIMAGE2DMSARRAY); }\r
"uimage2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(UIMAGE2DMSARRAY); }\r
-
-"struct" { pyylval->lex.line = yylineno; return(STRUCT); }
-
-"asm" { PaReservedWord(); return 0; }
-
-"class" { PaReservedWord(); return 0; }
-"union" { PaReservedWord(); return 0; }
-"enum" { PaReservedWord(); return 0; }
-"typedef" { PaReservedWord(); return 0; }
-"template" { PaReservedWord(); return 0; }
-"this" { PaReservedWord(); return 0; }
-"packed" { PaReservedWord(); return 0; }
-
-"goto" { PaReservedWord(); return 0; }
-
-"inline" { PaReservedWord(); return 0; }
-"noinline" { PaReservedWord(); return 0; }
-"public" { PaReservedWord(); return 0; }
-"static" { PaReservedWord(); return 0; }
-"extern" { PaReservedWord(); return 0; }
-"external" { PaReservedWord(); return 0; }
-"interface" { PaReservedWord(); return 0; }
-
-"long" { PaReservedWord(); return 0; }
-"short" { PaReservedWord(); return 0; }
-"half" { PaReservedWord(); return 0; }
-"fixed" { PaReservedWord(); return 0; }
-"unsigned" { PaReservedWord(); return 0; }
-
-"input" { PaReservedWord(); return 0; }
-"output" { PaReservedWord(); return 0; }
-
-"hvec2" { PaReservedWord(); return 0; }
-"hvec3" { PaReservedWord(); return 0; }
-"hvec4" { PaReservedWord(); return 0; }
-"fvec2" { PaReservedWord(); return 0; }
-"fvec3" { PaReservedWord(); return 0; }
-"fvec4" { PaReservedWord(); return 0; }
-
-"sampler3DRect" { PaReservedWord(); return 0; }
-
-"sizeof" { PaReservedWord(); return 0; }
-"cast" { PaReservedWord(); return 0; }
-
-"namespace" { PaReservedWord(); return 0; }
-"using" { PaReservedWord(); return 0; }
-
-{L}({L}|{D})* {
- pyylval->lex.line = yylineno;
- pyylval->lex.string = NewPoolTString(yytext);
- return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
-}
-
-0[xX]{H}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
-0{O}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
-0{D}+ { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
-{D}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
-
-0[xX]{H}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); }
-0{O}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); }
-0{D}+{U} { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
-{D}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); }
-
-{D}+{E} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
-{D}+"."{D}*({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
-"."{D}+({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
-
-"/*" { int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; }
-
-"+=" { pyylval->lex.line = yylineno; return(ADD_ASSIGN); }
-"-=" { pyylval->lex.line = yylineno; return(SUB_ASSIGN); }
-"*=" { pyylval->lex.line = yylineno; return(MUL_ASSIGN); }
-"/=" { pyylval->lex.line = yylineno; return(DIV_ASSIGN); }
-"%=" { pyylval->lex.line = yylineno; return(MOD_ASSIGN); }
-"<<=" { pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }
-">>=" { pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }
-"&=" { pyylval->lex.line = yylineno; return(AND_ASSIGN); }
-"^=" { pyylval->lex.line = yylineno; return(XOR_ASSIGN); }
-"|=" { pyylval->lex.line = yylineno; return(OR_ASSIGN); }
-
-"++" { pyylval->lex.line = yylineno; return(INC_OP); }
-"--" { pyylval->lex.line = yylineno; return(DEC_OP); }
-"&&" { pyylval->lex.line = yylineno; return(AND_OP); }
-"||" { pyylval->lex.line = yylineno; return(OR_OP); }
-"^^" { pyylval->lex.line = yylineno; return(XOR_OP); }
-"<=" { pyylval->lex.line = yylineno; return(LE_OP); }
-">=" { pyylval->lex.line = yylineno; return(GE_OP); }
-"==" { pyylval->lex.line = yylineno; return(EQ_OP); }
-"!=" { pyylval->lex.line = yylineno; return(NE_OP); }
-"<<" { pyylval->lex.line = yylineno; return(LEFT_OP); }
-">>" { pyylval->lex.line = yylineno; return(RIGHT_OP); }
-";" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }
-("{"|"<%") { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }
-("}"|"%>") { pyylval->lex.line = yylineno; return(RIGHT_BRACE); }
-"," { pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }
-":" { pyylval->lex.line = yylineno; return(COLON); }
-"=" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }
-"(" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }
-")" { pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }
-("["|"<:") { pyylval->lex.line = yylineno; return(LEFT_BRACKET); }
-("]"|":>") { pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }
-"." { BEGIN(FIELDS); return(DOT); }
-"!" { pyylval->lex.line = yylineno; return(BANG); }
-"-" { pyylval->lex.line = yylineno; return(DASH); }
-"~" { pyylval->lex.line = yylineno; return(TILDE); }
-"+" { pyylval->lex.line = yylineno; return(PLUS); }
-"*" { pyylval->lex.line = yylineno; return(STAR); }
-"/" { pyylval->lex.line = yylineno; return(SLASH); }
-"%" { pyylval->lex.line = yylineno; return(PERCENT); }
-"<" { pyylval->lex.line = yylineno; return(LEFT_ANGLE); }
-">" { pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }
-"|" { pyylval->lex.line = yylineno; return(VERTICAL_BAR); }
-"^" { pyylval->lex.line = yylineno; return(CARET); }
-"&" { pyylval->lex.line = yylineno; return(AMPERSAND); }
-"?" { pyylval->lex.line = yylineno; return(QUESTION); }
-
-<FIELDS>{L}({L}|{D})* {
-BEGIN(INITIAL);
- pyylval->lex.line = yylineno;
- pyylval->lex.string = NewPoolTString(yytext);
- return FIELD_SELECTION; }
-<FIELDS>[ \t\v\f\r] {}
-
-[ \t\v\n\f\r] { }
-<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}
-<*>. { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";
- return 0; }
-
-%%
-
-
-//Including Pre-processor.
-extern "C" {
- #include "./preprocessor/preprocess.h"
-}
-
-//
-// The YY_INPUT macro just calls this. Maybe this could be just put into
-// the macro directly.
-//
-
-int yy_input(char* buf, int max_size)
-{
- char *char_token =NULL;
- int len;
-
- if ((len = yylex_CPP(buf, max_size)) == 0)
- return 0;
- if (len >= max_size)
- YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-
- buf[len] = ' ';
- return len+1;
-}
-
-
-//
-// Parse an array of strings using yyparse. We set up globals used by
-// yywrap.
-//
-// Returns 0 for success, as per yyparse().
-//
-int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal)
-{
- int argv0len;
-
- ScanFromString(argv[0]);
-
- //Storing the Current Compiler Parse context into the cpp structure.
- cpp->pC = (void*)&parseContextLocal;
-
- if (!argv || argc == 0)
- return 1;
-
- for (int i = 0; i < argc; ++i) {
- if (!argv[i]) {
- parseContextLocal.error(0, "Null shader source string", "", "");
- parseContextLocal.recover();
- return 1;
- }
- }
-
- if (!strLen) {
- argv0len = (int) strlen(argv[0]);
- strLen = &argv0len;
- }
- yyrestart(0);
- (&parseContextLocal)->AfterEOF = false;
- cpp->PaWhichStr = 0;
- cpp->PaArgv = argv;
- cpp->PaArgc = argc;
- cpp->PaStrLen = strLen;
- cpp->notAVersionToken = 0;
- yylineno = 1;
-
- if (*cpp->PaStrLen >= 0) {
- int ret;
- #ifdef _WIN32
- ret = yyparse(parseContextLocal);
- #else
- ret = yyparse((void*)(&parseContextLocal));
- #endif
- if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)
- return 1;
- else
- return 0;
- }
- else
- return 0;
-}
-
-void yyerror(char *s)
-{
- if (((TParseContext *)cpp->pC)->AfterEOF) {
- if (cpp->tokensBeforeEOF == 1) {
- GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");
- GlobalParseContext->recover();
- }
- } else {
- GlobalParseContext->error(yylineno, "syntax error", yytext, s, "");
- GlobalParseContext->recover();
- }
-}
-
-void PaReservedWord()
-{
- GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");
- GlobalParseContext->recover();
-}
-
-int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)
-{
- symbol = parseContextLocal.symbolTable.find(id);
- if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {
- TVariable* variable = static_cast<TVariable*>(symbol);
- if (variable->isUserType()) {
- parseContextLocal.lexAfterType = true;
- return TYPE_NAME;
- }
- }
-
- return IDENTIFIER;
-}
-
-int PaParseComment(int &lineno, TParseContext& parseContextLocal)
-{
- int transitionFlag = 0;
- int nextChar;
-
- while (transitionFlag != 2) {
- nextChar = yyinput();
- if (nextChar == '\n')
- lineno++;
- switch (nextChar) {
- case '*' :
- transitionFlag = 1;
- break;
- case '/' : /* if star is the previous character, then it is the end of comment */
- if (transitionFlag == 1) {
- return 1 ;
- }
- break;
- case EOF :
- /* Raise error message here */
- parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");
- GlobalParseContext->recover();
- return YY_NULL;
- default : /* Any other character will be a part of the comment */
- transitionFlag = 0;
- }
- }
- return 1;
-}
-
-extern "C" {
-
-void CPPDebugLogMsg(const char *msg)
-{
- ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);
-}
-
-void CPPWarningToInfoLog(const char *msg)
-{
- ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno);
-}
-
-void CPPShInfoLogMsg(const char *msg)
-{
- ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");
- GlobalParseContext->recover();
-}
-
-void CPPErrorToInfoLog(char *msg)
-{
- ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");
- GlobalParseContext->recover();
-}
-
-void SetLineNumber(int line)
-{
- yylineno &= ~SourceLocLineMask;
- yylineno |= line;
-}
-
-void SetStringNumber(int string)
-{
- yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);
-}
-
-int GetStringNumber(void)
-{
- return yylineno >> 16;
-}
-
-int GetLineNumber(void)
-{
- return yylineno & SourceLocLineMask;
-}
-
-void IncLineNumber(void)
-{
- if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)
- ++yylineno;
-}
-
-void DecLineNumber(void)
-{
- if ((yylineno & SourceLocLineMask) > 0)
- --yylineno;
-}
-
-void HandlePragma(const char **tokens, int numTokens)
-{
- if (!strcmp(tokens[0], "optimize")) {
- if (numTokens != 4) {
- CPPShInfoLogMsg("optimize pragma syntax is incorrect");
- return;
- }
-
- if (strcmp(tokens[1], "(")) {
- CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");
- return;
- }
-
- if (!strcmp(tokens[2], "on"))
- ((TParseContext *)cpp->pC)->contextPragma.optimize = true;
- else if (!strcmp(tokens[2], "off"))
- ((TParseContext *)cpp->pC)->contextPragma.optimize = false;
- else {
- CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
- return;
- }
-
- if (strcmp(tokens[3], ")")) {
- CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");
- return;
- }
- } else if (!strcmp(tokens[0], "debug")) {
- if (numTokens != 4) {
- CPPShInfoLogMsg("debug pragma syntax is incorrect");
- return;
- }
-
- if (strcmp(tokens[1], "(")) {
- CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");
- return;
- }
-
- if (!strcmp(tokens[2], "on"))
- ((TParseContext *)cpp->pC)->contextPragma.debug = true;
- else if (!strcmp(tokens[2], "off"))
- ((TParseContext *)cpp->pC)->contextPragma.debug = false;
- else {
- CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
- return;
- }
-
- if (strcmp(tokens[3], ")")) {
- CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");
- return;
- }
- } else {
-
-#ifdef PRAGMA_TABLE
- //
- // implementation specific pragma
- // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma
- // For now, just ignore the pragma that the implementation cannot recognize
- // An Example of one such implementation for a pragma that has a syntax like
- // #pragma pragmaname(pragmavalue)
- // This implementation stores the current pragmavalue against the pragma name in pragmaTable.
- //
- if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) {
- TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
- TPragmaTable::iterator iter;
- iter = pragmaTable.find(TString(tokens[0]));
- if (iter != pragmaTable.end()) {
- iter->second = tokens[2];
- } else {
- pragmaTable[tokens[0]] = tokens[2];
- }
- } else if (numTokens >= 2) {
- TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
- TPragmaTable::iterator iter;
- iter = pragmaTable.find(TString(tokens[0]));
- if (iter != pragmaTable.end()) {
- iter->second = tokens[1];
- } else {
- pragmaTable[tokens[0]] = tokens[1];
- }
- }
-#endif // PRAGMA_TABLE
- }
-}
-
-void StoreStr(char *string)
-{
- TString strSrc;
- strSrc = TString(string);
-
- ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;
-}
-
-const char* GetStrfromTStr(void)
-{
- cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();
- return cpp->ErrMsg;
-}
-
-void ResetTString(void)
-{
- ((TParseContext *)cpp->pC)->HashErrMsg = "";
-}
-
-TBehavior GetBehavior(const char* behavior)
-{
- if (!strcmp("require", behavior))
- return EBhRequire;
- else if (!strcmp("enable", behavior))
- return EBhEnable;
- else if (!strcmp("disable", behavior))
- return EBhDisable;
- else if (!strcmp("warn", behavior))
- return EBhWarn;
- else {
- CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());
- return EBhDisable;
- }
-}
-
-void updateExtensionBehavior(const char* extName, const char* behavior)
-{
- TBehavior behaviorVal = GetBehavior(behavior);
- TMap<TString, TBehavior>:: iterator iter;
- TString msg;
-
- // special cased for all extension
- if (!strcmp(extName, "all")) {
- if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {
- CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");
- return;
- } else {
- for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)
- iter->second = behaviorVal;
- }
- } else {
- iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));
- if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {
- switch (behaviorVal) {
- case EBhRequire:
- CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());
- break;
- case EBhEnable:
- case EBhWarn:
- case EBhDisable:
- msg = TString("extension '") + extName + "' is not supported";
- ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
- break;
- }
- return;
- } else
- iter->second = behaviorVal;
- }
-}
-
-} // extern "C"
-
-void setInitialState()
-{
- yy_start = 1;
-}
+\r
+"struct" { pyylval->lex.line = yylineno; return(STRUCT); }\r
+\r
+"asm" { PaReservedWord(); return 0; }\r
+\r
+"class" { PaReservedWord(); return 0; }\r
+"union" { PaReservedWord(); return 0; }\r
+"enum" { PaReservedWord(); return 0; }\r
+"typedef" { PaReservedWord(); return 0; }\r
+"template" { PaReservedWord(); return 0; }\r
+"this" { PaReservedWord(); return 0; }\r
+"packed" { PaReservedWord(); return 0; }\r
+\r
+"goto" { PaReservedWord(); return 0; }\r
+\r
+"inline" { PaReservedWord(); return 0; }\r
+"noinline" { PaReservedWord(); return 0; }\r
+"public" { PaReservedWord(); return 0; }\r
+"static" { PaReservedWord(); return 0; }\r
+"extern" { PaReservedWord(); return 0; }\r
+"external" { PaReservedWord(); return 0; }\r
+"interface" { PaReservedWord(); return 0; }\r
+\r
+"long" { PaReservedWord(); return 0; }\r
+"short" { PaReservedWord(); return 0; }\r
+"half" { PaReservedWord(); return 0; }\r
+"fixed" { PaReservedWord(); return 0; }\r
+"unsigned" { PaReservedWord(); return 0; }\r
+\r
+"input" { PaReservedWord(); return 0; }\r
+"output" { PaReservedWord(); return 0; }\r
+\r
+"hvec2" { PaReservedWord(); return 0; }\r
+"hvec3" { PaReservedWord(); return 0; }\r
+"hvec4" { PaReservedWord(); return 0; }\r
+"fvec2" { PaReservedWord(); return 0; }\r
+"fvec3" { PaReservedWord(); return 0; }\r
+"fvec4" { PaReservedWord(); return 0; }\r
+\r
+"sampler3DRect" { PaReservedWord(); return 0; }\r
+\r
+"sizeof" { PaReservedWord(); return 0; }\r
+"cast" { PaReservedWord(); return 0; }\r
+\r
+"namespace" { PaReservedWord(); return 0; }\r
+"using" { PaReservedWord(); return 0; }\r
+\r
+{L}({L}|{D})* { \r
+ pyylval->lex.line = yylineno; \r
+ pyylval->lex.string = NewPoolTString(yytext); \r
+ return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); \r
+}\r
+\r
+0[xX]{H}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
+0{O}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
+0{D}+ { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}\r
+{D}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
+\r
+0[xX]{H}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); }\r
+0{O}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); }\r
+0{D}+{U} { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}\r
+{D}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); }\r
+\r
+{D}+{F} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
+{D}+{E}{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
+{D}+"."{D}*({E})?{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
+"."{D}+({E})?{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
+\r
+{D}+{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return(DOUBLECONSTANT); }\r
+{D}+{E}{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return(DOUBLECONSTANT); }\r
+{D}+"."{D}*({E})?{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return(DOUBLECONSTANT); }\r
+"."{D}+({E})?{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return(DOUBLECONSTANT); }\r
+\r
+"/*" { int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; } \r
+\r
+"+=" { pyylval->lex.line = yylineno; return(ADD_ASSIGN); }\r
+"-=" { pyylval->lex.line = yylineno; return(SUB_ASSIGN); }\r
+"*=" { pyylval->lex.line = yylineno; return(MUL_ASSIGN); }\r
+"/=" { pyylval->lex.line = yylineno; return(DIV_ASSIGN); }\r
+"%=" { pyylval->lex.line = yylineno; return(MOD_ASSIGN); }\r
+"<<=" { pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }\r
+">>=" { pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }\r
+"&=" { pyylval->lex.line = yylineno; return(AND_ASSIGN); }\r
+"^=" { pyylval->lex.line = yylineno; return(XOR_ASSIGN); }\r
+"|=" { pyylval->lex.line = yylineno; return(OR_ASSIGN); }\r
+\r
+"++" { pyylval->lex.line = yylineno; return(INC_OP); }\r
+"--" { pyylval->lex.line = yylineno; return(DEC_OP); }\r
+"&&" { pyylval->lex.line = yylineno; return(AND_OP); }\r
+"||" { pyylval->lex.line = yylineno; return(OR_OP); }\r
+"^^" { pyylval->lex.line = yylineno; return(XOR_OP); }\r
+"<=" { pyylval->lex.line = yylineno; return(LE_OP); }\r
+">=" { pyylval->lex.line = yylineno; return(GE_OP); }\r
+"==" { pyylval->lex.line = yylineno; return(EQ_OP); }\r
+"!=" { pyylval->lex.line = yylineno; return(NE_OP); }\r
+"<<" { pyylval->lex.line = yylineno; return(LEFT_OP); }\r
+">>" { pyylval->lex.line = yylineno; return(RIGHT_OP); }\r
+";" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }\r
+("{"|"<%") { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }\r
+("}"|"%>") { pyylval->lex.line = yylineno; return(RIGHT_BRACE); }\r
+"," { pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }\r
+":" { pyylval->lex.line = yylineno; return(COLON); }\r
+"=" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }\r
+"(" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }\r
+")" { pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }\r
+("["|"<:") { pyylval->lex.line = yylineno; return(LEFT_BRACKET); }\r
+("]"|":>") { pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }\r
+"." { BEGIN(FIELDS); return(DOT); }\r
+"!" { pyylval->lex.line = yylineno; return(BANG); }\r
+"-" { pyylval->lex.line = yylineno; return(DASH); }\r
+"~" { pyylval->lex.line = yylineno; return(TILDE); }\r
+"+" { pyylval->lex.line = yylineno; return(PLUS); }\r
+"*" { pyylval->lex.line = yylineno; return(STAR); }\r
+"/" { pyylval->lex.line = yylineno; return(SLASH); }\r
+"%" { pyylval->lex.line = yylineno; return(PERCENT); }\r
+"<" { pyylval->lex.line = yylineno; return(LEFT_ANGLE); }\r
+">" { pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }\r
+"|" { pyylval->lex.line = yylineno; return(VERTICAL_BAR); }\r
+"^" { pyylval->lex.line = yylineno; return(CARET); }\r
+"&" { pyylval->lex.line = yylineno; return(AMPERSAND); }\r
+"?" { pyylval->lex.line = yylineno; return(QUESTION); }\r
+\r
+<FIELDS>{L}({L}|{D})* { \r
+BEGIN(INITIAL); \r
+ pyylval->lex.line = yylineno; \r
+ pyylval->lex.string = NewPoolTString(yytext); \r
+ return FIELD_SELECTION; }\r
+<FIELDS>[ \t\v\f\r] {}\r
+\r
+[ \t\v\n\f\r] { }\r
+<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}\r
+<*>. { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";\r
+ return 0; }\r
+\r
+%%\r
+\r
+\r
+//Including Pre-processor.\r
+extern "C" {\r
+ #include "./preprocessor/preprocess.h"\r
+} \r
+\r
+//\r
+// The YY_INPUT macro just calls this. Maybe this could be just put into\r
+// the macro directly.\r
+//\r
+\r
+int yy_input(char* buf, int max_size)\r
+{\r
+ char *char_token =NULL;\r
+ int len;\r
+\r
+ if ((len = yylex_CPP(buf, max_size)) == 0)\r
+ return 0;\r
+ if (len >= max_size) \r
+ YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );\r
+\r
+ buf[len] = ' ';\r
+ return len+1;\r
+}\r
+\r
+\r
+//\r
+// Parse an array of strings using yyparse. We set up globals used by\r
+// yywrap.\r
+//\r
+// Returns 0 for success, as per yyparse().\r
+//\r
+int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal)\r
+{\r
+ int argv0len;\r
+ \r
+ ScanFromString(argv[0]); \r
+ \r
+ //Storing the Current Compiler Parse context into the cpp structure.\r
+ cpp->pC = (void*)&parseContextLocal;\r
+ \r
+ if (!argv || argc == 0)\r
+ return 1;\r
+ \r
+ for (int i = 0; i < argc; ++i) {\r
+ if (!argv[i]) {\r
+ parseContextLocal.error(0, "Null shader source string", "", "");\r
+ parseContextLocal.recover();\r
+ return 1;\r
+ }\r
+ }\r
+ \r
+ if (!strLen) {\r
+ argv0len = (int) strlen(argv[0]);\r
+ strLen = &argv0len;\r
+ }\r
+ yyrestart(0);\r
+ (&parseContextLocal)->AfterEOF = false;\r
+ cpp->PaWhichStr = 0;\r
+ cpp->PaArgv = argv;\r
+ cpp->PaArgc = argc;\r
+ cpp->PaStrLen = strLen;\r
+ cpp->notAVersionToken = 0;\r
+ yylineno = 1;\r
+ \r
+ if (*cpp->PaStrLen >= 0) { \r
+ int ret;\r
+ #ifdef _WIN32\r
+ ret = yyparse(parseContextLocal); \r
+ #else\r
+ ret = yyparse((void*)(&parseContextLocal));\r
+ #endif\r
+ if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)\r
+ return 1;\r
+ else\r
+ return 0;\r
+ }\r
+ else\r
+ return 0;\r
+}\r
+\r
+void yyerror(char *s) \r
+{\r
+ if (((TParseContext *)cpp->pC)->AfterEOF) {\r
+ if (cpp->tokensBeforeEOF == 1) {\r
+ GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");\r
+ GlobalParseContext->recover();\r
+ }\r
+ } else {\r
+ GlobalParseContext->error(yylineno, "syntax error", yytext, s, "");\r
+ GlobalParseContext->recover();\r
+ } \r
+}\r
+\r
+void PaReservedWord()\r
+{\r
+ GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");\r
+ GlobalParseContext->recover();\r
+}\r
+\r
+int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)\r
+{\r
+ symbol = parseContextLocal.symbolTable.find(id);\r
+ if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {\r
+ TVariable* variable = static_cast<TVariable*>(symbol);\r
+ if (variable->isUserType()) {\r
+ parseContextLocal.lexAfterType = true;\r
+ return TYPE_NAME;\r
+ }\r
+ }\r
+ \r
+ return IDENTIFIER;\r
+}\r
+\r
+int PaParseComment(int &lineno, TParseContext& parseContextLocal)\r
+{\r
+ int transitionFlag = 0;\r
+ int nextChar;\r
+ \r
+ while (transitionFlag != 2) {\r
+ nextChar = yyinput();\r
+ if (nextChar == '\n')\r
+ lineno++;\r
+ switch (nextChar) {\r
+ case '*' :\r
+ transitionFlag = 1;\r
+ break;\r
+ case '/' : /* if star is the previous character, then it is the end of comment */\r
+ if (transitionFlag == 1) {\r
+ return 1 ;\r
+ }\r
+ break;\r
+ case EOF :\r
+ /* Raise error message here */\r
+ parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");\r
+ GlobalParseContext->recover();\r
+ return YY_NULL; \r
+ default : /* Any other character will be a part of the comment */\r
+ transitionFlag = 0;\r
+ }\r
+ }\r
+ return 1;\r
+}\r
+\r
+extern "C" {\r
+\r
+void CPPDebugLogMsg(const char *msg)\r
+{\r
+ ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);\r
+}\r
+\r
+void CPPWarningToInfoLog(const char *msg)\r
+{\r
+ ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno); \r
+}\r
+\r
+void CPPShInfoLogMsg(const char *msg)\r
+{\r
+ ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");\r
+ GlobalParseContext->recover();\r
+}\r
+\r
+void CPPErrorToInfoLog(char *msg)\r
+{\r
+ ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");\r
+ GlobalParseContext->recover();\r
+}\r
+\r
+void SetLineNumber(int line)\r
+{\r
+ yylineno &= ~SourceLocLineMask;\r
+ yylineno |= line;\r
+}\r
+\r
+void SetStringNumber(int string)\r
+{\r
+ yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);\r
+}\r
+\r
+int GetStringNumber(void)\r
+{\r
+ return yylineno >> 16;\r
+}\r
+\r
+int GetLineNumber(void)\r
+{\r
+ return yylineno & SourceLocLineMask;\r
+}\r
+\r
+void IncLineNumber(void)\r
+{\r
+ if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)\r
+ ++yylineno;\r
+}\r
+\r
+void DecLineNumber(void)\r
+{\r
+ if ((yylineno & SourceLocLineMask) > 0)\r
+ --yylineno;\r
+}\r
+\r
+void HandlePragma(const char **tokens, int numTokens)\r
+{ \r
+ if (!strcmp(tokens[0], "optimize")) {\r
+ if (numTokens != 4) {\r
+ CPPShInfoLogMsg("optimize pragma syntax is incorrect");\r
+ return;\r
+ }\r
+ \r
+ if (strcmp(tokens[1], "(")) {\r
+ CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");\r
+ return;\r
+ }\r
+ \r
+ if (!strcmp(tokens[2], "on"))\r
+ ((TParseContext *)cpp->pC)->contextPragma.optimize = true;\r
+ else if (!strcmp(tokens[2], "off"))\r
+ ((TParseContext *)cpp->pC)->contextPragma.optimize = false;\r
+ else {\r
+ CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");\r
+ return;\r
+ }\r
+ \r
+ if (strcmp(tokens[3], ")")) {\r
+ CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");\r
+ return;\r
+ }\r
+ } else if (!strcmp(tokens[0], "debug")) {\r
+ if (numTokens != 4) {\r
+ CPPShInfoLogMsg("debug pragma syntax is incorrect");\r
+ return;\r
+ }\r
+ \r
+ if (strcmp(tokens[1], "(")) {\r
+ CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");\r
+ return;\r
+ }\r
+ \r
+ if (!strcmp(tokens[2], "on"))\r
+ ((TParseContext *)cpp->pC)->contextPragma.debug = true;\r
+ else if (!strcmp(tokens[2], "off"))\r
+ ((TParseContext *)cpp->pC)->contextPragma.debug = false;\r
+ else {\r
+ CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");\r
+ return;\r
+ }\r
+ \r
+ if (strcmp(tokens[3], ")")) {\r
+ CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");\r
+ return;\r
+ }\r
+ } else {\r
+\r
+#ifdef PRAGMA_TABLE\r
+ //\r
+ // implementation specific pragma\r
+ // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma\r
+ // For now, just ignore the pragma that the implementation cannot recognize\r
+ // An Example of one such implementation for a pragma that has a syntax like\r
+ // #pragma pragmaname(pragmavalue)\r
+ // This implementation stores the current pragmavalue against the pragma name in pragmaTable.\r
+ // \r
+ if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) { \r
+ TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;\r
+ TPragmaTable::iterator iter;\r
+ iter = pragmaTable.find(TString(tokens[0]));\r
+ if (iter != pragmaTable.end()) {\r
+ iter->second = tokens[2];\r
+ } else {\r
+ pragmaTable[tokens[0]] = tokens[2];\r
+ } \r
+ } else if (numTokens >= 2) {\r
+ TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;\r
+ TPragmaTable::iterator iter;\r
+ iter = pragmaTable.find(TString(tokens[0]));\r
+ if (iter != pragmaTable.end()) {\r
+ iter->second = tokens[1];\r
+ } else {\r
+ pragmaTable[tokens[0]] = tokens[1];\r
+ }\r
+ }\r
+#endif // PRAGMA_TABLE\r
+ }\r
+}\r
+\r
+void StoreStr(char *string)\r
+{\r
+ TString strSrc;\r
+ strSrc = TString(string);\r
+\r
+ ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;\r
+}\r
+\r
+const char* GetStrfromTStr(void)\r
+{\r
+ cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();\r
+ return cpp->ErrMsg;\r
+}\r
+\r
+void ResetTString(void)\r
+{\r
+ ((TParseContext *)cpp->pC)->HashErrMsg = "";\r
+}\r
+\r
+TBehavior GetBehavior(const char* behavior)\r
+{\r
+ if (!strcmp("require", behavior))\r
+ return EBhRequire;\r
+ else if (!strcmp("enable", behavior))\r
+ return EBhEnable;\r
+ else if (!strcmp("disable", behavior))\r
+ return EBhDisable;\r
+ else if (!strcmp("warn", behavior))\r
+ return EBhWarn;\r
+ else {\r
+ CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());\r
+ return EBhDisable;\r
+ } \r
+}\r
+\r
+void updateExtensionBehavior(const char* extName, const char* behavior)\r
+{\r
+ TBehavior behaviorVal = GetBehavior(behavior);\r
+ TMap<TString, TBehavior>:: iterator iter;\r
+ TString msg;\r
+ \r
+ // special cased for all extension\r
+ if (!strcmp(extName, "all")) {\r
+ if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {\r
+ CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior"); \r
+ return;\r
+ } else {\r
+ for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)\r
+ iter->second = behaviorVal;\r
+ } \r
+ } else {\r
+ iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));\r
+ if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {\r
+ switch (behaviorVal) {\r
+ case EBhRequire:\r
+ CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str()); \r
+ break;\r
+ case EBhEnable:\r
+ case EBhWarn:\r
+ case EBhDisable:\r
+ msg = TString("extension '") + extName + "' is not supported";\r
+ ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); \r
+ break;\r
+ }\r
+ return;\r
+ } else\r
+ iter->second = behaviorVal;\r
+ }\r
+}\r
+ \r
+} // extern "C"\r
+\r
+void setInitialState()\r
+{\r
+ yy_start = 1;\r
+}\r