vkd3d-shader: Implement #error.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-01-14 14:47:50 -06:00 committed by Alexandre Julliard
parent ba32e91aca
commit 1a326d16c6
4 changed files with 22 additions and 2 deletions

View File

@ -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 \

View File

@ -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:

View File

@ -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;

View File

@ -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,