Rename files

This commit is contained in:
2026-04-03 13:21:17 -07:00
parent aa4564fc55
commit 0671e17e8e
7 changed files with 17 additions and 17 deletions

View File

@@ -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

1
lc.c Normal file
View File

@@ -0,0 +1 @@
#include "lc.h"

View File

6
main.c
View File

@@ -1,4 +1,4 @@
#include "parse.h"
#include "token.h"
#include <stdio.h>
#include <stdlib.h>
@@ -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);

1
term.c
View File

@@ -1 +0,0 @@
#include "term.h"

View File

@@ -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;

View File

@@ -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;
}