diff options
-rw-r--r-- | gate.c | 2 | ||||
-rw-r--r-- | gate.h | 2 | ||||
-rw-r--r-- | lex.c | 2 | ||||
-rw-r--r-- | lex.h | 34 | ||||
-rw-r--r-- | token.h | 38 |
5 files changed, 42 insertions, 36 deletions
@@ -47,7 +47,7 @@ gate_add_generic(struct gate *array, size_t array_index, char *name, enum BINARY int gate_add(enum TOKEN_TYPE op, char *name, char *left, char *right) { /* FIXME */ - fprintf(stderr, "bop on %s and %s for gate %s not implemented", left, right, name); + fprintf(stderr, "bop on %s and %s for gate %s not implemented\n", left, right, name); return 1; } @@ -3,7 +3,7 @@ #include <stddef.h> -#include "lex.h" +#include "token.h" #include "logic.h" enum NODE_TYPE { @@ -4,7 +4,7 @@ #include <string.h> #include "common.h" -#include "lex.h" +#include "token.h" #define emit_error(...) fprintf(stderr, "Error (%zd,%zd): ", line_number, 1 + column_number);\ fprintf(stderr, __VA_ARGS__) @@ -3,39 +3,7 @@ #include <stdio.h> -#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, - TOK_NAND, - TOK_NOR, - - /* 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; -}; +#include "token.h" struct token* lex_file(FILE*); const char *get_token_description(enum TOKEN_TYPE); @@ -0,0 +1,38 @@ +#ifndef HENCE_TOKEN_H +#define HENCE_TOKEN_H + +#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, + TOK_NAND, + TOK_NOR, + + /* 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; +}; + +#endif |