harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit 021e1ba876d1dfe40a7474ad2118d231714b19c6
parent e2e0d12053b523274432fd682909428756efac62
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sun, 22 May 2022 19:06:39 -0400

lex: disallow decimal point in integer literal

Prior to this commit, 3.5i64 lexed as a valid literal with the value 3.
Now, this results in an error.

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Msrc/lex.c | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/lex.c b/src/lex.c @@ -428,6 +428,19 @@ finalize: } } + if (isfloat) { + switch (out->storage) { + case STORAGE_F32: + case STORAGE_F64: + case STORAGE_FCONST: + break; + default: + out->token = T_ERROR; + consume(lexer, -1); + return out->token; + } + } + errno = 0; switch (out->storage) { case STORAGE_U8: