diff options
Diffstat (limited to 'src/tokenize.c')
-rw-r--r-- | src/tokenize.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/tokenize.c b/src/tokenize.c index 69f17c9..179b251 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -1,4 +1,9 @@ -#include <lib.h> +#include <assert.h> +#include <ctype.h> +#include <stdbool.h> +#include <stddef.h> +#include <stdio.h> + #include <log.h> #include <tokenize.h> @@ -72,8 +77,8 @@ static void token_add(struct ctx *ctx, enum token_type type, size_t start, size_ { struct token token = { 0 }; token.type = type; - token.start = start; - token.end = end; + token.string.start = start; + token.string.end = end; assert(++ctx->token_count < TOKENS_MAX); ctx->tokens[ctx->token_count] = token; @@ -86,7 +91,7 @@ static void token_add(struct ctx *ctx, enum token_type type, size_t start, size_ } } -static void token_print(struct ctx *ctx, struct token *token) +void token_print(struct ctx *ctx, struct token *token) { assert(token->type != UNKNOWN); @@ -96,17 +101,11 @@ static void token_print(struct ctx *ctx, struct token *token) return; } - for (size_t i = token->start; i < token->end; i++) + for (size_t i = token->string.start; i < token->string.end; i++) printf("%c", ctx->data[i]); printf("'\n"); } -void tokens_print(struct ctx *ctx) -{ - for (size_t i = 1; i < ctx->token_count; i++) - token_print(ctx, &ctx->tokens[i]); -} - void tokenize(struct ctx *ctx) { for (size_t i = 0; i < ctx->size; i++) { |