[PATCH vkd3d] vkd3d-shader/hlsl: Fix floating point literals matching.

Zebediah Figura (she/her) zfigura at codeweavers.com
Mon Feb 7 18:20:16 CST 2022


On 2/7/22 18:14, Nikolay Sivov wrote:
> Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
> ---
> 
> Immediate issue was that constants like 1e1 were not parsed without a suffix.
> 
>   libs/vkd3d-shader/hlsl.l | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l
> index e9281ec..60aca79 100644
> --- a/libs/vkd3d-shader/hlsl.l
> +++ b/libs/vkd3d-shader/hlsl.l
> @@ -188,11 +188,7 @@ row_major               {return KW_ROW_MAJOR;           }
>                               yylval->floatval = atof(yytext);
>                               return C_FLOAT;
>                           }
> -[0-9]+\.([eE][+-]?[0-9]+)?[h|H|f|F]? {
> -                            yylval->floatval = atof(yytext);
> -                            return C_FLOAT;
> -                        }
> -[0-9]+([eE][+-]?[0-9]+)?[h|H|f|F] {
> +[0-9]+(\.)?([eE][+-]?[0-9]+)?[h|H|f|F]? {
>                               yylval->floatval = atof(yytext);
>                               return C_FLOAT;
>                           }

That matches integer constants like "1" as floats, though, unless I'm 
misreading. I believe it's necessary to introduce a fourth rule instead 
to avoid that—see the way it's done in preproc.l.



More information about the wine-devel mailing list