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_]* ">=" {return T_GE;} "==" {return T_EQ;} "!=" {return T_NE;} +"&&" {return T_AND;} +"||" {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_]* ## {return T_CONCAT;} -"&&" {return T_TEXT;} -"||" {return T_TEXT;} "++" {return T_TEXT;} "--" {return T_TEXT;} "<<"=? {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 primary_expr @@ -347,6 +349,8 @@ static void free_parse_arg_names(struct parse_arg_names *args) %type bitand_expr %type bitxor_expr %type bitor_expr +%type logicand_expr +%type logicor_expr %type body_token %type body_token_const %type 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; + }