Updated the project structure, and modified the Makefile to hopefully be future proof so I can freely make sub-folders in the src/ folder and not have to worry about breaking the Makefile.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
clox
|
clox
|
||||||
*.lox
|
*.lox
|
||||||
obj/
|
obj/
|
||||||
|
bin/
|
||||||
@@ -1,17 +1,26 @@
|
|||||||
CC = gcc
|
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)
|
all:$(BIN)
|
||||||
@mkdir -p obj
|
|
||||||
$(CC) $^ -o obj/clox
|
$(BIN): $(OBJS)
|
||||||
|
$(CC) $(CFLAGS) $(OBJS) -o $@
|
||||||
|
|
||||||
|
$(OBJ)/%.o: $(SRC)/%.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -r obj
|
rm -r $(BINDIR)/* $(OBJ)/*
|
||||||
|
|
||||||
test:
|
test:
|
||||||
./obj/clox test.lox
|
$(BIN) test.lox
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
+4
-4
@@ -40,9 +40,9 @@ struct Expr {
|
|||||||
} expression;
|
} expression;
|
||||||
};
|
};
|
||||||
|
|
||||||
void VisitBinary(struct binary);
|
// void VisitBinary(struct binary);
|
||||||
void VisitGrouping(struct grouping);
|
// void VisitGrouping(struct grouping);
|
||||||
void VisitLiteral(Token);
|
// void VisitLiteral(Token);
|
||||||
void VisitUnary(struct unary);
|
// void VisitUnary(struct unary);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user