aboutsummaryrefslogtreecommitdiff
path: root/boot/lexer.ll
diff options
context:
space:
mode:
Diffstat (limited to 'boot/lexer.ll')
-rw-r--r--boot/lexer.ll26
1 files changed, 7 insertions, 19 deletions
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 <sstream>
+#include <cmath>
#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<std::uint8_t> result = parse_byte_literal(yytext);