Mesa (master): glsl: Switch from the deprecated YYLEX_PARAM to %lex-param.

Kenneth Graunke kwg at kemper.freedesktop.org
Wed Jul 31 18:59:50 UTC 2013


Module: Mesa
Branch: master
Commit: f043381334a0760ec118d07b6fb7785b5692572a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f043381334a0760ec118d07b6fb7785b5692572a

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon Jul 29 15:28:59 2013 -0700

glsl: Switch from the deprecated YYLEX_PARAM to %lex-param.

YYLEX_PARAM is no longer supported as of Bison 3.0.  Instead, the Bison
developers recommend using %lex-param.

%lex-param takes a type and variable name, similar to %parse-param,
so you can't pass an arbitrary expression like state->scanner.  But Flex
insists on passing the actual scanner object, not an arbitrary object
like state.

To solve this, the parser defines a wrapper lex() function which accepts
"state," and calls Flex's lex() function with state->scanner.

Fixes the build with Bison 3.0.  Also works with Bison 2.7.1.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67354
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Tested-by: Laurent Carlier <lordheavym at gmail.com>
Cc: "9.2" mesa-stable at lists.freedesktop.org

---

 src/glsl/glsl_parser.yy |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 0b16d1d..fcc5620 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -31,8 +31,6 @@
 #include "glsl_types.h"
 #include "main/context.h"
 
-#define YYLEX_PARAM state->scanner
-
 #undef yyerror
 
 static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
@@ -41,9 +39,9 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
 }
 
 static int
-_mesa_glsl_lex(YYSTYPE *val, YYLTYPE *loc, void *scanner)
+_mesa_glsl_lex(YYSTYPE *val, YYLTYPE *loc, _mesa_glsl_parse_state *state)
 {
-   return _mesa_glsl_lexer_lex(val, loc, scanner);
+   return _mesa_glsl_lexer_lex(val, loc, state->scanner);
 }
 %}
 
@@ -61,7 +59,7 @@ _mesa_glsl_lex(YYSTYPE *val, YYLTYPE *loc, void *scanner)
    @$.source = 0;
 }
 
-%lex-param   {void *scanner}
+%lex-param   {struct _mesa_glsl_parse_state *state}
 %parse-param {struct _mesa_glsl_parse_state *state}
 
 %union {




More information about the mesa-commit mailing list