summaryrefslogtreecommitdiff
path: root/lex.h
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-08-01 23:25:46 +1200
committerDavid Phillips <david@sighup.nz>2018-08-01 23:25:46 +1200
commiteee61ddbba165f772a0e720825dcf6810eaa2648 (patch)
treec9b238e386dfcf19f0c3244998efa8d2dc6d0a82 /lex.h
parente22abc4eaf4f1446c6ac31e4b709cb5206d4fe3b (diff)
downloadhence-eee61ddbba165f772a0e720825dcf6810eaa2648.tar.xz
Rename lexer and parser, fix compilation warnings
Diffstat (limited to 'lex.h')
-rw-r--r--lex.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/lex.h b/lex.h
new file mode 100644
index 0000000..3ce15f4
--- /dev/null
+++ b/lex.h
@@ -0,0 +1,35 @@
+#define MAX_IDENT_LENGTH 128
+
+enum TOKEN_TYPE {
+ /* Keywords */
+ TOK_MODULE,
+ TOK_INPUT,
+ TOK_EXPR,
+ TOK_COLON,
+ TOK_EOL,
+ TOK_OR,
+ TOK_AND,
+ TOK_XOR,
+ TOK_NOT,
+
+ /* Etc */
+ TOK_IDENT
+};
+
+struct location {
+ size_t line;
+ size_t column;
+ size_t leading_whitespace_len;
+};
+
+struct token {
+ enum TOKEN_TYPE type;
+ struct location loc;
+ char value[MAX_IDENT_LENGTH];
+ size_t span;
+ struct token *next;
+};
+
+struct token* lex_file(FILE*);
+const char *get_token_description(enum TOKEN_TYPE);
+