Commit 5d3e2e35 by John Kessenich

Support suffixes for floats and doubles (none were supported in 110).

Add preprocessor support for parsing doubles. Add double support to the flex stage. Put in some of the basic double supported needed in the front end. Add generic support for version numbers in the preprocessor, and the core, compatibility, and es profiles. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@19949 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent e95ecc54
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
enum TBasicType { enum TBasicType {
EbtVoid, EbtVoid,
EbtFloat, EbtFloat,
EbtDouble,
EbtInt, EbtInt,
EbtBool, EbtBool,
EbtGuardSamplerBegin, // non type: see implementation of IsSampler() EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
......
...@@ -42,13 +42,16 @@ public: ...@@ -42,13 +42,16 @@ public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
void setIConst(int i) {iConst = i; type = EbtInt; } void setIConst(int i) {iConst = i; type = EbtInt; }
void setFConst(float f) {fConst = f; type = EbtFloat; } void setFConst(float f) {fConst = f; type = EbtFloat; }
void setDConst(double d) {dConst = d; type = EbtDouble; }
void setBConst(bool b) {bConst = b; type = EbtBool; } void setBConst(bool b) {bConst = b; type = EbtBool; }
int getIConst() { return iConst; } int getIConst() { return iConst; }
float getFConst() { return fConst; } float getFConst() { return fConst; }
double getDConst() { return dConst; }
bool getBConst() { return bConst; } bool getBConst() { return bConst; }
int getIConst() const { return iConst; } int getIConst() const { return iConst; }
float getFConst() const { return fConst; } float getFConst() const { return fConst; }
double getDConst() const { return dConst; }
bool getBConst() const { return bConst; } bool getBConst() const { return bConst; }
bool operator==(const int i) const bool operator==(const int i) const
...@@ -67,6 +70,14 @@ public: ...@@ -67,6 +70,14 @@ public:
return false; return false;
} }
bool operator==(const double d) const
{
if (d == dConst)
return true;
return false;
}
bool operator==(const bool b) const bool operator==(const bool b) const
{ {
if (b == bConst) if (b == bConst)
...@@ -91,6 +102,11 @@ public: ...@@ -91,6 +102,11 @@ public:
return true; return true;
break; break;
case EbtDouble:
if (constant.dConst == dConst)
return true;
break;
case EbtBool: case EbtBool:
if (constant.bConst == bConst) if (constant.bConst == bConst)
return true; return true;
...@@ -135,6 +151,11 @@ public: ...@@ -135,6 +151,11 @@ public:
return true; return true;
return false; return false;
case EbtDouble:
if (dConst > constant.dConst)
return true;
return false;
default: default:
assert(false && "Default missing"); assert(false && "Default missing");
return false; return false;
...@@ -157,6 +178,11 @@ public: ...@@ -157,6 +178,11 @@ public:
return true; return true;
return false; return false;
case EbtDouble:
if (dConst < constant.dConst)
return true;
return false;
default: default:
assert(false && "Default missing"); assert(false && "Default missing");
return false; return false;
...@@ -172,6 +198,7 @@ public: ...@@ -172,6 +198,7 @@ public:
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break; case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
case EbtFloat: returnValue.setFConst(fConst + constant.fConst); break; case EbtFloat: returnValue.setFConst(fConst + constant.fConst); break;
case EbtDouble: returnValue.setDConst(dConst + constant.dConst); break;
default: assert(false && "Default missing"); default: assert(false && "Default missing");
} }
...@@ -185,6 +212,7 @@ public: ...@@ -185,6 +212,7 @@ public:
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break; case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
case EbtFloat: returnValue.setFConst(fConst - constant.fConst); break; case EbtFloat: returnValue.setFConst(fConst - constant.fConst); break;
case EbtDouble: returnValue.setDConst(dConst - constant.dConst); break;
default: assert(false && "Default missing"); default: assert(false && "Default missing");
} }
...@@ -198,6 +226,7 @@ public: ...@@ -198,6 +226,7 @@ public:
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break; case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
case EbtFloat: returnValue.setFConst(fConst * constant.fConst); break; case EbtFloat: returnValue.setFConst(fConst * constant.fConst); break;
case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break;
default: assert(false && "Default missing"); default: assert(false && "Default missing");
} }
...@@ -307,6 +336,7 @@ private: ...@@ -307,6 +336,7 @@ private:
int iConst; // used for ivec, scalar ints int iConst; // used for ivec, scalar ints
bool bConst; // used for bvec, scalar bools bool bConst; // used for bvec, scalar bools
float fConst; // used for vec, mat, scalar floats float fConst; // used for vec, mat, scalar floats
double dConst; // used for dvec, dmat, scalar doubles
} ; } ;
TBasicType type; TBasicType type;
......
...@@ -235,6 +235,7 @@ public: ...@@ -235,6 +235,7 @@ public:
switch (t) { switch (t) {
case EbtVoid: return "void"; break; case EbtVoid: return "void"; break;
case EbtFloat: return "float"; break; case EbtFloat: return "float"; break;
case EbtDouble: return "double"; break;
case EbtInt: return "int"; break; case EbtInt: return "int"; break;
case EbtBool: return "bool"; break; case EbtBool: return "bool"; break;
case EbtSampler1D: return "sampler1D"; break; case EbtSampler1D: return "sampler1D"; break;
......
...@@ -187,6 +187,7 @@ enum TOperator { ...@@ -187,6 +187,7 @@ enum TOperator {
EOpConstructInt, EOpConstructInt,
EOpConstructBool, EOpConstructBool,
EOpConstructFloat, EOpConstructFloat,
EOpConstructDouble,
EOpConstructVec2, EOpConstructVec2,
EOpConstructVec3, EOpConstructVec3,
EOpConstructVec4, EOpConstructVec4,
......
...@@ -243,9 +243,10 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, ...@@ -243,9 +243,10 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode,
// //
TBasicType newType = EbtVoid; TBasicType newType = EbtVoid;
switch (op) { switch (op) {
case EOpConstructInt: newType = EbtInt; break; case EOpConstructInt: newType = EbtInt; break;
case EOpConstructBool: newType = EbtBool; break; case EOpConstructBool: newType = EbtBool; break;
case EOpConstructFloat: newType = EbtFloat; break; case EOpConstructFloat: newType = EbtFloat; break;
case EOpConstructDouble: newType = EbtDouble; break;
default: break; default: break;
} }
......
...@@ -55,6 +55,7 @@ void TType::buildMangledName(TString& mangledName) ...@@ -55,6 +55,7 @@ void TType::buildMangledName(TString& mangledName)
switch (type) { switch (type) {
case EbtFloat: mangledName += 'f'; break; case EbtFloat: mangledName += 'f'; break;
case EbtDouble: mangledName += 'd'; break;
case EbtInt: mangledName += 'i'; break; case EbtInt: mangledName += 'i'; break;
case EbtBool: mangledName += 'b'; break; case EbtBool: mangledName += 'b'; break;
case EbtSampler1D: mangledName += "s1"; break; case EbtSampler1D: mangledName += "s1"; break;
......
/* /*
// //
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions //modification, are permitted provided that the following conditions
//are met: //are met:
// //
// Redistributions of source code must retain the above copyright // Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// //
// Redistributions in binary form must reproduce the above // Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following // copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided // disclaimer in the documentation and/or other materials provided
// with the distribution. // with the distribution.
// //
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived // contributors may be used to endorse or promote products derived
// from this software without specific prior written permission. // from this software without specific prior written permission.
// //
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT //"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE //FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, //COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, //INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; //BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT //CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN //LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE //ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE. //POSSIBILITY OF SUCH DAMAGE.
// //
*/ */
/* Based on /* Based on
ANSI C grammar, Lex specification ANSI C grammar, Lex specification
In 1985, Jeff Lee published this Lex specification together with a Yacc In 1985, Jeff Lee published this Lex specification together with a Yacc
grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted 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 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, 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. file usenet/net.sources/ansi.c.grammar.Z.
I intend to keep this version as close to the current C Standard grammar I intend to keep this version as close to the current C Standard grammar
as possible; please let me know if you discover discrepancies. as possible; please let me know if you discover discrepancies.
Jutta Degener, 1995 Jutta Degener, 1995
*/ */
D [0-9] D [0-9]
L [a-zA-Z_] L [a-zA-Z_]
H [a-fA-F0-9] H [a-fA-F0-9]
E [Ee][+-]?{D}+ E [Ee][+-]?{D}+
O [0-7] O [0-7]
U [uU] U [uU]
F [fF]
/* TODO: double literals, which will likely require pre-processor rework */ LF [lL][fF]
/* TODO: unsigned int literals, which will likely require pre-processor rework */
/* TODO: double literals, which will likely require pre-processor rework */
%option nounput /* TODO: unsigned int literals, which will likely require pre-processor rework */
%{
#include <stdio.h> %option nounput
#include <stdlib.h> %{
#include "ParseHelper.h" #include <stdio.h>
#include "glslang_tab.cpp.h" #include <stdlib.h>
#include "ParseHelper.h"
/* windows only pragma */ #include "glslang_tab.cpp.h"
#ifdef _MSC_VER
#pragma warning(disable : 4102) /* windows only pragma */
#endif #ifdef _MSC_VER
#pragma warning(disable : 4102)
int yy_input(char* buf, int max_size); #endif
TSourceLoc yylineno;
int yy_input(char* buf, int max_size);
#ifdef _WIN32 TSourceLoc yylineno;
extern int yyparse(TParseContext&);
#define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext) #ifdef _WIN32
#else extern int yyparse(TParseContext&);
extern int yyparse(void*); #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal) #else
#define parseContext (*((TParseContext*)(parseContextLocal))) extern int yyparse(void*);
#endif #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
#define parseContext (*((TParseContext*)(parseContextLocal)))
#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size)) #endif
%} #define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))
%option noyywrap %}
%option never-interactive
%option outfile="gen_glslang.cpp" %option noyywrap
%x FIELDS %option never-interactive
%option outfile="gen_glslang.cpp"
%x FIELDS
%%
<*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ };
%%
"attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); } <*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ };
"const" { pyylval->lex.line = yylineno; return(CONST); }
"patch" { pyylval->lex.line = yylineno; return(PATCH); } "attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); }
"sample" { pyylval->lex.line = yylineno; return(SAMPLE); } "const" { pyylval->lex.line = yylineno; return(CONST); }
"uniform" { pyylval->lex.line = yylineno; return(UNIFORM); } "patch" { pyylval->lex.line = yylineno; return(PATCH); }
"buffer" { pyylval->lex.line = yylineno; return(BUFFER); } "sample" { pyylval->lex.line = yylineno; return(SAMPLE); }
"shared" { pyylval->lex.line = yylineno; return(SHARED); } "uniform" { pyylval->lex.line = yylineno; return(UNIFORM); }
"coherent" { pyylval->lex.line = yylineno; return(COHERENT); } "buffer" { pyylval->lex.line = yylineno; return(BUFFER); }
"volatile" { pyylval->lex.line = yylineno; return(VOLATILE); } "shared" { pyylval->lex.line = yylineno; return(SHARED); }
"restrict" { pyylval->lex.line = yylineno; return(RESTRICT); } "coherent" { pyylval->lex.line = yylineno; return(COHERENT); }
"readonly" { pyylval->lex.line = yylineno; return(READONLY); } "volatile" { pyylval->lex.line = yylineno; return(VOLATILE); }
"writeonly" { pyylval->lex.line = yylineno; return(WRITEONLY); } "restrict" { pyylval->lex.line = yylineno; return(RESTRICT); }
"varying" { pyylval->lex.line = yylineno; return(VARYING); } "readonly" { pyylval->lex.line = yylineno; return(READONLY); }
"layout" { pyylval->lex.line = yylineno; return(LAYOUT); } "writeonly" { pyylval->lex.line = yylineno; return(WRITEONLY); }
"varying" { pyylval->lex.line = yylineno; return(VARYING); }
"break" { pyylval->lex.line = yylineno; return(BREAK); } "layout" { pyylval->lex.line = yylineno; return(LAYOUT); }
"continue" { pyylval->lex.line = yylineno; return(CONTINUE); }
"do" { pyylval->lex.line = yylineno; return(DO); } "break" { pyylval->lex.line = yylineno; return(BREAK); }
"for" { pyylval->lex.line = yylineno; return(FOR); } "continue" { pyylval->lex.line = yylineno; return(CONTINUE); }
"while" { pyylval->lex.line = yylineno; return(WHILE); } "do" { pyylval->lex.line = yylineno; return(DO); }
"switch" { pyylval->lex.line = yylineno; return(SWITCH); } "for" { pyylval->lex.line = yylineno; return(FOR); }
"case" { pyylval->lex.line = yylineno; return(CASE); } "while" { pyylval->lex.line = yylineno; return(WHILE); }
"default" { pyylval->lex.line = yylineno; return(DEFAULT); } "switch" { pyylval->lex.line = yylineno; return(SWITCH); }
"case" { pyylval->lex.line = yylineno; return(CASE); }
"if" { pyylval->lex.line = yylineno; return(IF); } "default" { pyylval->lex.line = yylineno; return(DEFAULT); }
"else" { pyylval->lex.line = yylineno; return(ELSE); }
"if" { pyylval->lex.line = yylineno; return(IF); }
"in" { pyylval->lex.line = yylineno; return(IN); } "else" { pyylval->lex.line = yylineno; return(ELSE); }
"out" { pyylval->lex.line = yylineno; return(OUT); }
"inout" { pyylval->lex.line = yylineno; return(INOUT); } "in" { pyylval->lex.line = yylineno; return(IN); }
"centroid" { pyylval->lex.line = yylineno; return(CENTROID); } "out" { pyylval->lex.line = yylineno; return(OUT); }
"noperspective" { pyylval->lex.line = yylineno; return(NOPERSPECTIVE); } "inout" { pyylval->lex.line = yylineno; return(INOUT); }
"flat" { pyylval->lex.line = yylineno; return(FLAT); } "centroid" { pyylval->lex.line = yylineno; return(CENTROID); }
"smooth" { pyylval->lex.line = yylineno; return(SMOOTH); } "noperspective" { pyylval->lex.line = yylineno; return(NOPERSPECTIVE); }
"flat" { pyylval->lex.line = yylineno; return(FLAT); }
"precise" { pyylval->lex.line = yylineno; return(PRECISE); } "smooth" { pyylval->lex.line = yylineno; return(SMOOTH); }
"invariant" { pyylval->lex.line = yylineno; return(INVARIANT); }
"precise" { pyylval->lex.line = yylineno; return(PRECISE); }
"precision" { pyylval->lex.line = yylineno; return(PRECISION); } "invariant" { pyylval->lex.line = yylineno; return(INVARIANT); }
"highp" { pyylval->lex.line = yylineno; return(HIGH_PRECISION); }
"mediump" { pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); } "precision" { pyylval->lex.line = yylineno; return(PRECISION); }
"lowp" { pyylval->lex.line = yylineno; return(LOW_PRECISION); } "highp" { pyylval->lex.line = yylineno; return(HIGH_PRECISION); }
"mediump" { pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); }
"float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT); } "lowp" { pyylval->lex.line = yylineno; return(LOW_PRECISION); }
"double" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DOUBLE); }
"int" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT); } "float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT); }
"uint" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(UINT); } "double" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DOUBLE); }
"void" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID); } "int" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT); }
"bool" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL); } "uint" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(UINT); }
"true" { pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); } "void" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID); }
"false" { pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); } "bool" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL); }
"true" { pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); }
"discard" { pyylval->lex.line = yylineno; return(DISCARD); } "false" { pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }
"return" { pyylval->lex.line = yylineno; return(RETURN); }
"subroutine" { pyylval->lex.line = yylineno; return(SUBROUTINE); } "discard" { pyylval->lex.line = yylineno; return(DISCARD); }
"return" { pyylval->lex.line = yylineno; return(RETURN); }
"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2); } "subroutine" { pyylval->lex.line = yylineno; return(SUBROUTINE); }
"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3); }
"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT4); } "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); }
"mat2x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X2); } "mat2x2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X2); }
"mat2x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X3); } "mat2x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2X3); }
...@@ -177,52 +179,52 @@ TSourceLoc yylineno; ...@@ -177,52 +179,52 @@ TSourceLoc yylineno;
"dmat4x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X3); } "dmat4x3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X3); }
"dmat4x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X4); } "dmat4x4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(DMAT4X4); }
"atomic_uint" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(ATOMIC_UINT); } "atomic_uint" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(ATOMIC_UINT); }
"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); } "vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }
"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); } "vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }
"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); } "vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }
"dvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC2); } "dvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC2); }
"dvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC3); } "dvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC3); }
"dvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC4); } "dvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (DVEC4); }
"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); } "ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }
"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); } "ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }
"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); } "ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }
"uvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC2); } "uvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC2); }
"uvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC3); } "uvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC3); }
"uvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC4); } "uvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (UVEC4); }
"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); } "bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }
"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); } "bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }
"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); } "bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }
"sampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; } "sampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; }
"sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; } "sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }
"sampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER3D; } "sampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER3D; }
"samplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; } "samplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }
"sampler1DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DSHADOW; } "sampler1DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DSHADOW; }
"sampler2DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DSHADOW; } "sampler2DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DSHADOW; }
"sampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DRECT; } "sampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DRECT; }
"isampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2DRECT; } "isampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2DRECT; }
"usampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2DRECT; } "usampler2DRect" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2DRECT; }
"sampler2DRectShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DRECTSHADOW; } "sampler2DRectShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DRECTSHADOW; }
"samplerCubeShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBESHADOW; } "samplerCubeShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBESHADOW; }
"sampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DARRAY; } "sampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DARRAY; }
"sampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DARRAY; } "sampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DARRAY; }
"sampler1DArrayShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DARRAYSHADOW; } "sampler1DArrayShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DARRAYSHADOW; }
"sampler2DArrayShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DARRAYSHADOW; } "sampler2DArrayShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DARRAYSHADOW; }
"isampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER1D; } "isampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER1D; }
"isampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2D; } "isampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2D; }
"isampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER3D; } "isampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER3D; }
"isamplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLERCUBE; } "isamplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLERCUBE; }
"isampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER1DARRAY; } "isampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER1DARRAY; }
"isampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2DARRAY; } "isampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return ISAMPLER2DARRAY; }
"usampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER1D; } "usampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER1D; }
"usampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2D; } "usampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2D; }
"usampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER3D; } "usampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER3D; }
"usamplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLERCUBE; } "usamplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLERCUBE; }
"usampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER1DARRAY; } "usampler1DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER1DARRAY; }
"usampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2DARRAY; } "usampler2DArray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return USAMPLER2DARRAY; }
"samplerBuffer" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(SAMPLERBUFFER); } "samplerBuffer" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(SAMPLERBUFFER); }
"isamplerBuffer" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(ISAMPLERBUFFER); } "isamplerBuffer" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(ISAMPLERBUFFER); }
...@@ -266,494 +268,500 @@ TSourceLoc yylineno; ...@@ -266,494 +268,500 @@ TSourceLoc yylineno;
"image2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(IMAGE2DMSARRAY); } "image2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(IMAGE2DMSARRAY); }
"iimage2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(IIMAGE2DMSARRAY); } "iimage2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(IIMAGE2DMSARRAY); }
"uimage2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(UIMAGE2DMSARRAY); } "uimage2DMSarray" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(UIMAGE2DMSARRAY); }
"struct" { pyylval->lex.line = yylineno; return(STRUCT); } "struct" { pyylval->lex.line = yylineno; return(STRUCT); }
"asm" { PaReservedWord(); return 0; } "asm" { PaReservedWord(); return 0; }
"class" { PaReservedWord(); return 0; } "class" { PaReservedWord(); return 0; }
"union" { PaReservedWord(); return 0; } "union" { PaReservedWord(); return 0; }
"enum" { PaReservedWord(); return 0; } "enum" { PaReservedWord(); return 0; }
"typedef" { PaReservedWord(); return 0; } "typedef" { PaReservedWord(); return 0; }
"template" { PaReservedWord(); return 0; } "template" { PaReservedWord(); return 0; }
"this" { PaReservedWord(); return 0; } "this" { PaReservedWord(); return 0; }
"packed" { PaReservedWord(); return 0; } "packed" { PaReservedWord(); return 0; }
"goto" { PaReservedWord(); return 0; } "goto" { PaReservedWord(); return 0; }
"inline" { PaReservedWord(); return 0; } "inline" { PaReservedWord(); return 0; }
"noinline" { PaReservedWord(); return 0; } "noinline" { PaReservedWord(); return 0; }
"public" { PaReservedWord(); return 0; } "public" { PaReservedWord(); return 0; }
"static" { PaReservedWord(); return 0; } "static" { PaReservedWord(); return 0; }
"extern" { PaReservedWord(); return 0; } "extern" { PaReservedWord(); return 0; }
"external" { PaReservedWord(); return 0; } "external" { PaReservedWord(); return 0; }
"interface" { PaReservedWord(); return 0; } "interface" { PaReservedWord(); return 0; }
"long" { PaReservedWord(); return 0; } "long" { PaReservedWord(); return 0; }
"short" { PaReservedWord(); return 0; } "short" { PaReservedWord(); return 0; }
"half" { PaReservedWord(); return 0; } "half" { PaReservedWord(); return 0; }
"fixed" { PaReservedWord(); return 0; } "fixed" { PaReservedWord(); return 0; }
"unsigned" { PaReservedWord(); return 0; } "unsigned" { PaReservedWord(); return 0; }
"input" { PaReservedWord(); return 0; } "input" { PaReservedWord(); return 0; }
"output" { PaReservedWord(); return 0; } "output" { PaReservedWord(); return 0; }
"hvec2" { PaReservedWord(); return 0; } "hvec2" { PaReservedWord(); return 0; }
"hvec3" { PaReservedWord(); return 0; } "hvec3" { PaReservedWord(); return 0; }
"hvec4" { PaReservedWord(); return 0; } "hvec4" { PaReservedWord(); return 0; }
"fvec2" { PaReservedWord(); return 0; } "fvec2" { PaReservedWord(); return 0; }
"fvec3" { PaReservedWord(); return 0; } "fvec3" { PaReservedWord(); return 0; }
"fvec4" { PaReservedWord(); return 0; } "fvec4" { PaReservedWord(); return 0; }
"sampler3DRect" { PaReservedWord(); return 0; } "sampler3DRect" { PaReservedWord(); return 0; }
"sizeof" { PaReservedWord(); return 0; } "sizeof" { PaReservedWord(); return 0; }
"cast" { PaReservedWord(); return 0; } "cast" { PaReservedWord(); return 0; }
"namespace" { PaReservedWord(); return 0; } "namespace" { PaReservedWord(); return 0; }
"using" { PaReservedWord(); return 0; } "using" { PaReservedWord(); return 0; }
{L}({L}|{D})* { {L}({L}|{D})* {
pyylval->lex.line = yylineno; pyylval->lex.line = yylineno;
pyylval->lex.string = NewPoolTString(yytext); pyylval->lex.string = NewPoolTString(yytext);
return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); 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[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{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;} 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); } {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[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{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;} 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}+{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}+{F} { 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}{F}? { 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); } {D}+"."{D}*({E})?{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
"."{D}+({E})?{F}? { 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; }
{D}+{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return(DOUBLECONSTANT); }
"+=" { pyylval->lex.line = yylineno; return(ADD_ASSIGN); } {D}+{E}{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return(DOUBLECONSTANT); }
"-=" { pyylval->lex.line = yylineno; return(SUB_ASSIGN); } {D}+"."{D}*({E})?{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return(DOUBLECONSTANT); }
"*=" { pyylval->lex.line = yylineno; return(MUL_ASSIGN); } "."{D}+({E})?{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return(DOUBLECONSTANT); }
"/=" { pyylval->lex.line = yylineno; return(DIV_ASSIGN); }
"%=" { pyylval->lex.line = yylineno; return(MOD_ASSIGN); } "/*" { int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; }
"<<=" { pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }
">>=" { pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); } "+=" { pyylval->lex.line = yylineno; return(ADD_ASSIGN); }
"&=" { pyylval->lex.line = yylineno; return(AND_ASSIGN); } "-=" { pyylval->lex.line = yylineno; return(SUB_ASSIGN); }
"^=" { pyylval->lex.line = yylineno; return(XOR_ASSIGN); } "*=" { pyylval->lex.line = yylineno; return(MUL_ASSIGN); }
"|=" { pyylval->lex.line = yylineno; return(OR_ASSIGN); } "/=" { pyylval->lex.line = yylineno; return(DIV_ASSIGN); }
"%=" { pyylval->lex.line = yylineno; return(MOD_ASSIGN); }
"++" { pyylval->lex.line = yylineno; return(INC_OP); } "<<=" { pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }
"--" { pyylval->lex.line = yylineno; return(DEC_OP); } ">>=" { pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }
"&&" { pyylval->lex.line = yylineno; return(AND_OP); } "&=" { pyylval->lex.line = yylineno; return(AND_ASSIGN); }
"||" { pyylval->lex.line = yylineno; return(OR_OP); } "^=" { pyylval->lex.line = yylineno; return(XOR_ASSIGN); }
"^^" { pyylval->lex.line = yylineno; return(XOR_OP); } "|=" { pyylval->lex.line = yylineno; return(OR_ASSIGN); }
"<=" { pyylval->lex.line = yylineno; return(LE_OP); }
">=" { pyylval->lex.line = yylineno; return(GE_OP); } "++" { pyylval->lex.line = yylineno; return(INC_OP); }
"==" { pyylval->lex.line = yylineno; return(EQ_OP); } "--" { pyylval->lex.line = yylineno; return(DEC_OP); }
"!=" { pyylval->lex.line = yylineno; return(NE_OP); } "&&" { pyylval->lex.line = yylineno; return(AND_OP); }
"<<" { pyylval->lex.line = yylineno; return(LEFT_OP); } "||" { pyylval->lex.line = yylineno; return(OR_OP); }
">>" { pyylval->lex.line = yylineno; return(RIGHT_OP); } "^^" { pyylval->lex.line = yylineno; return(XOR_OP); }
";" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); } "<=" { pyylval->lex.line = yylineno; return(LE_OP); }
("{"|"<%") { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); } ">=" { pyylval->lex.line = yylineno; return(GE_OP); }
("}"|"%>") { pyylval->lex.line = yylineno; return(RIGHT_BRACE); } "==" { pyylval->lex.line = yylineno; return(EQ_OP); }
"," { pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); } "!=" { pyylval->lex.line = yylineno; return(NE_OP); }
":" { pyylval->lex.line = yylineno; return(COLON); } "<<" { pyylval->lex.line = yylineno; return(LEFT_OP); }
"=" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); } ">>" { pyylval->lex.line = yylineno; return(RIGHT_OP); }
"(" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); } ";" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }
")" { pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); } ("{"|"<%") { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }
("["|"<:") { pyylval->lex.line = yylineno; return(LEFT_BRACKET); } ("}"|"%>") { pyylval->lex.line = yylineno; return(RIGHT_BRACE); }
("]"|":>") { pyylval->lex.line = yylineno; return(RIGHT_BRACKET); } "," { pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }
"." { BEGIN(FIELDS); return(DOT); } ":" { pyylval->lex.line = yylineno; return(COLON); }
"!" { pyylval->lex.line = yylineno; return(BANG); } "=" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }
"-" { pyylval->lex.line = yylineno; return(DASH); } "(" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }
"~" { pyylval->lex.line = yylineno; return(TILDE); } ")" { pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }
"+" { pyylval->lex.line = yylineno; return(PLUS); } ("["|"<:") { pyylval->lex.line = yylineno; return(LEFT_BRACKET); }
"*" { pyylval->lex.line = yylineno; return(STAR); } ("]"|":>") { pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }
"/" { pyylval->lex.line = yylineno; return(SLASH); } "." { BEGIN(FIELDS); return(DOT); }
"%" { pyylval->lex.line = yylineno; return(PERCENT); } "!" { pyylval->lex.line = yylineno; return(BANG); }
"<" { pyylval->lex.line = yylineno; return(LEFT_ANGLE); } "-" { pyylval->lex.line = yylineno; return(DASH); }
">" { pyylval->lex.line = yylineno; return(RIGHT_ANGLE); } "~" { pyylval->lex.line = yylineno; return(TILDE); }
"|" { pyylval->lex.line = yylineno; return(VERTICAL_BAR); } "+" { pyylval->lex.line = yylineno; return(PLUS); }
"^" { pyylval->lex.line = yylineno; return(CARET); } "*" { pyylval->lex.line = yylineno; return(STAR); }
"&" { pyylval->lex.line = yylineno; return(AMPERSAND); } "/" { pyylval->lex.line = yylineno; return(SLASH); }
"?" { pyylval->lex.line = yylineno; return(QUESTION); } "%" { pyylval->lex.line = yylineno; return(PERCENT); }
"<" { pyylval->lex.line = yylineno; return(LEFT_ANGLE); }
<FIELDS>{L}({L}|{D})* { ">" { pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }
BEGIN(INITIAL); "|" { pyylval->lex.line = yylineno; return(VERTICAL_BAR); }
pyylval->lex.line = yylineno; "^" { pyylval->lex.line = yylineno; return(CARET); }
pyylval->lex.string = NewPoolTString(yytext); "&" { pyylval->lex.line = yylineno; return(AMPERSAND); }
return FIELD_SELECTION; } "?" { pyylval->lex.line = yylineno; return(QUESTION); }
<FIELDS>[ \t\v\f\r] {}
<FIELDS>{L}({L}|{D})* {
[ \t\v\n\f\r] { } BEGIN(INITIAL);
<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();} pyylval->lex.line = yylineno;
<*>. { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n"; pyylval->lex.string = NewPoolTString(yytext);
return 0; } return FIELD_SELECTION; }
<FIELDS>[ \t\v\f\r] {}
%%
[ \t\v\n\f\r] { }
<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}
//Including Pre-processor. <*>. { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";
extern "C" { return 0; }
#include "./preprocessor/preprocess.h"
} %%
//
// The YY_INPUT macro just calls this. Maybe this could be just put into //Including Pre-processor.
// the macro directly. extern "C" {
// #include "./preprocessor/preprocess.h"
}
int yy_input(char* buf, int max_size)
{ //
char *char_token =NULL; // The YY_INPUT macro just calls this. Maybe this could be just put into
int len; // the macro directly.
//
if ((len = yylex_CPP(buf, max_size)) == 0)
return 0; int yy_input(char* buf, int max_size)
if (len >= max_size) {
YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); char *char_token =NULL;
int len;
buf[len] = ' ';
return len+1; 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" );
//
// Parse an array of strings using yyparse. We set up globals used by buf[len] = ' ';
// yywrap. return len+1;
// }
// Returns 0 for success, as per yyparse().
//
int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal) //
{ // Parse an array of strings using yyparse. We set up globals used by
int argv0len; // yywrap.
//
ScanFromString(argv[0]); // Returns 0 for success, as per yyparse().
//
//Storing the Current Compiler Parse context into the cpp structure. int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal)
cpp->pC = (void*)&parseContextLocal; {
int argv0len;
if (!argv || argc == 0)
return 1; ScanFromString(argv[0]);
for (int i = 0; i < argc; ++i) { //Storing the Current Compiler Parse context into the cpp structure.
if (!argv[i]) { cpp->pC = (void*)&parseContextLocal;
parseContextLocal.error(0, "Null shader source string", "", "");
parseContextLocal.recover(); if (!argv || argc == 0)
return 1; return 1;
}
} for (int i = 0; i < argc; ++i) {
if (!argv[i]) {
if (!strLen) { parseContextLocal.error(0, "Null shader source string", "", "");
argv0len = (int) strlen(argv[0]); parseContextLocal.recover();
strLen = &argv0len; return 1;
} }
yyrestart(0); }
(&parseContextLocal)->AfterEOF = false;
cpp->PaWhichStr = 0; if (!strLen) {
cpp->PaArgv = argv; argv0len = (int) strlen(argv[0]);
cpp->PaArgc = argc; strLen = &argv0len;
cpp->PaStrLen = strLen; }
cpp->notAVersionToken = 0; yyrestart(0);
yylineno = 1; (&parseContextLocal)->AfterEOF = false;
cpp->PaWhichStr = 0;
if (*cpp->PaStrLen >= 0) { cpp->PaArgv = argv;
int ret; cpp->PaArgc = argc;
#ifdef _WIN32 cpp->PaStrLen = strLen;
ret = yyparse(parseContextLocal); cpp->notAVersionToken = 0;
#else yylineno = 1;
ret = yyparse((void*)(&parseContextLocal));
#endif if (*cpp->PaStrLen >= 0) {
if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0) int ret;
return 1; #ifdef _WIN32
else ret = yyparse(parseContextLocal);
return 0; #else
} ret = yyparse((void*)(&parseContextLocal));
else #endif
return 0; if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)
} return 1;
else
void yyerror(char *s) return 0;
{ }
if (((TParseContext *)cpp->pC)->AfterEOF) { else
if (cpp->tokensBeforeEOF == 1) { return 0;
GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, ""); }
GlobalParseContext->recover();
} void yyerror(char *s)
} else { {
GlobalParseContext->error(yylineno, "syntax error", yytext, s, ""); if (((TParseContext *)cpp->pC)->AfterEOF) {
GlobalParseContext->recover(); if (cpp->tokensBeforeEOF == 1) {
} GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");
} GlobalParseContext->recover();
}
void PaReservedWord() } else {
{ GlobalParseContext->error(yylineno, "syntax error", yytext, s, "");
GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", ""); GlobalParseContext->recover();
GlobalParseContext->recover(); }
} }
int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol) void PaReservedWord()
{ {
symbol = parseContextLocal.symbolTable.find(id); GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");
if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) { GlobalParseContext->recover();
TVariable* variable = static_cast<TVariable*>(symbol); }
if (variable->isUserType()) {
parseContextLocal.lexAfterType = true; int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)
return TYPE_NAME; {
} symbol = parseContextLocal.symbolTable.find(id);
} if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol);
return IDENTIFIER; if (variable->isUserType()) {
} parseContextLocal.lexAfterType = true;
return TYPE_NAME;
int PaParseComment(int &lineno, TParseContext& parseContextLocal) }
{ }
int transitionFlag = 0;
int nextChar; return IDENTIFIER;
}
while (transitionFlag != 2) {
nextChar = yyinput(); int PaParseComment(int &lineno, TParseContext& parseContextLocal)
if (nextChar == '\n') {
lineno++; int transitionFlag = 0;
switch (nextChar) { int nextChar;
case '*' :
transitionFlag = 1; while (transitionFlag != 2) {
break; nextChar = yyinput();
case '/' : /* if star is the previous character, then it is the end of comment */ if (nextChar == '\n')
if (transitionFlag == 1) { lineno++;
return 1 ; switch (nextChar) {
} case '*' :
break; transitionFlag = 1;
case EOF : break;
/* Raise error message here */ case '/' : /* if star is the previous character, then it is the end of comment */
parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", ""); if (transitionFlag == 1) {
GlobalParseContext->recover(); return 1 ;
return YY_NULL; }
default : /* Any other character will be a part of the comment */ break;
transitionFlag = 0; case EOF :
} /* Raise error message here */
} parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");
return 1; GlobalParseContext->recover();
} return YY_NULL;
default : /* Any other character will be a part of the comment */
extern "C" { transitionFlag = 0;
}
void CPPDebugLogMsg(const char *msg) }
{ return 1;
((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg); }
}
extern "C" {
void CPPWarningToInfoLog(const char *msg)
{ void CPPDebugLogMsg(const char *msg)
((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno); {
} ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);
}
void CPPShInfoLogMsg(const char *msg)
{ void CPPWarningToInfoLog(const char *msg)
((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,""); {
GlobalParseContext->recover(); ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno);
} }
void CPPErrorToInfoLog(char *msg) void CPPShInfoLogMsg(const char *msg)
{ {
((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,""); ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");
GlobalParseContext->recover(); GlobalParseContext->recover();
} }
void SetLineNumber(int line) void CPPErrorToInfoLog(char *msg)
{ {
yylineno &= ~SourceLocLineMask; ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");
yylineno |= line; GlobalParseContext->recover();
} }
void SetStringNumber(int string) void SetLineNumber(int line)
{ {
yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask); yylineno &= ~SourceLocLineMask;
} yylineno |= line;
}
int GetStringNumber(void)
{ void SetStringNumber(int string)
return yylineno >> 16; {
} yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);
}
int GetLineNumber(void)
{ int GetStringNumber(void)
return yylineno & SourceLocLineMask; {
} return yylineno >> 16;
}
void IncLineNumber(void)
{ int GetLineNumber(void)
if ((yylineno & SourceLocLineMask) <= SourceLocLineMask) {
++yylineno; return yylineno & SourceLocLineMask;
} }
void DecLineNumber(void) void IncLineNumber(void)
{ {
if ((yylineno & SourceLocLineMask) > 0) if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)
--yylineno; ++yylineno;
} }
void HandlePragma(const char **tokens, int numTokens) void DecLineNumber(void)
{ {
if (!strcmp(tokens[0], "optimize")) { if ((yylineno & SourceLocLineMask) > 0)
if (numTokens != 4) { --yylineno;
CPPShInfoLogMsg("optimize pragma syntax is incorrect"); }
return;
} void HandlePragma(const char **tokens, int numTokens)
{
if (strcmp(tokens[1], "(")) { if (!strcmp(tokens[0], "optimize")) {
CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword"); if (numTokens != 4) {
return; CPPShInfoLogMsg("optimize pragma syntax is incorrect");
} return;
}
if (!strcmp(tokens[2], "on"))
((TParseContext *)cpp->pC)->contextPragma.optimize = true; if (strcmp(tokens[1], "(")) {
else if (!strcmp(tokens[2], "off")) CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");
((TParseContext *)cpp->pC)->contextPragma.optimize = false; return;
else { }
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
return; if (!strcmp(tokens[2], "on"))
} ((TParseContext *)cpp->pC)->contextPragma.optimize = true;
else if (!strcmp(tokens[2], "off"))
if (strcmp(tokens[3], ")")) { ((TParseContext *)cpp->pC)->contextPragma.optimize = false;
CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma"); else {
return; CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
} return;
} else if (!strcmp(tokens[0], "debug")) { }
if (numTokens != 4) {
CPPShInfoLogMsg("debug pragma syntax is incorrect"); if (strcmp(tokens[3], ")")) {
return; CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");
} return;
}
if (strcmp(tokens[1], "(")) { } else if (!strcmp(tokens[0], "debug")) {
CPPShInfoLogMsg("\"(\" expected after 'debug' keyword"); if (numTokens != 4) {
return; CPPShInfoLogMsg("debug pragma syntax is incorrect");
} return;
}
if (!strcmp(tokens[2], "on"))
((TParseContext *)cpp->pC)->contextPragma.debug = true; if (strcmp(tokens[1], "(")) {
else if (!strcmp(tokens[2], "off")) CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");
((TParseContext *)cpp->pC)->contextPragma.debug = false; return;
else { }
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
return; if (!strcmp(tokens[2], "on"))
} ((TParseContext *)cpp->pC)->contextPragma.debug = true;
else if (!strcmp(tokens[2], "off"))
if (strcmp(tokens[3], ")")) { ((TParseContext *)cpp->pC)->contextPragma.debug = false;
CPPShInfoLogMsg("\")\" expected to end 'debug' pragma"); else {
return; CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
} return;
} else { }
#ifdef PRAGMA_TABLE if (strcmp(tokens[3], ")")) {
// CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");
// implementation specific pragma return;
// use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma }
// For now, just ignore the pragma that the implementation cannot recognize } else {
// An Example of one such implementation for a pragma that has a syntax like
// #pragma pragmaname(pragmavalue) #ifdef PRAGMA_TABLE
// This implementation stores the current pragmavalue against the pragma name in pragmaTable. //
// // implementation specific pragma
if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) { // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma
TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable; // For now, just ignore the pragma that the implementation cannot recognize
TPragmaTable::iterator iter; // An Example of one such implementation for a pragma that has a syntax like
iter = pragmaTable.find(TString(tokens[0])); // #pragma pragmaname(pragmavalue)
if (iter != pragmaTable.end()) { // This implementation stores the current pragmavalue against the pragma name in pragmaTable.
iter->second = tokens[2]; //
} else { if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) {
pragmaTable[tokens[0]] = tokens[2]; TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
} TPragmaTable::iterator iter;
} else if (numTokens >= 2) { iter = pragmaTable.find(TString(tokens[0]));
TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable; if (iter != pragmaTable.end()) {
TPragmaTable::iterator iter; iter->second = tokens[2];
iter = pragmaTable.find(TString(tokens[0])); } else {
if (iter != pragmaTable.end()) { pragmaTable[tokens[0]] = tokens[2];
iter->second = tokens[1]; }
} else { } else if (numTokens >= 2) {
pragmaTable[tokens[0]] = tokens[1]; TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
} TPragmaTable::iterator iter;
} iter = pragmaTable.find(TString(tokens[0]));
#endif // PRAGMA_TABLE if (iter != pragmaTable.end()) {
} iter->second = tokens[1];
} } else {
pragmaTable[tokens[0]] = tokens[1];
void StoreStr(char *string) }
{ }
TString strSrc; #endif // PRAGMA_TABLE
strSrc = TString(string); }
}
((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;
} void StoreStr(char *string)
{
const char* GetStrfromTStr(void) TString strSrc;
{ strSrc = TString(string);
cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();
return cpp->ErrMsg; ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;
} }
void ResetTString(void) const char* GetStrfromTStr(void)
{ {
((TParseContext *)cpp->pC)->HashErrMsg = ""; cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();
} return cpp->ErrMsg;
}
TBehavior GetBehavior(const char* behavior)
{ void ResetTString(void)
if (!strcmp("require", behavior)) {
return EBhRequire; ((TParseContext *)cpp->pC)->HashErrMsg = "";
else if (!strcmp("enable", behavior)) }
return EBhEnable;
else if (!strcmp("disable", behavior)) TBehavior GetBehavior(const char* behavior)
return EBhDisable; {
else if (!strcmp("warn", behavior)) if (!strcmp("require", behavior))
return EBhWarn; return EBhRequire;
else { else if (!strcmp("enable", behavior))
CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str()); return EBhEnable;
return EBhDisable; else if (!strcmp("disable", behavior))
} return EBhDisable;
} else if (!strcmp("warn", behavior))
return EBhWarn;
void updateExtensionBehavior(const char* extName, const char* behavior) else {
{ CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());
TBehavior behaviorVal = GetBehavior(behavior); return EBhDisable;
TMap<TString, TBehavior>:: iterator iter; }
TString msg; }
// special cased for all extension void updateExtensionBehavior(const char* extName, const char* behavior)
if (!strcmp(extName, "all")) { {
if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) { TBehavior behaviorVal = GetBehavior(behavior);
CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior"); TMap<TString, TBehavior>:: iterator iter;
return; TString msg;
} else {
for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter) // special cased for all extension
iter->second = behaviorVal; if (!strcmp(extName, "all")) {
} if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {
} else { CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");
iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName)); return;
if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) { } else {
switch (behaviorVal) { for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)
case EBhRequire: iter->second = behaviorVal;
CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str()); }
break; } else {
case EBhEnable: iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));
case EBhWarn: if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {
case EBhDisable: switch (behaviorVal) {
msg = TString("extension '") + extName + "' is not supported"; case EBhRequire:
((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());
break; break;
} case EBhEnable:
return; case EBhWarn:
} else case EBhDisable:
iter->second = behaviorVal; msg = TString("extension '") + extName + "' is not supported";
} ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
} break;
}
} // extern "C" return;
} else
void setInitialState() iter->second = behaviorVal;
{ }
yy_start = 1; }
}
} // extern "C"
void setInitialState()
{
yy_start = 1;
}
...@@ -93,6 +93,7 @@ Jutta Degener, 1995 ...@@ -93,6 +93,7 @@ Jutta Degener, 1995
float f; float f;
int i; int i;
bool b; bool b;
double d;
}; };
TSymbol* symbol; TSymbol* symbol;
} lex; } lex;
...@@ -278,8 +279,8 @@ primary_expression ...@@ -278,8 +279,8 @@ primary_expression
} }
| DOUBLECONSTANT { | DOUBLECONSTANT {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setFConst($1.f); unionArray->setDConst($1.d);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.line);
} }
| BOOLCONSTANT { | BOOLCONSTANT {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
...@@ -1825,7 +1826,7 @@ type_specifier_nonarray ...@@ -1825,7 +1826,7 @@ type_specifier_nonarray
| DOUBLE { | DOUBLE {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
// TODO: implement EbtDouble, check all float types // TODO: implement EbtDouble, check all float types
$$.setBasic(EbtFloat, qual, $1.line); $$.setBasic(EbtDouble, qual, $1.line);
} }
| INT { | INT {
// TODO: implement EbtUint, check all int types // TODO: implement EbtUint, check all int types
......
...@@ -380,6 +380,15 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) ...@@ -380,6 +380,15 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
out.debug << buf << "\n"; out.debug << buf << "\n";
} }
break; break;
case EbtDouble:
{
const int maxSize = 300;
char buf[maxSize];
sprintf_s(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getDConst(), "const double");
out.debug << buf << "\n";
}
break;
case EbtInt: case EbtInt:
{ {
const int maxSize = 300; const int maxSize = 300;
......
...@@ -127,6 +127,10 @@ struct CPPStruct_Rec { ...@@ -127,6 +127,10 @@ struct CPPStruct_Rec {
int PaArgc; // count of strings in the array int PaArgc; // count of strings in the array
char** PaArgv; // our array of strings to parse char** PaArgv; // our array of strings to parse
unsigned int tokensBeforeEOF : 1; unsigned int tokensBeforeEOF : 1;
// Declared version of the shader
int version;
int profileAtom;
}; };
#endif // !defined(__COMPILE_H) #endif // !defined(__COMPILE_H)
...@@ -115,6 +115,9 @@ static int __LINE__Atom = 0; ...@@ -115,6 +115,9 @@ static int __LINE__Atom = 0;
static int __FILE__Atom = 0; static int __FILE__Atom = 0;
static int __VERSION__Atom = 0; static int __VERSION__Atom = 0;
static int versionAtom = 0; static int versionAtom = 0;
static int coreAtom = 0;
static int compatibilityAtom = 0;
static int esAtom = 0;
static int extensionAtom = 0; static int extensionAtom = 0;
static Scope *macros = 0; static Scope *macros = 0;
...@@ -149,6 +152,9 @@ int InitCPP(void) ...@@ -149,6 +152,9 @@ int InitCPP(void)
__FILE__Atom = LookUpAddString(atable, "__FILE__"); __FILE__Atom = LookUpAddString(atable, "__FILE__");
__VERSION__Atom = LookUpAddString(atable, "__VERSION__"); __VERSION__Atom = LookUpAddString(atable, "__VERSION__");
versionAtom = LookUpAddString(atable, "version"); versionAtom = LookUpAddString(atable, "version");
coreAtom = LookUpAddString(atable, "core");
compatibilityAtom = LookUpAddString(atable, "compatibility");
esAtom = LookUpAddString(atable, "es");
extensionAtom = LookUpAddString(atable, "extension"); extensionAtom = LookUpAddString(atable, "extension");
macros = NewScopeInPool(mem_CreatePool(0, 0)); macros = NewScopeInPool(mem_CreatePool(0, 0));
strcpy(buffer, "PROFILE_"); strcpy(buffer, "PROFILE_");
...@@ -660,8 +666,6 @@ static int CPPpragma(yystypepp * yylvalpp) ...@@ -660,8 +666,6 @@ static int CPPpragma(yystypepp * yylvalpp)
return token; return token;
} // CPPpragma } // CPPpragma
#define GL2_VERSION_NUMBER 110
static int CPPversion(yystypepp * yylvalpp) static int CPPversion(yystypepp * yylvalpp)
{ {
...@@ -680,10 +684,8 @@ static int CPPversion(yystypepp * yylvalpp) ...@@ -680,10 +684,8 @@ static int CPPversion(yystypepp * yylvalpp)
CPPErrorToInfoLog("#version"); CPPErrorToInfoLog("#version");
yylvalpp->sc_int=atoi(yylvalpp->symbol_name); yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
//SetVersionNumber(yylvalpp->sc_int);
cpp->version = yylvalpp->sc_int;
if (yylvalpp->sc_int != GL2_VERSION_NUMBER)
CPPShInfoLogMsg("Version number not supported by GL2");
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
...@@ -691,8 +693,20 @@ static int CPPversion(yystypepp * yylvalpp) ...@@ -691,8 +693,20 @@ static int CPPversion(yystypepp * yylvalpp)
return token; return token;
} }
else{ else{
CPPErrorToInfoLog("#version"); cpp->profileAtom = yylvalpp->sc_ident;
if (cpp->profileAtom != coreAtom &&
cpp->profileAtom != compatibilityAtom &&
cpp->profileAtom != esAtom)
CPPErrorToInfoLog("#version profile name");
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token == '\n')
return token;
else
CPPErrorToInfoLog("#version");
} }
return token; return token;
} // CPPversion } // CPPversion
......
...@@ -132,6 +132,8 @@ int ResetPreprocessor(void) ...@@ -132,6 +132,8 @@ int ResetPreprocessor(void)
cpp->elsedepth[cpp->elsetracker]=0; cpp->elsedepth[cpp->elsetracker]=0;
cpp->elsetracker=0; cpp->elsetracker=0;
cpp->tokensBeforeEOF = 0; cpp->tokensBeforeEOF = 0;
cpp->version = 110;
cpp->profileAtom = 0;
return 1; return 1;
} }
......
...@@ -82,6 +82,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -82,6 +82,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
typedef struct { typedef struct {
int sc_int; int sc_int;
float sc_fval; float sc_fval;
double sc_dval;
int sc_ident; int sc_ident;
char symbol_name[MAX_SYMBOL_NAME_LEN+1]; char symbol_name[MAX_SYMBOL_NAME_LEN+1];
} yystypepp; } yystypepp;
......
...@@ -225,47 +225,9 @@ int ScanFromString(char *s) ...@@ -225,47 +225,9 @@ int ScanFromString(char *s)
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Floating point constants: ///////////////////////////////// /////////////////////////////////// Floating point constants: /////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/*
* lBuildFloatValue() - Quick and dirty conversion to floating point. Since all
* we need is single precision this should be quite precise.
*/
static float lBuildFloatValue(const char *str, int len, int exp)
{
double val, expval, ten;
int ii, llen, absexp;
float rv;
val = 0.0;
llen = len;
for (ii = 0; ii < len; ii++)
val = val*10.0 + (str[ii] - '0');
if (exp != 0) {
absexp = exp > 0 ? exp : -exp;
expval = 1.0f;
ten = 10.0;
while (absexp) {
if (absexp & 1)
expval *= ten;
ten *= ten;
absexp >>= 1;
}
if (exp >= 0) {
val *= expval;
} else {
val /= expval;
}
}
rv = (float)val;
if (isinff(rv)) {
CPPErrorToInfoLog(" ERROR___FP_CONST_OVERFLOW");
}
return rv;
} // lBuildFloatValue
/* /*
* lFloatConst() - Scan a floating point constant. Assumes that the scanner * lFloatConst() - Scan a single- or double-precision floating point constant. Assumes that the scanner
* has seen at least one digit, followed by either a decimal '.' or the * has seen at least one digit, followed by either a decimal '.' or the
* letter 'e'. * letter 'e'.
*/ */
...@@ -274,7 +236,6 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) ...@@ -274,7 +236,6 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
{ {
int HasDecimal, declen, exp, ExpSign; int HasDecimal, declen, exp, ExpSign;
int str_len; int str_len;
float lval;
HasDecimal = 0; HasDecimal = 0;
declen = 0; declen = 0;
...@@ -303,41 +264,76 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) ...@@ -303,41 +264,76 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
// Exponent: // Exponent:
if (ch == 'e' || ch == 'E') { if (ch == 'e' || ch == 'E') {
ExpSign = 1; if (len >= MAX_SYMBOL_NAME_LEN) {
str[len++]=ch; CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); len = 1,str_len=1;
if (ch == '+') { } else {
str[len++]=ch; ExpSign = 1;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); str[len++]=ch;
} else if (ch == '-') {
ExpSign = -1;
str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} if (ch == '+') {
if (ch >= '0' && ch <= '9') { str[len++]=ch;
while (ch >= '0' && ch <= '9') { ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
exp = exp*10 + ch - '0'; } else if (ch == '-') {
str[len++]=ch; ExpSign = -1;
str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} }
} else { if (ch >= '0' && ch <= '9') {
CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT"); while (ch >= '0' && ch <= '9') {
if (len < MAX_SYMBOL_NAME_LEN) {
exp = exp*10 + ch - '0';
str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} else {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
len = 1,str_len=1;
}
}
} else {
CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT");
}
exp *= ExpSign;
} }
exp *= ExpSign;
} }
if (len == 0) { if (len == 0) {
lval = 0.0f; yylvalpp->sc_fval = 0.0f;
yylvalpp->sc_dval = 0.0;
strcpy(str,"0.0"); strcpy(str,"0.0");
} else { } else {
if (ch == 'l' || ch == 'L') {
int ch2 = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch2 != 'f' && ch2 != 'F') {
cpp->currentInput->ungetch(cpp->currentInput, ch2, yylvalpp);
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
} else {
if (len < MAX_SYMBOL_NAME_LEN-1) {
str[len++] = ch;
str[len++] = ch2;
} else {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
len = 1,str_len=1;
}
}
} else if (ch == 'f' || ch == 'F') {
if (len < MAX_SYMBOL_NAME_LEN)
str[len++] = ch;
else {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
len = 1,str_len=1;
}
} else
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
str[len]='\0'; str[len]='\0';
lval = lBuildFloatValue(str, str_len, exp - declen);
yylvalpp->sc_dval = strtod(str, 0);
yylvalpp->sc_fval = (float)yylvalpp->sc_dval;
} }
// Suffix: // Suffix:
yylvalpp->sc_fval = lval;
strcpy(yylvalpp->symbol_name,str); strcpy(yylvalpp->symbol_name,str);
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return CPP_FLOATCONSTANT; return CPP_FLOATCONSTANT;
} // lFloatConst } // lFloatConst
...@@ -454,7 +450,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -454,7 +450,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
} }
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} while (ch >= '0' && ch <= '7'); } while (ch >= '0' && ch <= '7');
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E' || ch == 'F' || ch == 'l' || ch == 'L')
return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp); return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
yylvalpp->symbol_name[len] = '\0'; yylvalpp->symbol_name[len] = '\0';
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
...@@ -476,7 +472,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -476,7 +472,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} }
} while (ch >= '0' && ch <= '9'); } while (ch >= '0' && ch <= '9');
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') { if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E' || ch == 'F' || ch == 'l' || ch == 'L') {
return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp); return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
} else { } else {
yylvalpp->symbol_name[len] = '\0'; yylvalpp->symbol_name[len] = '\0';
......
...@@ -83,6 +83,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -83,6 +83,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
typedef struct CPPStruct_Rec CPPStruct; typedef struct CPPStruct_Rec CPPStruct;
// Multi-threading note: The existence of this global makes
// this preprocessing single-threaded only.
extern CPPStruct *cpp; extern CPPStruct *cpp;
#undef CPPC_DEBUG_THE_COMPILER #undef CPPC_DEBUG_THE_COMPILER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment