aboutsummaryrefslogtreecommitdiff
path: root/src/as_tokenizer.h
diff options
context:
space:
mode:
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_