sic

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

commit 43cf39ebd945e897f872040f6ffec6f39560f6c3
parent af48161c438cc41f808c94ce9b54311a7e98c066
Author: citbl <citbl@citbl.org>
Date:   Sat,  9 May 2026 20:52:45 +1000

lexer wip

Diffstat:
Msrc/lexer.c | 12+++++++++++-
Msrc/main.c | 2++
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/lexer.c b/src/lexer.c @@ -2,9 +2,19 @@ #include <stdio.h> #include <stdlib.h> -Lexer* add_token(Lexer* l, Token); +static void add_token(Lexer* l, Token t) { + if (l->count >= l->cap) { + l->cap *= 2; + l->tokens = realloc(l->tokens, l->cap * sizeof(Token)); + } + + l->tokens[l->count++] = t; +} Lexer* lexer_lex(Lexer* l) { l->tokens = calloc(250, sizeof(Token)); + + Token tok = {0}; + add_token(l, tok); return l; } diff --git a/src/main.c b/src/main.c @@ -1,9 +1,11 @@ #include "lexer.h" #include "utils.h" #include <stdio.h> + int main(int argc, char** args) { if (argc < 1) return 1; + char* filename = args[1]; if (filename == NULL)