From 0671e17e8ea48db21fb68216be4307c259fc892b Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 3 Apr 2026 13:21:17 -0700 Subject: [PATCH] Rename files --- Makefile | 8 ++++---- lc.c | 1 + term.h => lc.h | 0 main.c | 6 +++--- term.c | 1 - parse.c => token.c | 10 +++++----- parse.h => token.h | 8 ++++---- 7 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 lc.c rename term.h => lc.h (100%) delete mode 100644 term.c rename parse.c => token.c (95%) rename parse.h => token.h (87%) diff --git a/Makefile b/Makefile index 44e4215..4125f98 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ CFLAGS=-std=c11 -D_FILE_OFFSET_BITS=64 -D_POSIX_C_SOURCE=200112L -Wall -Wextra $ LD=gcc LDFLAGS=$(DEBUG_FLAGS) -lambda: main.o parse.o term.o +lambda: main.o token.o lc.o $(LD) $(LDFLAGS) -o $@ $^ %.o: %.c @@ -17,6 +17,6 @@ clean: .PHONY: clean # Dependencies -main.o: parse.h term.h -parse.o: parse.h util.h -term.o: term.h +main.o: token.h lc.h +token.o: token.h util.h +lc.o: lc.h token.h diff --git a/lc.c b/lc.c new file mode 100644 index 0000000..d1afbf5 --- /dev/null +++ b/lc.c @@ -0,0 +1 @@ +#include "lc.h" diff --git a/term.h b/lc.h similarity index 100% rename from term.h rename to lc.h diff --git a/main.c b/main.c index a9439ee..be7d5e9 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -#include "parse.h" +#include "token.h" #include #include @@ -17,12 +17,12 @@ int main(int argc, const char **argv) { fread(text, 1, length, in); fclose(in); TokenStream stream; - TokenStreamError err; + ParseError err; Token token; token_stream_init(&stream, text, length); while (!token_stream_is_eof(&stream)) { token_stream_next(&stream, &token, &err); - if (token_stream_error_set(&err)) { + if (parse_error_is_set(&err)) { printf("Error at %zu:%zu: %s\n", err.pos.line, err.pos.column, err.message); free(text); diff --git a/term.c b/term.c deleted file mode 100644 index 5bd656e..0000000 --- a/term.c +++ /dev/null @@ -1 +0,0 @@ -#include "term.h" diff --git a/parse.c b/token.c similarity index 95% rename from parse.c rename to token.c index 0ea9d1c..47f48de 100644 --- a/parse.c +++ b/token.c @@ -1,4 +1,4 @@ -#include "parse.h" +#include "token.h" #include "util.h" @@ -109,7 +109,7 @@ static int pprint_character(int c, char *buf, size_t buf_size) { } ATTR_FORMAT(3, 4) -static void sprintf_error(TokenStreamError *error, const SrcPos *pos, +static void sprintf_error(ParseError *error, const SrcPos *pos, const char *restrict fmt, ...) { if (error) { error->set = true; @@ -134,10 +134,10 @@ static void sprintf_error(TokenStreamError *error, const SrcPos *pos, static bool read_next_ident(TokenStream *restrict stream, Token *restrict out); // consume = before using static bool read_next_reduce(TokenStream *restrict stream, Token *restrict out, - TokenStreamError *restrict error); + ParseError *restrict error); bool token_stream_next(TokenStream *restrict stream, Token *restrict out, - TokenStreamError *restrict error) { + ParseError *restrict error) { if (error) { error->set = false; } @@ -214,7 +214,7 @@ static bool read_next_ident(TokenStream *restrict stream, Token *restrict out) { } static bool read_next_reduce(TokenStream *restrict stream, Token *restrict out, - TokenStreamError *restrict error) { + ParseError *restrict error) { size_t len = 0; SrcPos start = *POS; int c; diff --git a/parse.h b/token.h similarity index 87% rename from parse.h rename to token.h index e950e0a..32b7b51 100644 --- a/parse.h +++ b/token.h @@ -56,7 +56,7 @@ typedef struct { bool set; SrcPos pos; char message[64]; -} TokenStreamError; +} ParseError; inline static void token_stream_init(TokenStream *stream, const char *src, size_t src_len) { @@ -74,11 +74,11 @@ inline static bool token_stream_is_eof(TokenStream *stream) { // return true on success, false on error bool token_stream_next(TokenStream *restrict stream, Token *restrict out, - TokenStreamError *restrict error); -static inline void token_stream_error_clear(TokenStreamError *error) { + ParseError *restrict error); +static inline void parse_error_clear(ParseError *error) { error->set = false; } -static inline bool token_stream_error_set(const TokenStreamError *error) { +static inline bool parse_error_is_set(const ParseError *error) { return error->set; }