aboutsummaryrefslogtreecommitdiff
path: root/include/tokenizer.h
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-02-27 22:26:35 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit76d85a10f6cda93eba29dad5372e8160af7289c8 (patch)
treecfec3043ec45a5e83494ec109e87c239dad6cc47 /include/tokenizer.h
parent8201cd9f40897cf6b8e6973b28a8661108702ab1 (diff)
Use multiple threads to parse
Diffstat (limited to 'include/tokenizer.h')
-rw-r--r--include/tokenizer.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/tokenizer.h b/include/tokenizer.h
index 9584542..e79f070 100644
--- a/include/tokenizer.h
+++ b/include/tokenizer.h
@@ -1,11 +1,13 @@
#ifndef AMALGAM_TOKENIZER_H
#define AMALGAM_TOKENIZER_H
-#include "buffer_view.h"
-#include "misc.h"
+#include "std/buffer_view.h"
+#include "std/misc.h"
#define TOKENIZER_OK 0
-#define TOKENIZER_UNEXPECTED_TOKEN -1
+/* General error */
+#define TOKENIZER_ERR -1
+#define TOKENIZER_UNEXPECTED_TOKEN -2
typedef enum {
TOK_NONE,
@@ -13,11 +15,13 @@ typedef enum {
TOK_IDENTIFIER,
TOK_CONST,
TOK_VAR,
+ TOK_STRING,
TOK_EQUALS,
TOK_OPEN_PAREN,
TOK_CLOSING_PAREN,
TOK_OPEN_BRACE,
- TOK_CLOSING_BRACE
+ TOK_CLOSING_BRACE,
+ TOK_IMPORT
} Token;
typedef struct {
@@ -25,13 +29,15 @@ typedef struct {
int index;
int prev_index;
int line;
+ BufferView code_name;
union {
BufferView identifier;
+ BufferView string;
} value;
} Tokenizer;
-CHECK_RESULT int tokenizer_init(Tokenizer *self, BufferView code);
+CHECK_RESULT int tokenizer_init(Tokenizer *self, BufferView code, BufferView code_name);
CHECK_RESULT int tokenizer_next(Tokenizer *self, Token *token);
CHECK_RESULT int tokenizer_accept(Tokenizer *self, Token expected_token);