summaryrefslogtreecommitdiff
path: root/Token.h
diff options
context:
space:
mode:
Diffstat (limited to 'Token.h')
-rw-r--r--Token.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/Token.h b/Token.h
new file mode 100644
index 0000000..f11753f
--- /dev/null
+++ b/Token.h
@@ -0,0 +1,40 @@
+#pragma once
+#include <stdbool.h>
+
+enum {
+ TOK_NONE,
+ TOK_KEYWORD,
+ TOK_STRING,
+ TOK_INTEGER,
+ /* single char toks */
+ TOK_PAREN_OPEN,
+ TOK_PAREN_CLOS,
+ TOK_CURL_OPEN,
+ TOK_CURL_CLOS,
+ TOK_SQUAR_OPEN,
+ TOK_SQUAR_CLOS,
+ TOK_SEMICOLON,
+ TOK_ASSIGN,
+ TOK_COMMA,
+ TOK_COMP_LESS,
+ TOK_MODULO,
+ /* double char toks */
+ TOK_INCREMENT,
+};
+
+union TokenValue {
+ char *s;
+ char c;
+ int i;
+ double d;
+ bool b;
+};
+
+typedef struct Token {
+ unsigned int type;
+ unsigned int line;
+ union TokenValue v;
+} Token;
+
+void token_free(Token *tok);
+void token_print(const Token *tok);