Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 1 - libs/vkd3d-shader/preproc.l | 4 +++- libs/vkd3d-shader/preproc.y | 26 ++++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 30bea627..76a2f31a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -243,7 +243,6 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing.shader_test \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ - tests/preproc-ifdef.shader_test \ tests/preproc-if-expr.shader_test \ tests/preproc-macro.shader_test \ tests/swizzle-0.shader_test \ diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 6779a39e..d21ddd1f 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -80,6 +80,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>"<=" {return T_LE;} <INITIAL>">=" {return T_GE;} +<INITIAL>"==" {return T_EQ;} +<INITIAL>"!=" {return T_NE;}
/* We have no use for floats, but shouldn't parse them as integers. */
@@ -99,7 +101,7 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* <INITIAL>"--" {return T_TEXT;} <INITIAL>"<<"=? {return T_TEXT;} <INITIAL>">>"=? {return T_TEXT;} -<INITIAL>[-+*/%&|^=!]= {return T_TEXT;} +<INITIAL>[-+*/%&|^]= {return T_TEXT;}
<INCLUDE>"[^"]*" {return T_STRING;} <INCLUDE><[^>]*> {return T_STRING;} diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index 6d88419e..089fd760 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -334,6 +334,8 @@ static void free_parse_arg_names(struct parse_arg_names *args)
%token T_LE "<=" %token T_GE ">=" +%token T_EQ "==" +%token T_NE "!=" %token T_DEFINED "defined"
%type <integer> primary_expr @@ -341,6 +343,7 @@ static void free_parse_arg_names(struct parse_arg_names *args) %type <integer> mul_expr %type <integer> add_expr %type <integer> ineq_expr +%type <integer> eq_expr %type <string> body_token %type <const_string> body_token_const %type <string_buffer> body_text @@ -473,6 +476,14 @@ body_token_const { $$ = ">="; } + | T_EQ + { + $$ = "=="; + } + | T_NE + { + $$ = "!="; + } | T_DEFINED { $$ = "defined"; @@ -510,7 +521,7 @@ directive } vkd3d_free($2); } - | T_IF ineq_expr T_NEWLINE + | T_IF eq_expr T_NEWLINE { if (!preproc_push_if(ctx, !!$2)) YYABORT; @@ -525,7 +536,7 @@ directive preproc_push_if(ctx, !preproc_find_macro(ctx, $2)); vkd3d_free($2); } - | T_ELIF ineq_expr T_NEWLINE + | T_ELIF eq_expr T_NEWLINE { const struct preproc_file *file = preproc_get_top_file(ctx);
@@ -707,3 +718,14 @@ ineq_expr { $$ = $1 >= $3; } + +eq_expr + : ineq_expr + | eq_expr T_EQ ineq_expr + { + $$ = $1 == $3; + } + | eq_expr T_NE ineq_expr + { + $$ = $1 != $3; + }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/preproc.l | 2 +- libs/vkd3d-shader/preproc.y | 40 +++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index d21ddd1f..4c82babf 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -162,7 +162,7 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* }
<INITIAL>{WS}+ {} -<INITIAL>[-()[]{},+!*/<>] {return yytext[0];} +<INITIAL>[-()[]{},+!*/<>&|^] {return yytext[0];} <INITIAL>. {return T_TEXT;}
%% diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index 089fd760..fa5e5ccc 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -344,6 +344,9 @@ static void free_parse_arg_names(struct parse_arg_names *args) %type <integer> add_expr %type <integer> ineq_expr %type <integer> eq_expr +%type <integer> bitand_expr +%type <integer> bitxor_expr +%type <integer> bitor_expr %type <string> body_token %type <const_string> body_token_const %type <string_buffer> body_text @@ -464,6 +467,18 @@ body_token_const { $$ = ">"; } + | '&' + { + $$ = "&"; + } + | '|' + { + $$ = "|"; + } + | '^' + { + $$ = "^"; + } | T_CONCAT { $$ = "##"; @@ -521,7 +536,7 @@ directive } vkd3d_free($2); } - | T_IF eq_expr T_NEWLINE + | T_IF bitor_expr T_NEWLINE { if (!preproc_push_if(ctx, !!$2)) YYABORT; @@ -536,7 +551,7 @@ directive preproc_push_if(ctx, !preproc_find_macro(ctx, $2)); vkd3d_free($2); } - | T_ELIF eq_expr T_NEWLINE + | T_ELIF bitor_expr T_NEWLINE { const struct preproc_file *file = preproc_get_top_file(ctx);
@@ -729,3 +744,24 @@ eq_expr { $$ = $1 != $3; } + +bitand_expr + : eq_expr + | bitand_expr '&' eq_expr + { + $$ = $1 & $3; + } + +bitxor_expr + : bitand_expr + | bitxor_expr '^' bitand_expr + { + $$ = $1 ^ $3; + } + +bitor_expr + : bitxor_expr + | bitor_expr '|' bitxor_expr + { + $$ = $1 | $3; + }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/preproc.l | 4 ++-- libs/vkd3d-shader/preproc.y | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 4c82babf..37acc5e0 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -82,6 +82,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* <INITIAL>">=" {return T_GE;} <INITIAL>"==" {return T_EQ;} <INITIAL>"!=" {return T_NE;} +<INITIAL>"&&" {return T_AND;} +<INITIAL>"||" {return T_OR;}
/* We have no use for floats, but shouldn't parse them as integers. */
@@ -95,8 +97,6 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>## {return T_CONCAT;}
-<INITIAL>"&&" {return T_TEXT;} -<INITIAL>"||" {return T_TEXT;} <INITIAL>"++" {return T_TEXT;} <INITIAL>"--" {return T_TEXT;} <INITIAL>"<<"=? {return T_TEXT;} diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index fa5e5ccc..051f94bc 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -336,6 +336,8 @@ static void free_parse_arg_names(struct parse_arg_names *args) %token T_GE ">=" %token T_EQ "==" %token T_NE "!=" +%token T_AND "&&" +%token T_OR "||" %token T_DEFINED "defined"
%type <integer> primary_expr @@ -347,6 +349,8 @@ static void free_parse_arg_names(struct parse_arg_names *args) %type <integer> bitand_expr %type <integer> bitxor_expr %type <integer> bitor_expr +%type <integer> logicand_expr +%type <integer> logicor_expr %type <string> body_token %type <const_string> body_token_const %type <string_buffer> body_text @@ -499,6 +503,14 @@ body_token_const { $$ = "!="; } + | T_AND + { + $$ = "&&"; + } + | T_OR + { + $$ = "||"; + } | T_DEFINED { $$ = "defined"; @@ -536,7 +548,7 @@ directive } vkd3d_free($2); } - | T_IF bitor_expr T_NEWLINE + | T_IF logicor_expr T_NEWLINE { if (!preproc_push_if(ctx, !!$2)) YYABORT; @@ -551,7 +563,7 @@ directive preproc_push_if(ctx, !preproc_find_macro(ctx, $2)); vkd3d_free($2); } - | T_ELIF bitor_expr T_NEWLINE + | T_ELIF logicor_expr T_NEWLINE { const struct preproc_file *file = preproc_get_top_file(ctx);
@@ -765,3 +777,17 @@ bitor_expr { $$ = $1 | $3; } + +logicand_expr + : bitor_expr + | logicand_expr T_AND bitor_expr + { + $$ = $1 && $3; + } + +logicor_expr + : logicand_expr + | logicor_expr T_OR logicand_expr + { + $$ = $1 || $3; + }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/preproc.l | 2 +- libs/vkd3d-shader/preproc.y | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 37acc5e0..1bf14ff4 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -162,7 +162,7 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* }
<INITIAL>{WS}+ {} -<INITIAL>[-()[]{},+!*/<>&|^] {return yytext[0];} +<INITIAL>[-()[]{},+!*/<>&|^?:] {return yytext[0];} <INITIAL>. {return T_TEXT;}
%% diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index 051f94bc..aa381e8a 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -351,6 +351,7 @@ static void free_parse_arg_names(struct parse_arg_names *args) %type <integer> bitor_expr %type <integer> logicand_expr %type <integer> logicor_expr +%type <integer> expr %type <string> body_token %type <const_string> body_token_const %type <string_buffer> body_text @@ -483,6 +484,14 @@ body_token_const { $$ = "^"; } + | '?' + { + $$ = "?"; + } + | ':' + { + $$ = ":"; + } | T_CONCAT { $$ = "##"; @@ -548,7 +557,7 @@ directive } vkd3d_free($2); } - | T_IF logicor_expr T_NEWLINE + | T_IF expr T_NEWLINE { if (!preproc_push_if(ctx, !!$2)) YYABORT; @@ -563,7 +572,7 @@ directive preproc_push_if(ctx, !preproc_find_macro(ctx, $2)); vkd3d_free($2); } - | T_ELIF logicor_expr T_NEWLINE + | T_ELIF expr T_NEWLINE { const struct preproc_file *file = preproc_get_top_file(ctx);
@@ -791,3 +800,10 @@ logicor_expr { $$ = $1 || $3; } + +expr + : logicor_expr + | expr '?' logicor_expr ':' logicor_expr + { + $$ = $1 ? $3 : $5; + }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 -- libs/vkd3d-shader/preproc.y | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 76a2f31a..27d933c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -243,8 +243,6 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing.shader_test \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ - tests/preproc-if-expr.shader_test \ - tests/preproc-macro.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ tests/swizzle-2.shader_test \ diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index aa381e8a..7a995430 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -693,6 +693,10 @@ primary_expr $$ = !!preproc_find_macro(ctx, $3); vkd3d_free($3); } + | '(' expr ')' + { + $$ = $2; + }
unary_expr : primary_expr
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com