Classify more keywords as to what versions they are identifiers, reserved, or keywords.
authorJohn Kessenich <cepheus@frii.com>
Tue, 12 Feb 2013 06:53:13 +0000 (06:53 +0000)
committerJohn Kessenich <cepheus@frii.com>
Tue, 12 Feb 2013 06:53:13 +0000 (06:53 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20540 e7fa87d3-cd2b-0410-9028-fcbf551c1848

Test/specExamples.vert
glslang/MachineIndependent/ParseHelper.h
glslang/MachineIndependent/glslang.l

index c8eb75f..ab51872 100644 (file)
@@ -1,4 +1,4 @@
-#version 150\r
+#version 430\r
 \r
 #extension GL_3DL_array_objects : enable\r
 \r
index 18adf8d..8ed61a6 100644 (file)
@@ -151,8 +151,6 @@ struct TParseContext {
 };
 
 int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&);
-void PaReservedWord();
-int PaIdentOrType(TString& id, TParseContext&, TSymbol*&);
 int PaParseComment(int &lineno, TParseContext&);
 void ResetFlex();
 
index 061062b..351e29f 100644 (file)
@@ -69,7 +69,10 @@ LF          [lL][fF]
 #include "ParseHelper.h"\r
 #include "glslang_tab.cpp.h"\r
 \r
+int PaReservedWord();\r
+int PaIdentOrType(TString& id, TParseContext&, TSymbol*&);\r
 int PaIdentOrReserved(bool reserved, TParseContext&, int line, const char* text, YYSTYPE* pyylval);\r
+int PaES30ReservedFromGLSL(int version, TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int keyword);\r
 int PaPrecisionKeyword(TParseContext&, int line, const char* text, YYSTYPE* pyylval, int keyword);\r
 int PaMatNxM(TParseContext&, int line, const char* text, YYSTYPE* pyylval, int keyword);\r
 int PaDMat(TParseContext&, int line, const char* text, YYSTYPE* pyylval, int keyword);\r
@@ -104,18 +107,22 @@ int yy_input(char* buf, int max_size);
 %%\r
 <*>"//"[^\n]*"\n"     { /* ?? carriage and/or line-feed? */ };\r
 \r
-"attribute"    {  pyylval->lex.line = yylineno; return(ATTRIBUTE); }\r
+"attribute"    {  pyylval->lex.line = yylineno; return(ATTRIBUTE); }  // TODO ES 30 reserved\r
 "const"        {  pyylval->lex.line = yylineno; return(CONST); }\r
 "uniform"      {  pyylval->lex.line = yylineno; return(UNIFORM); }\r
-"varying"      {  pyylval->lex.line = yylineno; return(VARYING); }\r
+"varying"      {  pyylval->lex.line = yylineno; return(VARYING); }    // TODO ES 30 reserved\r
 "buffer"       {  pyylval->lex.line = yylineno; return(BUFFER); }\r
 "shared"       {  pyylval->lex.line = yylineno; return(SHARED); }\r
 \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
+"coherent"     {  return PaES30ReservedFromGLSL(420, parseContext, yylineno, yytext, pyylval, COHERENT); }\r
+"volatile"     {  if (parseContext.profile == EEsProfile || parseContext.version < 420) \r
+                      return PaReservedWord();    \r
+                  else\r
+                       pyylval->lex.line = yylineno; return(VOLATILE); \r
+               }\r
+"restrict"     {  return PaES30ReservedFromGLSL(420, parseContext, yylineno, yytext, pyylval, RESTRICT); }\r
+"readonly"     {  return PaES30ReservedFromGLSL(420, parseContext, yylineno, yytext, pyylval, READONLY); }\r
+"writeonly"    {  return PaES30ReservedFromGLSL(420, parseContext, yylineno, yytext, pyylval, WRITEONLY); }\r
 \r
 "layout"       {  pyylval->lex.line = yylineno; return(LAYOUT); }\r
 \r
@@ -124,8 +131,8 @@ int yy_input(char* buf, int max_size);
 "smooth"        {  pyylval->lex.line = yylineno; return(SMOOTH); }\r
 "noperspective" {  pyylval->lex.line = yylineno; return(NOPERSPECTIVE); }\r
 \r
-"patch"        {  pyylval->lex.line = yylineno; return(PATCH); }\r
-"sample"       {  pyylval->lex.line = yylineno; return(SAMPLE); }\r
+"patch"        {  return PaES30ReservedFromGLSL(400, parseContext, yylineno, yytext, pyylval, PATCH); }\r
+"sample"       {  return PaES30ReservedFromGLSL(400, parseContext, yylineno, yytext, pyylval, SAMPLE); }\r
 \r
 "break"        {  pyylval->lex.line = yylineno; return(BREAK); }\r
 "continue"     {  pyylval->lex.line = yylineno; return(CONTINUE); }\r
