Signed-off-by: Nikolay Sivov nsivov@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; }
On 2/7/22 18:14, Nikolay Sivov wrote:
Signed-off-by: Nikolay Sivov nsivov@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.
On 2/8/22 03:20, Zebediah Figura (she/her) wrote:
On 2/7/22 18:14, Nikolay Sivov wrote:
Signed-off-by: Nikolay Sivov nsivov@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.
I see, thanks.