From 39269cc68a32f6e1a7524b00da36a1fe4cc7fb8b Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 21 Aug 2026 00:05:03 +0200 Subject: Implement Single and Double floats --- boot/lexer.ll | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'boot/lexer.ll') diff --git a/boot/lexer.ll b/boot/lexer.ll index 888c17d..eb1bbd3 100644 --- a/boot/lexer.ll +++ b/boot/lexer.ll @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see } while (0); #include +#include #include "parser.hh" #undef YY_DECL @@ -50,6 +51,7 @@ HIGIT [0-9a-fA-F] HEXADECIMAL 0[xX]{HIGIT}+ BIGIT [01] NATURAL [1-9][[:digit:]]* +EXPONENT [eE][+-]?[[:digit:]]+ %% %{ @@ -325,31 +327,17 @@ to { REJECT; } } -[[:digit:]]+\.[[:digit:]]+([eE][+-]?[[:digit:]]+)? { +[[:digit:]]+(\.[[:digit:]]+{EXPONENT}?|{EXPONENT}) { errno = 0; double result = strtod(yytext, NULL); - if (errno == ERANGE) - { - REJECT; - } - else - { - return yy::parser::make_FLOAT(result, this->location); - } + return yy::parser::make_DOUBLE(result, this->location); } -[[:digit:]]+[eE][+-]?[[:digit:]]+ { +[[:digit:]]+(\.[[:digit:]]+{EXPONENT}?|{EXPONENT})f { errno = 0; - double result = strtod(yytext, NULL); + float result = strtof(yytext, NULL); - if (errno == ERANGE) - { - REJECT; - } - else - { - return yy::parser::make_FLOAT(result, this->location); - } + return yy::parser::make_SINGLE(result, this->location); } '([^'\\\n]|\\.|\\\n)+' { std::optional result = parse_byte_literal(yytext); -- cgit v1.2.3