From 2c601e7a00d54181bb67b403e79ca351eae200e2 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 9 Oct 2021 12:16:41 +0200 Subject: Add support for comments --- src/bootstrap/main.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/bootstrap/main.c') diff --git a/src/bootstrap/main.c b/src/bootstrap/main.c index 65a61f4..1494378 100755 --- a/src/bootstrap/main.c +++ b/src/bootstrap/main.c @@ -8,6 +8,7 @@ // FIXME: We are not worried right now about freeing memory, but we should in // the future. +// TODO: Better error messages. typedef struct StringView { char *start; @@ -143,7 +144,25 @@ tokenize(StringView sv) { tokens_buf[n++] = token; token_n = 0; } - continue; + } break; + case ';': { + if (token_n != 0) { + Token token = (Token){ + .type = TOKEN_UNKNOWN, + .value = (StringView){ + .start = &sv.start[i - token_n], + .n = token_n, + } + }; + token.type = find_token_type(token.value); + tokens_buf[n++] = token; + token_n = 0; + } + + // Advance until the next newline. + do { + i++; + } while (i < sv.n && sv.start[(i + 1)] != '\n'); } break; case '"': { if (token_n != 0) { -- cgit v1.2.1