C_FILES=math/math.c parser/parser.c

H_FILES=math/math.h parser/parser.h

MAIN_C=main.c

PROGRAM=calculator


OBJS=$(C_FILES:.c=.o)
AUTOSAVES=$(C_FILES:.c=.c~) $(H_FILES:.h=.h~) $(MAIN_C:.c=.c~)

CFLAGS=-Wall -Werror -pedantic


all: $(PROGRAM)

check:
	@echo "OBJS:    $(OBJS)"
	@echo "C_FILES: $(C_FILES)"
	@echo "H_FILES: $(H_FILES)"

$(OBJS): $(H_FILES) Makefile

%.c:Makefile $(C_FILES)

%.o::%.c
	gcc $(CFLAGS)  -c $< -o $@

%.E::%.c
	gcc -E $< -o $@

check: all

clean:
	-rm -f $(OBJS) calculator calculator.out calculator-debug a.out *~ *.o
	-rm -f $(AUTOSAVES)

$(PROGRAM): $(OBJS) $(MAIN_C)
	gcc $(CFLAGS) $(MAIN_C) $(OBJS) -o $@


debug: $(OBJS) $(MAIN_C)
	gcc -g $(CFLAGS) $(MAIN_C) $(OBJS) -o calculator-debug
 #Helt enkelt kompilerar programmet med -g flaggan så att den kan debuggas. Lägger den sedan i en särskild mapp.


black-box: 
	./test.sh 





















# #missing args
# 	@echo Calling calculator with arguments 
# 	@echo Expecting MISSING ARGUMENTS
# 	./$(PROGRAM) 1 + 1

# 	@echo Calling calculator with arguments 1
# 	@echo Expecting MISSING ARGUMENTS
# 	./$(PROGRAM) 1
# 	@echo Calling calculator with arguments 1 +
# 	@echo Expecting MISSING ARGUMENTS
# 	./$(PROGRAM) 1 +
# 	@echo Calling calculator with arguments + 1
# 	@echo Expecting MISSING ARGUMENTS
# 	./$(PROGRAM) + 1
# 	#invalid inputs
# 	@echo Calling calculator with arguments a + 1 
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) a + 1
# 	@echo Calling calculator with arguments 1 + a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 + a
# 	@echo Calling calculator with arguments 1 + 1a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 + 1a
# 	@echo Calling calculator with arguments 1a + 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1a + 1
# 	@echo Calling calculator with arguments a + a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) a + a
# 	@echo Calling calculator with arguments a a a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) a a a
# 	@echo Calling calculator with arguments -1a + 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) -1a + 1
# 	@echo Calling calculator with arguments 1 + -1a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 + -1a
# 	#invalid operator
# 	@echo Calling calculator with arguments 1 ++ 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 ++ 1
# 	@echo Calling calculator with arguments 1 -/ 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 -/ 1
# 	@echo Calling calculator with arguments 1 1 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 1 1
# 	@echo Calling calculator with arguments 1.1.1 + 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1.1.1 + 1
# 	@echo Calling calculator with arguments ..1 + 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) ..1 + 1
# 	#Math errors
# 	@echo Calling calculator with arguments 1  / 0
# 	@echo Expecting MATH ERROR
# 	./$(PROGRAM) 1  / 0
# 	@echo Calling calculator with arguments 1 % 0
# 	@echo Expecting MATH ERROR
# 	./$(PROGRAM) 1 % 0
# 	@echo Calling calculator with arguments 1 % 0.5
# 	@echo Expecting MATH ERROR
# 	./$(PROGRAM) 1 % 0.5
# 	#Successaful integer output
# 	@echo Calling calculator with arguments 1 + 1
# 	@echo Expecting 2
# 	./$(PROGRAM) 1 + 1
# 	@echo Calling calculator with arguments 1 + 0
# 	@echo Expecting 1
# 	./$(PROGRAM) 1 + 0
# 	@echo Calling calculator with arguments 2 - 1
# 	@echo Expecting 1
# 	./$(PROGRAM) 2 - 1
# 	@echo Calling calculator with arguments -1 - -1
# 	@echo Expecting 0 
# 	./$(PROGRAM) -1 - -1
# 	@echo Calling calculator with arguments 1 + -1
# 	@echo Expecting 0 
# 	./$(PROGRAM) 1 + -1
# 	@echo Calling calculator with arguments 2 x 2
# 	@echo Expecting 4
# 	./$(PROGRAM) 2 x 2
# 	@echo Calling calculator with arguments 2 x 0
# 	@echo Expecting 0 
# 	./$(PROGRAM) 2 x 0
# 	@echo Calling calculator with arguments 10 / 5
# 	@echo Expecting 2
# 	./$(PROGRAM) 10 / 5
# 	@echo Calling calculator with arguments 10 % 3
# 	@echo Expecting 1
# 	./$(PROGRAM) 10 % 3
# 	@echo Calling calculator with arguments 5 / 10
# 	@echo Expecting 0.5
# 	./$(PROGRAM) 5 / 10
# 	@echo Calling calculator with arguments 5 % 10
# 	@echo Expecting 5
# 	./$(PROGRAM) 5 % 10
# 	#Successful float operations  
# 	@echo Calling calculator with arguments 1 + 0.5
# 	@echo Expecting  1.5
# 	./$(PROGRAM) 1 + 0.5
# 	@echo Calling calculator with arguments 0.5 - 1
# 	@echo Expecting  -0.5
# 	./$(PROGRAM) 0.5 - 1
# 	@echo Calling calculator with arguments 1 x 0.5
# 	@echo Expecting 0.5 
# 	./$(PROGRAM) 1 x 0.5
# 	@echo Calling calculator with arguments 1 / 0.5
# 	@echo Expecting 2 
# 	./$(PROGRAM) 1 / 0.5
# 	@echo Calling calculator with arguments 10 % 6.5
# 	@echo Expecting  4
# 	./$(PROGRAM) 10 % 6.5
# 	@echo Calling calculator with arguments 1 + .5
# 	@echo Expecting  1.5
# 	./$(PROGRAM) 1 + .5
# 	@echo Calling calculator with arguments .5 + .5
# 	@echo Expecting 1 
# 	./$(PROGRAM) .5 + .5

# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 
# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 
# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 
# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 
# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 
# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 
# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 
# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 
# @echo Calling calculator with arguments
# @echo Expecting  
# ./$(PROGRAM) 








# print-test-input: $(PROGRAM)
# @echo "Argument and Input Value errors"
# @echo "args"   
# @echo "`./calculator `" #missing args
# @echo "args  1" 
# @echo " `./calculator 1`" #missing args
# @echo "args  1 +"
# @echo " `./calculator 1 +`" #missing args
# @echo "args  + 1"
# @echo " `./calculator + 1`" #missing arg
# @echo "args  a + 1"
# @echo " `./calculator a + 1`" #invalid value1
# @echo "args  1 + a" 
# @echo " `./calculator 1 + a`" #invalid value2
# @echo "args  1 + 1a" 
# @echo " `./calculator 1 + 1a`" #invalid value2
# @echo "args  1a + 1" 
# @echo " `./calculator 1a + 1`" #invalid value2
# @echo "args  a + a" 
# @echo " `./calculator a + a`" #invalid val1 & val2
# @echo "args a a a"
# @echo " `./calculator a a a`" #all inputs invalid
# @echo "args -1a + 1"
# @echo " `./calculator -1a + 1`"
# @echo "args 1 + -1a"
# @echo " `./calculator 1 + -1a`"


# @echo "Invalid Operator syntax errors"
# @echo "args  1 ++ 1" #samma giltiga tecken
# @echo "OUTPUT  `./calculator 1 ++ 1`"
# @echo "args  1 -/ 1" #olika giltiga tecken
# @echo "OUTPUT  `./calculator 1 -/ 1`"
# @echo "args  1 1 1" 
# @echo "OUTPUT  `./calculator 1 1 1`" #invalid operator
# @echo "args  1.1.1 + 1" 
# @echo "OUTPUT `./calculator 1.1.1 + 1`"
# @echo "args  ..1 + 1"
# @echo OUTPUT "`./calculator ..1 + 1`"


# @echo
# @echo "Math errors"
# # @echo args  2147483647 + 1 \(overflow\) 
# # @echo OUTPUT  `./calculator 2147483647 + 1` #invalid value2
# # @echo args  -2147483648 - 1 
# # @echo OUTPUT  `./calculator -2147483648 - 1` #invalid value2
# @echo "args  1  / 0 "
# @echo "OUTPUT  `./calculator 1 / 0`" #division by zero
# @echo
# @echo "args  1 % 0"
# @echo "OUTPUT  `./calculator 1 % 0`" ##division by zero
# @echo "1 % 0.5 `./calculator 1 % 0.5`"  
# @echo "NOTE  Modulo function rounds input values down."       
# @echo

# @echo "Successful INTEGER Output"
# @echo "100 + 100  OUTPUT  `./calculator 100 + 100`" 
# @echo "1 + 0  OUTPUT  `./calculator 1 + 0`"
# @echo "100 - 50  OUTPUT  `./calculator 100 - 50`"

# @echo "-1 - -1  OUTPUT  `./calculator -1 - -1`"
# @echo "1 + -1  OUTPUT `./calculator 1 + -1`"
# @echo "100 x 100  OUTPUT  `./calculator 100 x 100`"
# @echo "100 / 50  OUTPUT  `./calculator 100 / 50`"
# @echo "100 % 3  OUTPUT  `./calculator 100 % 3`"

# @echo "50 \/ 100  OUTPUT  `./calculator 50 / 100`" #division by larger number
# @echo "50 % 100  OUTPUT  `./calculator 50 % 100`"
# @echo 

# @echo "Successful FLOAT Output"
# @echo "1 + 0.5 `./calculator 1 + 0.5`"
# @echo "0.5 - 1 `./calculator 0.5 - 1`"
# @echo "1 x 0.5 `./calculator 1 x 0.5`"
# @echo "1 / 0.5 `./calculator 1 / 0.5`"
# @echo "10 % 6.5 `./calculator 10 % 6.5`"
# @echo "1 + .5 `./calculator 1 + .5`" #float does not require leading zero
# @echo ".5 + .5 `./calculator .5 + .5`"




