summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parser.l18
-rw-r--r--txr.15
2 files changed, 20 insertions, 3 deletions
diff --git a/parser.l b/parser.l
index 7a9d8d8b..c0114b24 100644
--- a/parser.l
+++ b/parser.l
@@ -137,6 +137,12 @@ static void yyerrprepf(scanner_t *scanner, val fmt, ...)
}
}
+static void out_of_range_float(scanner_t *scanner, val tok)
+{
+ yyerrorf(scanner, lit("out-of-range floating-point literal: ~a"),
+ tok, nao);
+}
+
static wchar_t char_esc(int letter)
{
switch (letter) {
@@ -344,7 +350,9 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
|| yy_top_state(yyscanner) == QWLIT)
yy_pop_state(yyscanner);
- yylval->val = flo_str(str);
+ if ((yylval->val = flo_str(str)) == nil)
+ out_of_range_float(yyg, str);
+
return NUMBER;
}
@@ -360,7 +368,9 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
|| yy_top_state(yyscanner) == QWLIT)
yy_pop_state(yyscanner);
- yylval->val = flo_str(str);
+ if ((yylval->val = flo_str(str)) == nil)
+ out_of_range_float(yyg, str);
+
return NUMBER;
}
@@ -372,7 +382,9 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
|| yy_top_state(yyscanner) == QWLIT)
yy_pop_state(yyscanner);
- yylval->val = flo_str(str);
+ if ((yylval->val = flo_str(str)) == nil)
+ out_of_range_float(yyg, str);
+
return NUMBER;
}
diff --git a/txr.1 b/txr.1
index 7f2c5cf9..89f6c32e 100644
--- a/txr.1
+++ b/txr.1
@@ -36741,6 +36741,11 @@ part denoted by the letter
or
.codn e ,
an optional sign and one or more optional exponent digits.
+If the value specified by
+.meta string
+is out of range of the floating-point representation, then
+.code nil
+is returned.
The
.code num-str