From 6f283c1d12cad524e08a5a947489964004f77956 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 2 Oct 2024 21:06:54 -0400 Subject: [PATCH] Fixed some things. --- src/include/lexer.h | 20 ++++++++++---------- src/include/parser.h | 17 ----------------- src/include/token.h | 2 +- src/include/util.c | 12 ------------ src/util.c | 5 +---- 5 files changed, 12 insertions(+), 44 deletions(-) delete mode 100644 src/include/util.c diff --git a/src/include/lexer.h b/src/include/lexer.h index d86d43c..d5ec072 100644 --- a/src/include/lexer.h +++ b/src/include/lexer.h @@ -8,20 +8,20 @@ // What the lexer is currently looking at. typedef enum { - LEXER_STATE_CONFUSED, // Can't decide what it's looking at (also initial - // state). - LEXER_STATE_NUM, // Looking at a number. - LEXER_STATE_CALL, // Looking at a call. + LEXER_STATE_CONFUSED, // Can't decide what it's looking at (also initial + // state). + LEXER_STATE_NUM, // Looking at a number. + LEXER_STATE_CALL, // Looking at a call. } LexerState; // Lexer: converts text to tokens. typedef struct { - char* src; // The source text. - size_t srcl; // The number of source chars. - char* cchar; // The current character. - Token** tokens; // The tokens produced. - size_t ntokens; // The number of tokens. - LexerState state; // What the lexxer is looking at. + char* src; // The source text. + size_t srcl; // The number of source chars. + char* cchar; // The current character. + Token** tokens; // The tokens produced. + size_t ntokens; // The number of tokens. + LexerState state; // What the lexxer is looking at. } Lexer; // Create a lexer. diff --git a/src/include/parser.h b/src/include/parser.h index a3f442c..53a77ff 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -10,21 +10,4 @@ // - Expression 1 // - Expression 2 -typedef enum OpType { - OPTYPE_PLUS, - OPTYPE_MINUS -} optype_t; - -typedef union Exp { - typedef struct Op { - optype_t type; - Exp* exp1; - Exp* exp2; - } op_t; - - int n; -} exp_t; - - - #endif diff --git a/src/include/token.h b/src/include/token.h index 02c4174..2b36870 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -9,7 +9,7 @@ typedef enum { // Token. typedef struct { TokenType type; // The type of the Token. - char* val; // The text of the Token. + char* val; // The text of the Token. } Token; Token* token_init(TokenType type, char* val); diff --git a/src/include/util.c b/src/include/util.c deleted file mode 100644 index 1f5a7ca..0000000 --- a/src/include/util.c +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef UTIL_H -#define UTIL_H - -// Utilies. - -#include -#include - -// Exit with an error. Returns int for ease of use, but should be treated as void. -int die(char* msg); - -#endif diff --git a/src/util.c b/src/util.c index 1efe3fb..9e9e272 100644 --- a/src/util.c +++ b/src/util.c @@ -1,6 +1,3 @@ #include "include/util.h" -int is_even(int n) { - return !(n%2); -} - +int is_even(int n) { return !(n % 2); }