reg_test = ${SRCDIR}test/reg-test.pl
excep_dir = ${SRCDIR}excep/
gram_dir = ${SRCDIR}gram/
main_dir = ${SRCDIR}main/
misc_dir = ${SRCDIR}misc/
lib_dir = ${SRCDIR}lib/
symtb_dir = ${SRCDIR}symtb/

# Compile Section Below
# Invoke with "make compile"
compile: grammar inter

grammar:
	java org.antlr.Tool $(gram_dir)TableGen.g
	@perl $(misc_dir)buildprep.pl $(gram_dir)TableGenLexer.java $(gram_dir)TableGenParser.java
	javac $(gram_dir)TableGenLexer.java
	javac $(gram_dir)TableGenParser.java

inter:
	javac $(excep_dir)*.java
	javac $(symtb_dir)*.java
	javac $(main_dir)*.java

clean:
	rm -f $(gram_dir){*.class,*.tokens,*java,TableGen__.g}
	rm -f {$(main_dir),$(symtb_dir),$(excep_dir)}*.class

clean-test:
	rm -f ${SRCDIR}testfail.log

# Testing Section Below
# Invoke with "make test"
test: clean-test eq for-if hello_world lists pascal putinto average for-each func-return njnets
	@echo Finished running all tests.

eq: 
	@echo "Running eq test..."
	@${reg_test} eq.tg
	@echo =======================================

for-if: 
	@echo "Running for-if test..."
	@${reg_test} for-if.tg
	@echo =======================================

hello_world: 
	@echo "Running hello_world test..."
	@${reg_test} hello_world.tg
	@echo =======================================

lists: 
	@echo "Running lists test..."
	@${reg_test} lists.tg
	@echo =======================================

pascal: 
	@echo "Running pascal test..."
	@${reg_test} pascal.tg
	@echo =======================================

putinto: 
	@echo "Running putinto test..."
	@${reg_test} putinto.tg
	@echo =======================================

average: 
	@echo "Running average test..."
	@${reg_test} average.tg
	@echo =======================================

for-each: 
	@echo "Running for-each test..."
	@${reg_test} for-each.tg
	@echo =======================================

func-return: 
	@echo "Running func-return test..."
	@${reg_test} func-return.tg
	@echo =======================================

njnets: 
	@echo "Running njnets test..."
	@${reg_test} njnets.tg
	@echo =======================================

