aboutsummaryrefslogtreecommitdiff
path: root/src/as_tokenizer.h
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-03-16 20:01:42 +0800
committerMistivia <i@mistivia.com>2025-03-16 20:01:42 +0800
commitb83187f66175d93a0dba45f6d110ed94badac7c5 (patch)
tree22710b7a5278ac8a254ead30109f1dd9084d1022 /src/as_tokenizer.h
parent1ce0d45242097a07b7a4ee539a074ec812851a58 (diff)
refactor using allocator pattern
Diffstat (limited to 'src/as_tokenizer.h')
-rw-r--r--src/as_tokenizer.h39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/as_tokenizer.h b/src/as_tokenizer.h
index 377aca0..e9025ba 100644
--- a/src/as_tokenizer.h
+++ b/src/as_tokenizer.h
@@ -4,38 +4,43 @@
#include <stdint.h>
#include <stdio.h>
-typedef enum {
+#include "utils.h"
+
+enum tokenType {
OP, ARG, TAG, COLON, NEWLINE, ENDOFFILE
-} TokenType;
+};
-typedef struct {
- TokenType type;
+struct token {
+ enum tokenType type;
int line;
int col;
char *sval;
int64_t ival;
double fval;
-} Token;
+};
+typedef struct token *Token;
#define INPUT_STREAM_BUF_SIZE 1024
-typedef struct {
+struct inputStream {
FILE *fp;
char *buf;
int buf_pos;
int cursor;
int line;
int col;
-} InputStream;
-
-typedef struct {
- Token* buf;
- InputStream *s;
-} TokenStream;
-
-Token *nextToken(TokenStream *ts);
-Token *peekToken(TokenStream *ts);
-void printToken(Token *t);
-TokenStream* makeTokenStream(FILE* fp);
+};
+typedef struct inputStream *InputStream;
+
+struct tokenStream {
+ Token buf;
+ InputStream s;
+};
+typedef struct tokenStream *TokenStream;
+
+Token nextToken(Allocator alct, TokenStream ts);
+Token peekToken(Allocator alct, TokenStream ts);
+void printToken(Token t);
+TokenStream makeTokenStream(Allocator alct, FILE* fp);
#endif // FMV_AS_TOKENIZER_H_