@@ -139,7 +146,7 @@ int yy_input(char* buf, int max_size);
 "if"           {  pyylval->lex.line = yylineno; return(IF); }\r
 "else"         {  pyylval->lex.line = yylineno; return(ELSE); }\r
 \r
-"subroutine"   {  pyylval->lex.line = yylineno; return(SUBROUTINE); }\r
+"subroutine"   {  return PaES30ReservedFromGLSL(400, parseContext, yylineno, yytext, pyylval, SUBROUTINE); }\r
 \r
 "in"           {  pyylval->lex.line = yylineno; return(IN); }\r
 "out"          {  pyylval->lex.line = yylineno; return(OUT); }\r
@@ -165,7 +172,7 @@ int yy_input(char* buf, int max_size);
 "discard"      {  pyylval->lex.line = yylineno; return(DISCARD); }\r
 "return"       {  pyylval->lex.line = yylineno; return(RETURN); }\r
 \r
-"atomic_uint"  { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(ATOMIC_UINT); }\r
+"atomic_uint"  { return PaES30ReservedFromGLSL(420, parseContext, yylineno, yytext, pyylval, ATOMIC_UINT); }\r
 \r
 "mat2"         { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT2); }\r
 "mat3"         { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MAT3); }\r
@@ -294,7 +301,10 @@ int yy_input(char* buf, int max_size);
 "this"         {  PaReservedWord(); return 0; }\r
 "packed"       {  PaReservedWord(); return 0; }\r
 \r
-"resource"     {  PaReservedWord(); return 0; }\r
+"resource"     {  if (parseContext.profile == EEsProfile && parseContext.version >= 300 ||\r
+                      parseContext.profile != EEsProfile && parseContext.version >= 420)    \r
+                          return PaReservedWord();\r
+               }\r
 \r
 "goto"         {  PaReservedWord(); return 0; }\r
 \r
@@ -520,10 +530,12 @@ void yyerror(char *s)
     }\r
 }\r
 \r
-void PaReservedWord()\r
+int PaReservedWord()\r
 {\r
     GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");\r
     GlobalParseContext->recover();\r
+\r
+    return 0;\r
 }\r
 \r
 int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)\r
@@ -547,10 +559,32 @@ int PaIdentOrReserved(bool reserved, TParseContext& pc, int line, const char* te
 \r
     pyylval->lex.line = line;\r
     pyylval->lex.string = NewPoolTString(text);\r
+    pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
+    pc.infoSink.info.message(EPrefixWarning, "using future reserved keyword", yylineno);\r
 \r
     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);\r
 }\r
 \r
+int PaES30ReservedFromGLSL(int version, TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int keyword)\r
+{\r
+    if (pc.profile == EEsProfile && pc.version < 300 ||\r
+        pc.profile != EEsProfile && pc.version < version) {\r
+            pyylval->lex.line = yylineno;\r
+            pyylval->lex.string = NewPoolTString(yytext);\r
+            pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
+            pc.infoSink.info.message(EPrefixWarning, "future reserved word in ES 300 and keyword in GLSL", yylineno);\r
+\r
+            return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);\r
+    } else if (pc.profile == EEsProfile && pc.version >= 300)\r
+\r
+        return PaReservedWord();\r
+    else {\r
+        pyylval->lex.line = yylineno;\r
+\r
+        return keyword;\r
+    }\r
+}\r
+\r
 int PaPrecisionKeyword(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int keyword)\r
 {\r
     if (pc.profile == EEsProfile || pc.version >= 130)\r
@@ -558,7 +592,9 @@ int PaPrecisionKeyword(TParseContext& pc, int line, const char* text, YYSTYPE* p
 \r
     pyylval->lex.line = line;\r
     pyylval->lex.string = NewPoolTString(text);\r
-    \r
+    pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
+    pc.infoSink.info.message(EPrefixWarning, "using ES precision qualifier keyword", yylineno);\r
+\r
     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);\r
 }\r
 \r
@@ -569,6 +605,8 @@ int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, in
 \r
     pyylval->lex.line = line;\r
     pyylval->lex.string = NewPoolTString(text);\r
+    pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
+    pc.infoSink.info.message(EPrefixWarning, "using future non-square matrix type keyword", yylineno);\r
 \r
     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);\r
 }\r
@@ -582,9 +620,11 @@ int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int
 \r
     if (pc.profile != EEsProfile && pc.version >= 400)\r
         return keyword;\r
-    \r
+\r
     pyylval->lex.line = line;\r
     pyylval->lex.string = NewPoolTString(text);\r
+    pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
+    pc.infoSink.info.message(EPrefixWarning, "using future type keyword", yylineno);\r
 \r
     return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);\r
 }\r