Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 1 - libs/vkd3d-shader/preproc.l | 12 +++++++++++- libs/vkd3d-shader/preproc.y | 10 ++++++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 4 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 22151adf..30bea627 100644 --- a/Makefile.am +++ b/Makefile.am @@ -245,7 +245,6 @@ XFAIL_TESTS = \ tests/math.shader_test \ tests/preproc-ifdef.shader_test \ tests/preproc-if-expr.shader_test \ - tests/preproc-invalid.shader_test \ tests/preproc-macro.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index f7aee198..a2c1e26e 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -50,6 +50,7 @@ static void update_location(struct preproc_ctx *ctx); %s C_COMMENT %s CXX_COMMENT
+%s ERROR %s INCLUDE
NEWLINE \r?\n @@ -70,6 +71,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* <C_COMMENT,CXX_COMMENT><<EOF>> {yy_pop_state(yyscanner);} <C_COMMENT,CXX_COMMENT>. {}
+<ERROR>(\{NEWLINE}|[^\n])* {return T_STRING;} + <INITIAL>{IDENTIFIER}/( {return T_IDENTIFIER_PAREN;} <INITIAL>{IDENTIFIER} {return T_IDENTIFIER;}
@@ -109,6 +112,12 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* for (p = yytext + 1; strchr(" \t", *p); ++p) ;
+ if (!strcmp(p, "error")) + { + BEGIN(ERROR); + return T_ERROR; + } + if (!strcmp(p, "include")) { BEGIN(INCLUDE); @@ -140,7 +149,7 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* }
<INITIAL,INCLUDE>\{NEWLINE} {} -<INITIAL,INCLUDE>{NEWLINE} { +<INITIAL,INCLUDE,ERROR>{NEWLINE} { BEGIN(INITIAL); return T_NEWLINE; } @@ -350,6 +359,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner) case T_ELIF: case T_ELSE: case T_ENDIF: + case T_ERROR: case T_IF: case T_IFDEF: case T_IFNDEF: diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index 4b276a95..9f650549 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -319,6 +319,7 @@ static void free_parse_arg_names(struct parse_arg_names *args) %token T_NEWLINE
%token T_DEFINE "#define" +%token T_ERROR "#error" %token T_ELIF "#elif" %token T_ELSE "#else" %token T_ENDIF "#endif" @@ -534,6 +535,15 @@ directive preproc_warning(ctx, &@$, VKD3D_SHADER_WARNING_PP_INVALID_DIRECTIVE, "Ignoring #endif without prior #if."); } + | T_ERROR T_NEWLINE + { + preproc_error(ctx, &@$, VKD3D_SHADER_ERROR_PP_ERROR_DIRECTIVE, "Error directive."); + } + | T_ERROR T_STRING T_NEWLINE + { + preproc_error(ctx, &@$, VKD3D_SHADER_ERROR_PP_ERROR_DIRECTIVE, "Error directive: %s", $2); + vkd3d_free($2); + } | T_INCLUDE T_STRING T_NEWLINE { PFN_vkd3d_shader_open_include open_include = ctx->preprocess_info->pfn_open_include; diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 157dc5e2..8d9821d5 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -81,6 +81,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_RS_MIXED_DESCRIPTOR_RANGE_TYPES = 3004,
VKD3D_SHADER_ERROR_PP_INVALID_SYNTAX = 4000, + VKD3D_SHADER_ERROR_PP_ERROR_DIRECTIVE = 4001, VKD3D_SHADER_ERROR_PP_INCLUDE_FAILED = 4002,
VKD3D_SHADER_WARNING_PP_ALREADY_DEFINED = 4300,