diff options
Diffstat (limited to 'src/glsl/glsl_lexer.lpp')
-rw-r--r-- | src/glsl/glsl_lexer.lpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index d3d53ffb68e..e4c469f9e0a 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -27,6 +27,8 @@ #include "glsl_parser_extras.h" #include "glsl_parser.h" +static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); + #define YY_USER_ACTION \ do { \ yylloc->source = 0; \ @@ -62,7 +64,7 @@ return ERROR_TOK; \ } else { \ yylval->identifier = strdup(yytext); \ - return IDENTIFIER; \ + return classify_identifier(yyextra, yytext); \ } \ } while (0) @@ -419,13 +421,24 @@ row_major KEYWORD(130, 999, ROW_MAJOR); struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; yylval->identifier = ralloc_strdup(ctx, yytext); - return IDENTIFIER; + return classify_identifier(state, yytext); } . { return yytext[0]; } %% +int +classify_identifier(struct _mesa_glsl_parse_state *state, const char *name) +{ + if (state->symbols->get_variable(name) || state->symbols->get_function(name)) + return IDENTIFIER; + else if (state->symbols->get_type(name)) + return TYPE_IDENTIFIER; + else + return NEW_IDENTIFIER; +} + void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) { |