aboutsummaryrefslogtreecommitdiff
path: root/src/as_tokenizer.c
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-03-25 17:59:11 +0800
committerMistivia <i@mistivia.com>2025-03-25 17:59:11 +0800
commit93d6f231d59b413b091b7e15a8af246a8b105c65 (patch)
treec6c239e6b0cc8d893561df6435db578bfb7b23a2 /src/as_tokenizer.c
parent39e2a605f6d8ebcc3cb454daae3d0a4298df2eb6 (diff)
make code shorter
Diffstat (limited to 'src/as_tokenizer.c')
-rw-r--r--src/as_tokenizer.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/as_tokenizer.c b/src/as_tokenizer.c
index 7a71707..aa22000 100644
--- a/src/as_tokenizer.c
+++ b/src/as_tokenizer.c
@@ -6,7 +6,7 @@
#include "as_op.h"
#include "utils.h"
-int input_stream_next_char(struct input_stream * s) {
+int input_stream_next_char(input_stream* s) {
if (s->cursor == -1) {
return EOF;
}
@@ -30,7 +30,7 @@ int input_stream_next_char(struct input_stream * s) {
return c;
}
-int input_stream_peek_char(struct input_stream * s) {
+int input_stream_peek_char(input_stream* s) {
if (s->cursor == -1) {
return EOF;
}
@@ -71,9 +71,9 @@ int is_part_of_identifier(int c) {
return 0;
}
-struct result next_token_impl(struct allocator * alct, struct input_stream * s) {
+result next_token_impl(allocator* alct, input_stream* s) {
const char *errmsg;
- struct token * t = allocate(alct, sizeof(struct token));
+ token* t = allocate(alct, sizeof(token));
int c;
while (1) {
c = input_stream_peek_char(s);
@@ -138,7 +138,7 @@ struct result next_token_impl(struct allocator * alct, struct input_stream * s)
return ok(t);
}
-struct result next_token(struct allocator * alct, struct token_stream * ts) {
+result next_token(allocator* alct, token_stream* ts) {
if (ts->buf != NULL) {
struct token * t = ts->buf;
ts->buf = NULL;
@@ -147,7 +147,7 @@ struct result next_token(struct allocator * alct, struct token_stream * ts) {
return next_token_impl(alct, ts->s);
}
-struct result peek_token(struct allocator * alct, struct token_stream * ts) {
+result peek_token(allocator* alct, token_stream* ts) {
if (ts->buf != NULL) {
return ok(ts->buf);
}
@@ -155,7 +155,7 @@ struct result peek_token(struct allocator * alct, struct token_stream * ts) {
return ok(ts->buf);
}
-void print_token(struct token * t) {
+void print_token(token* t) {
switch (t->type) {
case TK_OP:
printf("OP: %s, line: %d, col: %d\n", t->sval, t->line, t->col);
@@ -178,15 +178,15 @@ void print_token(struct token * t) {
}
}
-struct token_stream * new_token_stream(struct allocator * alct, FILE* fp) {
- struct input_stream * s = allocate(alct, sizeof(struct input_stream));
+token_stream* new_token_stream(allocator* alct, FILE* fp) {
+ input_stream* s = allocate(alct, sizeof(input_stream));
s->fp = fp;
s->buf = allocate(alct, INPUT_STREAM_BUF_SIZE);
s->buf_pos = 0;
s->cursor = 0;
s->line = 1;
s->col = 1;
- struct token_stream * ts = allocate(alct, sizeof(struct token_stream));
+ token_stream* ts = allocate(alct, sizeof(token_stream));
ts->s = s;
ts->buf = NULL;
return ts;