Files
ee/ee.c
Jon-William Lewis 465ee17549 Initial Commit
2016-03-28 00:36:40 -05:00

28 lines
647 B
C

#include "ee.h"
int
main (int argc, const char* argv[]){
STACK ee_stack = NULL;
int iter = 1;
while (iter < argc){
if (isNum(argv[iter])){
ee_stack = push(strtod(argv[iter],NULL), ee_stack);
}else if (isOperator(argv[iter][0])){
ee_stack = push(evaluate(&ee_stack, argv[iter][0]), ee_stack);
} else{
ERR_INVALID_INPUT = 1;
}
iter++;
}
if (ee_stack == NULL){
ERR_NS_OPERANDS = 1;
} else if (ee_stack->tail!=NULL){
ERR_NS_OPERATORS = 1;
}
if (!reportErrors()){
printf("%f\n", peek(ee_stack));
}
return 0;
}