Mesa (glsl2): glsl2: Make lowp, mediump, highp, and precision identifiers pre-1.20.

Eric Anholt anholt at kemper.freedesktop.org
Thu Jul 29 00:32:55 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 192b57df8c451c7ae39e5471124a9bab36ec17f8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=192b57df8c451c7ae39e5471124a9bab36ec17f8

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Jul 28 16:11:26 2010 -0700

glsl2: Make lowp, mediump, highp, and precision identifiers pre-1.20.

Fixes glsl-precision-110.

---

 src/glsl/glsl_lexer.cpp |   52 ++++++++++++++++++++++++++++++++++++----------
 src/glsl/glsl_lexer.lpp |   36 ++++++++++++++++++++++++++++---
 2 files changed, 72 insertions(+), 16 deletions(-)

diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp
index ecb4b85..e5ca1bd 100644
--- a/src/glsl/glsl_lexer.cpp
+++ b/src/glsl/glsl_lexer.cpp
@@ -1994,26 +1994,54 @@ return USING;
 case 140:
 YY_RULE_SETUP
 #line 321 "glsl_lexer.lpp"
-return LOWP;
+{
+		  if (yyextra->language_version >= 120){
+		      return LOWP;
+		   } else {
+		      yylval->identifier = strdup(yytext);
+		      return IDENTIFIER;
+		   }
+		}
 	YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 322 "glsl_lexer.lpp"
-return MEDIUMP;
+#line 329 "glsl_lexer.lpp"
+{
+		  if (yyextra->language_version >= 120){
+		      return MEDIUMP;
+		   } else {
+		      yylval->identifier = strdup(yytext);
+		      return IDENTIFIER;
+		   }
+		}return MEDIUMP;
 	YY_BREAK
 case 142:
 YY_RULE_SETUP
-#line 323 "glsl_lexer.lpp"
-return HIGHP;
+#line 337 "glsl_lexer.lpp"
+{
+		  if (yyextra->language_version >= 120){
+		      return HIGHP;
+		   } else {
+		      yylval->identifier = strdup(yytext);
+		      return IDENTIFIER;
+		   }
+		}
 	YY_BREAK
 case 143:
 YY_RULE_SETUP
-#line 324 "glsl_lexer.lpp"
-return PRECISION;
+#line 345 "glsl_lexer.lpp"
+{
+		  if (yyextra->language_version >= 120){
+		      return PRECISION;
+		   } else {
+		      yylval->identifier = strdup(yytext);
+		      return IDENTIFIER;
+		   }
+		}
 	YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 326 "glsl_lexer.lpp"
+#line 354 "glsl_lexer.lpp"
 {
 			    struct _mesa_glsl_parse_state *state = yyextra;
 			    void *ctx = state;	
@@ -2023,15 +2051,15 @@ YY_RULE_SETUP
 	YY_BREAK
 case 145:
 YY_RULE_SETUP
-#line 333 "glsl_lexer.lpp"
+#line 361 "glsl_lexer.lpp"
 { return yytext[0]; }
 	YY_BREAK
 case 146:
 YY_RULE_SETUP
-#line 335 "glsl_lexer.lpp"
+#line 363 "glsl_lexer.lpp"
 ECHO;
 	YY_BREAK
-#line 2035 "glsl_lexer.cpp"
+#line 2063 "glsl_lexer.cpp"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(PP):
 	yyterminate();
@@ -3173,7 +3201,7 @@ void _mesa_glsl_free (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 335 "glsl_lexer.lpp"
+#line 363 "glsl_lexer.lpp"
 
 
 
diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp
index ebfea37..702e79a 100644
--- a/src/glsl/glsl_lexer.lpp
+++ b/src/glsl/glsl_lexer.lpp
@@ -318,10 +318,38 @@ namespace	return NAMESPACE;
 using		return USING;
 
     /* Additional reserved words in GLSL 1.20. */
-lowp		return LOWP;
-mediump		return MEDIUMP;
-highp		return HIGHP;
-precision	return PRECISION;
+lowp		{
+		  if (yyextra->language_version >= 120){
+		      return LOWP;
+		   } else {
+		      yylval->identifier = strdup(yytext);
+		      return IDENTIFIER;
+		   }
+		}
+mediump		{
+		  if (yyextra->language_version >= 120){
+		      return MEDIUMP;
+		   } else {
+		      yylval->identifier = strdup(yytext);
+		      return IDENTIFIER;
+		   }
+		}return MEDIUMP;
+highp		{
+		  if (yyextra->language_version >= 120){
+		      return HIGHP;
+		   } else {
+		      yylval->identifier = strdup(yytext);
+		      return IDENTIFIER;
+		   }
+		}
+precision	{
+		  if (yyextra->language_version >= 120){
+		      return PRECISION;
+		   } else {
+		      yylval->identifier = strdup(yytext);
+		      return IDENTIFIER;
+		   }
+		}
 
 [_a-zA-Z][_a-zA-Z0-9]*	{
 			    struct _mesa_glsl_parse_state *state = yyextra;




More information about the mesa-commit mailing list