harec

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

commit 077408eea9e6e59728857497a89d7616e74c94f7
parent 7c79272d61984f430f7e04845d684555a4189782
Author: Sebastian <sebastian@sebsite.pw>
Date:   Mon, 10 Oct 2022 17:47:58 -0400

lex: Disallow f suffix on non-base-10 literals

The spec only details the 0b, 0o, and 0x prefixes for integer literals.
Floating point literals are always treated as decimal.

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

Diffstat:
Msrc/lex.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/lex.c b/src/lex.c @@ -377,9 +377,14 @@ lex_literal(struct lexer *lexer, struct token *out) }; exp = &lexer->buf[lexer->buflen - 1]; break; + case 'f': + if (base != 10) { + push(lexer, c, true); + goto finalize; + } + // Fallthrough case 'i': case 'u': - case 'f': case 'z': if (suff || !started) { push(lexer, c, true);