diff --git a/.gitignore b/.gitignore index decd285..7cbeb09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ clox *.lox obj/ +bin/ \ No newline at end of file diff --git a/Makefile b/Makefile index 8b2fab8..0064e4a 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,26 @@ CC = gcc -SOURCEFILES := $(wildcard *.c) +CFLAGS=-Wall +SRC=src +OBJ=obj +SRCS=$(wildcard $(SRC)/*.c) +OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS)) -SOURCE := $(wildcard *.c) +BINDIR=bin +BIN=$(BINDIR)/clox -$(SOURCE:.c=.o): $(SOURCE) - @mkdir -p obj - $(CC) $^ -o obj/clox +all:$(BIN) + +$(BIN): $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o $@ + +$(OBJ)/%.o: $(SRC)/%.c + $(CC) $(CFLAGS) -c $< -o $@ .PHONY: clean .PHONY: test clean: - rm -r obj + rm -r $(BINDIR)/* $(OBJ)/* test: - ./obj/clox test.lox \ No newline at end of file + $(BIN) test.lox \ No newline at end of file diff --git a/expr.c b/expr.c deleted file mode 100644 index 351907d..0000000 --- a/expr.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "expr.h" - -char* Parenthesize(char*, int, ...); - -void VisitBinary(struct binary expr) { - -} - -void VisitGrouping(struct grouping); -void VisitLiteral(Token); -void VisitUnary(struct unary); - -char* Parenthesize(char* operator, int count, ...) { - va_list list; - va_start(list, count); - - va_arg(list, Expr); -} \ No newline at end of file diff --git a/expr.h b/src/expr.h similarity index 81% rename from expr.h rename to src/expr.h index 02334d1..544352b 100644 --- a/expr.h +++ b/src/expr.h @@ -40,9 +40,9 @@ struct Expr { } expression; }; -void VisitBinary(struct binary); -void VisitGrouping(struct grouping); -void VisitLiteral(Token); -void VisitUnary(struct unary); +// void VisitBinary(struct binary); +// void VisitGrouping(struct grouping); +// void VisitLiteral(Token); +// void VisitUnary(struct unary); #endif \ No newline at end of file diff --git a/interpreter.c b/src/interpreter.c similarity index 100% rename from interpreter.c rename to src/interpreter.c diff --git a/interpreter.h b/src/interpreter.h similarity index 100% rename from interpreter.h rename to src/interpreter.h diff --git a/lox.c b/src/lox.c similarity index 100% rename from lox.c rename to src/lox.c diff --git a/parser.c b/src/parser.c similarity index 100% rename from parser.c rename to src/parser.c diff --git a/parser.h b/src/parser.h similarity index 100% rename from parser.h rename to src/parser.h diff --git a/scanner.c b/src/scanner.c similarity index 100% rename from scanner.c rename to src/scanner.c diff --git a/scanner.h b/src/scanner.h similarity index 100% rename from scanner.h rename to src/scanner.h diff --git a/token.c b/src/token.c similarity index 100% rename from token.c rename to src/token.c diff --git a/token.h b/src/token.h similarity index 100% rename from token.h rename to src/token.h