aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorc+12023-05-03 12:42:57 -0400
committerc+12023-05-03 12:42:57 -0400
commit640b395ef000dc20056ec04d6b5ff5d488baf2aa (patch)
tree1b4c691fb8e6d349dfe12a9eefe180aa1e7789fb /src
parent9d981a2597dca067572ee16d1a3f6e99f9c6ddd6 (diff)
HALK HALK HALK
Diffstat (limited to 'src')
-rw-r--r--src/include/token.h7
-rw-r--r--src/lexer.c13
-rw-r--r--src/token.c10
3 files changed, 25 insertions, 5 deletions
diff --git a/src/include/token.h b/src/include/token.h
index c5ee9ec..33f28f1 100644
--- a/src/include/token.h
+++ b/src/include/token.h
@@ -1,6 +1,6 @@
#ifndef TOKEN_H
#define TOKEN_H
-typedef struct TOKEN_STRUCT {
+typedef struct TOKEN_STRUC {
enum {
TOKEN_ID, // keyword
TOKEN_EQ, // '='
@@ -12,11 +12,12 @@ typedef struct TOKEN_STRUCT {
TOKEN_LBRAK, // '['
TOKEN_RBRAK, // ']'
TOKEN_POUND, // '#''
- TOKEN_TILDE // '~'
+ TOKEN_TILDE, // '~'
+ TOKEN_EOF // '\0'
} type;
char* value;
} token_T;
-token_T* init_token(int type, char* value);
+token_T* token_init(int type, char* value);
#endif
diff --git a/src/lexer.c b/src/lexer.c
index 692a9c9..2a3839e 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -1,4 +1,5 @@
#include "include/lexer.h"
+#include "include/token.h"
#include <stdlib.h>
#include <string.h>
@@ -33,20 +34,28 @@ token_T* lexer_get_next_token(lexer_T* lexer) {
if (lexer->c == ' ' ||
lexer->c == '\t' ||
lexer->c == '\n') {
-
+ lexer_pass(lexer);
}
}
+
+ return token_init(TOKEN_EOF, "\0");
}
token_T* lexer_get_string(lexer_T* lexer) {
-
+
}
+
token_T* lexer_get_id(lexer_T* lexer) {
}
+
token_T* lexer_next_token(lexer_T* lexer, token_T* token) {
+ lexer_next(lexer);
+
+ return lexer;
}
+
char* lexer_get_c_as_string(lexer_T* lexer) {
}
diff --git a/src/token.c b/src/token.c
index e69de29..da38b9a 100644
--- a/src/token.c
+++ b/src/token.c
@@ -0,0 +1,10 @@
+#include "include/token.h"
+#include <stdlib.h>
+
+token_T* token_init(int type, char* val) {
+ token_T* token = calloc(1, sizeof(struct TOKEN_STRUC));
+ token->type = type;
+ token->value = val;
+
+ return token;
+}