From fa02225c5ae8b704408769c70bb47101042762b8 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 20 Feb 2022 18:48:30 +0100 Subject: Haskell ftw --- src/preprocess.c | 59 -------------------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 src/preprocess.c (limited to 'src/preprocess.c') diff --git a/src/preprocess.c b/src/preprocess.c deleted file mode 100644 index f4f67f7..0000000 --- a/src/preprocess.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include - -static void preprocess_erase(struct ctx *ctx, size_t start) -{ - assert(ctx->data[start] == '#'); - - for (size_t i = start; i < ctx->size; i++) { - char cur = ctx->data[i]; - if (cur == '\0') - break; - - if (cur == '\n') { - ctx->data[i] = MACRO_NEWLINE; - break; - } else { - ctx->data[i] = MACRO_SKIP; - } - } -} - -void preprocess(struct ctx *ctx) -{ - ctx->size = ctx->location.size; - ctx->data = malloc(ctx->size); - memcpy(ctx->data, ctx->location.data, ctx->size); - - for (size_t i = 0; i < ctx->location.size; i++) { - const char cur = ctx->location.data[i]; - - ctx->location.column++; - - if (cur == '\n') { - ctx->location.line++; - ctx->location.column = 0; - continue; - } else if (cur == '\0') { - break; - } else if (cur == '#' && ctx->location.column == 1) { - if (strncmp(ctx->location.data + i + 1, "inc ", - fmin(4, ctx->location.size - i)) == 0) { - // TODO: Add include features - } else if (*(ctx->location.data + i + 1) == '#') { - // Comment - } else { - errln(&ctx->location, "Invalid preprocessing directive"); - } - preprocess_erase(ctx, i); - } - } - - context_rewind(ctx); -} -- cgit v1.2.3