Commit 2ad2c5fa authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dcompiler: Add identifiers parsing.

parent 5e82c397
......@@ -614,6 +614,9 @@ struct hlsl_parse_ctx
extern struct hlsl_parse_ctx hlsl_ctx DECLSPEC_HIDDEN;
void hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN;
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
BOOL find_function(const char *name) DECLSPEC_HIDDEN;
struct bwriter_shader *parse_hlsl_shader(const char *text, enum shader_type type, DWORD version,
const char *entrypoint, char **messages) DECLSPEC_HIDDEN;
......
......@@ -45,6 +45,7 @@ WS [ \t]
NEWLINE (\n)|(\r\n)
DOUBLESLASHCOMMENT "//"[^\n]*
STRING \"[^\"]*\"
IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
ANY (.)
......@@ -166,6 +167,17 @@ while {return KW_WHILE; }
column_major {return KW_COLUMN_MAJOR; }
row_major {return KW_ROW_MAJOR; }
{IDENTIFIER} {
hlsl_lval.name = d3dcompiler_strdup(yytext);
if (get_variable(hlsl_ctx.cur_scope, yytext)
|| find_function(yytext))
return VAR_IDENTIFIER;
else if (get_type(hlsl_ctx.cur_scope, yytext, TRUE))
return TYPE_IDENTIFIER;
else
return NEW_IDENTIFIER;
}
[+-]?[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[h|H|f|F]? {
hlsl_lval.floatval = atof(yytext);
return C_FLOAT;
......
......@@ -159,6 +159,7 @@ static void hlsl_error(const char *s)
%token <intval> PRE_LINE
%token <name> VAR_IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
%token <name> STRING
%token <floatval> C_FLOAT
%token <intval> C_INTEGER
......
......@@ -3,6 +3,7 @@
* Copyright 2009 Matteo Bruni
* Copyright 2008-2009 Henri Verbeet for CodeWeavers
* Copyright 2010 Rico Schüller
* Copyright 2012 Matteo Bruni for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -759,3 +760,21 @@ void compilation_message(struct compilation_messages *msg, const char *fmt, va_l
}
}
}
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name)
{
FIXME("stub.\n");
return NULL;
}
struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive)
{
FIXME("stub.\n");
return NULL;
}
BOOL find_function(const char *name)
{
FIXME("stub.\n");
return FALSE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment