int eval_expr(char *str) { int i; t_env *env; env = create_env(); if (!env) return (0); i = 0; while (str[i]) read_token(env, str, &i); //transform to reverse-polish notation while (env->stack) { add_to_queue(env, env->stack->data); pop_from_stack(env); } env->stack = NULL; i = calc_expr(env); //calculate result from reverse-polish notation free(env); return (i); }
int main() { printf("architecture %s\n", sizeof(void *) == 8 ? "64bit" : "32bit"); printf("expr(compiled) = %d\n", calc_expr(23)); return EXIT_SUCCESS; }