
.PRECIOUS: %.cpp
%.cpp: %.l yyTestParser.h
	flex -o $@ $<

yyTestParser.h: parser.cpp
%.cpp: %.y
	bison -v -Wcounterexamples -o $@ $<

%.o: %.cpp
	g++ -g -o $@ -c $<

test.elf: lexer.o parser.o test.o ast/expression.o ast/statement.o ast/type.o
	g++ -o $@ $^

.PHONY: run
run: test.elf
	./test.elf example.txt

.PHONY: clean
clean:
	rm -f lexer.cpp parser.cpp yyTestParser.h *.o *.elf ast/*.o
