We have arranged for the lexer function to receive an argument of type
struct _mesa_gls_parse_state* but it comes in as "void *yyextra".

By including code immediately after the %% separator, we can declare a local
variable of the correct type and name, ("state"), to hold this value for use
by all actions.

This is much simpler than redeclaring the state variable and assigning to it
in multiple actions.
---
 src/glsl/glsl_lexer.ll |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index 04cc778..ac06fd2 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -162,6 +162,9 @@ SPCP                [ \t]+
 HASH           ^{SPC}#{SPC}
 %%
 
+       /* Make state available to all actions. */
+       struct _mesa_glsl_parse_state *state = yyextra;
+
 [ \r\t]+               ;
 
     /* Preprocessor tokens. */ 
@@ -541,7 +544,6 @@ usampler2DMSArray KEYWORD(0, 300, 0, 0, USAMPLER2DMSARRAY);
 
 
 [_a-zA-Z][_a-zA-Z0-9]* {
-                           struct _mesa_glsl_parse_state *state = yyextra;
                            void *ctx = state;  
                            yylval->identifier = ralloc_strdup(ctx, yytext);
                            return classify_identifier(state, yytext);
-- 
1.7.10

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to