Beispiel #1
0
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");
}
Beispiel #2
0
inline void Evaluate(void) {
    while (arr_size(operators) != 0) {
        eval_current();
    }
    arr_reset(operands);
    arr_reset(operators);

    //printf("Reset operators and operands\n");
}
Beispiel #3
0
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();
    }
}
Beispiel #4
0
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);
}
Beispiel #5
0
void evaluate(void)
{
	schedule_next(((cd*)input)->content);
	while(true) eval_current();
}