[PATCH vkd3d 3/5] vkd3d-shader: Implement multiplication and division.

Zebediah Figura zfigura at codeweavers.com
Mon Jan 18 15:16:42 CST 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 libs/vkd3d-shader/preproc.l |  2 +-
 libs/vkd3d-shader/preproc.y | 24 ++++++++++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index 011f8dbb..a522b7c8 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -157,7 +157,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 51df5d40..1060e9d7 100644
--- a/libs/vkd3d-shader/preproc.y
+++ b/libs/vkd3d-shader/preproc.y
@@ -335,6 +335,7 @@ static void free_parse_arg_names(struct parse_arg_names *args)
 
 %type <integer> primary_expr
 %type <integer> unary_expr
+%type <integer> mul_expr
 %type <string> body_token
 %type <const_string> body_token_const
 %type <string_buffer> body_text
@@ -439,6 +440,14 @@ body_token_const
         {
             $$ = "!";
         }
+    | '*'
+        {
+            $$ = "*";
+        }
+    | '/'
+        {
+            $$ = "/";
+        }
     | T_CONCAT
         {
             $$ = "##";
@@ -480,7 +489,7 @@ directive
             }
             vkd3d_free($2);
         }
-    | T_IF unary_expr T_NEWLINE
+    | T_IF mul_expr T_NEWLINE
         {
             if (!preproc_push_if(ctx, !!$2))
                 YYABORT;
@@ -495,7 +504,7 @@ directive
             preproc_push_if(ctx, !preproc_find_macro(ctx, $2));
             vkd3d_free($2);
         }
-    | T_ELIF unary_expr T_NEWLINE
+    | T_ELIF mul_expr T_NEWLINE
         {
             const struct preproc_file *file = preproc_get_top_file(ctx);
 
@@ -631,3 +640,14 @@ unary_expr
         {
             $$ = !$2;
         }
+
+mul_expr
+    : unary_expr
+    | mul_expr '*' unary_expr
+        {
+            $$ = $1 * $3;
+        }
+    | mul_expr '/' unary_expr
+        {
+            $$ = $1 / $3;
+        }
-- 
2.30.0




More information about the wine-devel mailing list