Initial Commit
This commit is contained in:
27
ee.c
Normal file
27
ee.c
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user