inline void EndScopeFound(void) { //printf("inside EndScope\n"); optional opt; while ((opt = arr_peek(operators)).e && (OpCode_type)opt.val != SCOPESTART) { eval_current(); } // arr_pop(operators); //printf("exiting EndScope\n"); }
inline void Evaluate(void) { while (arr_size(operators) != 0) { eval_current(); } arr_reset(operands); arr_reset(operators); //printf("Reset operators and operands\n"); }
bool ConditionalFound() { optional opt; //printf("inside conditional"); while ((opt = arr_peek(operators)).e && !op_is_assign[(OpCode_type)opt.val]) { eval_current(); } //printf("finished eval with operands: \n"); //arr_foreach(operands, print_sym); if (opt.e && (opt = arr_pop(operands)).e) { return get_value(opt.val).ival != 0; } else { stop(); } }
inline void OperatorFound(OpCode_type op) { /* if (op_func_is_binary[op]) { //printf("add operator %s\n", opcode_str[op]); } */ optional opt; while (arr_size(operators) > 0 && (opt = arr_peek(operators)).e && operatorPrecedence[(OpCode_type) opt.val] < operatorPrecedence[op]) { eval_current(); } if (!opt.e) { stop(); } arr_push(operators, (void *) op); }
void evaluate(void) { schedule_next(((cd*)input)->content); while(true) eval_current(); }