sic

The sic programming language, compiler and tools (WIP)
Log | Files | Refs

commit e57fe33ccd7f8f4c550ec7931b7b3f9405093402
parent ea3dd11b971262fdc221b8d485b6b3c40127e12e
Author: citbl <citbl@citbl.org>
Date:   Wed, 13 May 2026 19:26:05 +1000

num parsing

Diffstat:
Msrc/lexer.c | 3+--
Mtest.sic | 1+
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lexer.c b/src/lexer.c @@ -70,7 +70,6 @@ static char peek(Lexer* lex) static char advance(Lexer* lex) { const char c = peek(lex); - // if (!c) return c; if (c == '\n') { lex->state.line++; lex->state.col = 1; @@ -105,11 +104,11 @@ static void lex_number(Lexer* lex, Token* tok) while (lex->state.pos < lex->code_len) { advance(lex); c = peek(lex); - // TODO lexing numbers: commas and underscores if (c == '.' && tok->type == LIT_DECIMAL) { err(lex, "parsing number failed with more than one decimal point '.'\n"); } if (c == '.' && tok->type == LIT_INT) tok->type = LIT_DECIMAL; + if (c == '_' && tok->type == LIT_INT) continue; // allow _ in large integers if (c != '.' && !isdigit((unsigned char)c)) break; str_append(str, c); } diff --git a/test.sic b/test.sic @@ -2,6 +2,7 @@ str name = "Johnny Mnemonic"; int age = 45; +int km = 400_000_000; dec height = 188.3;