-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
37 lines (31 loc) · 919 Bytes
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
.PHONY: test
TEST_DIR := Tests
LEXER := cq_lexer
PARSER := cq_parser
all: $(LEXER).l $(PARSER).y symbol_table.c ast.c pars_utils.c
bison -d $(PARSER).y
flex -o $(LEXER).yy.c $(LEXER).l
clang -o $(PARSER) $(PARSER).tab.c symbol_table.c ast.c pars_utils.c $(LEXER).yy.c -ll
@rm $(LEXER).yy.c $(PARSER).tab.c $(PARSER).tab.h
example:
@./$(PARSER) example.cq --dump
@cat tree_dump.out
@cat symbol_table_dump.out
test:
@printf "Running tests...\n"; \
@for dir in $(TEST_DIR)/*/; do \
if [ -d "$$dir" ]; then \
for file in "$$dir"*; do \
if [ -f "$$file" ]; then \
./$(PARSER) $$file; \
if [ $$? -ne 0 ]; then \
echo "$(PARSER) returned 1 for file $$(basename $$file)"; \
exit 1; \
fi; \
fi; \
done; \
printf "|- %s passed.\n" "$$dir"; \
fi; \
done; \
clean:
@rm -f $(PARSER) $(PARSER).output symtab_dump.out $(PARSER).tab.c $(PARSER).tab.h $(LEXER).yy.c