summaryrefslogtreecommitdiff
path: root/src/glsl/glsl_lexer.lpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2011-01-27 17:52:19 -0800
committerIan Romanick <ian.d.romanick@intel.com>2011-02-11 14:12:43 -0800
commit884215894493bdbc55abd567c121c9df06ae3bc7 (patch)
treeb1014ccae0f8a99d24021ac9ebd682f878898040 /src/glsl/glsl_lexer.lpp
parentf4b812e1a661448cf4b624f283c949a54b52e9d5 (diff)
glsl: Finish out the reduce/reduce error fixes
Track variables, functions, and types during parsing. Use this information in the lexer to return the currect "type" for identifiers. Change the handling of structure constructors. They will now show up in the AST as constructors (instead of plain function calls). Fixes piglit tests constructor-18.vert, constructor-19.vert, and constructor-20.vert. Also fixes bugzilla #29926. NOTE: This is a candidate for the 7.9 and 7.10 branches.
Diffstat (limited to 'src/glsl/glsl_lexer.lpp')
-rw-r--r--src/glsl/glsl_lexer.lpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp
index d3d53ffb68..e4c469f9e0 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)
{