int main(int argc, char** argv) { WORD KeyVal; char ResString[10]; void Ludacris_Speed_GO(void); Ludacris_Speed_GO(); InitGlobals(); InitLCD(); Timer1_Setup(); UART1_Config(); Pin_Setup(); printf("\nUART Configured\n\n"); while(1) { __delay_ms(250); PutsXLCD("No Workie! "); if(!Calculate) { if(TriggerGetKeys) { KeyVal = GetKeyPressed(); FindKey(KeyVal); if(Key != NULL) { ParseInput(Key); } TriggerGetKeys = 0; } } else { DoCalculate(); printf("%f\n", Terms.Result); sprintf(ResString, "%f", Terms.Result); PutsXLCD(ResString); TriggerGetKeys = 0; Calculate = 0; GotOperand1 = 0; GotOperand2 = 0; Operation = NO_OP; } } return (EXIT_SUCCESS); }
bool Parser::CalculateOnStackTop(sym_t opr, CC_STACK<SynToken>& opnd_stack, CC_STACK<sym_t>& opr_stack) { SynToken a, b; SynToken result = { SSID_SYMBOL_X, SynToken::TA_UINT }; if( opr == SSID_COLON ) { SynToken c; sym_t tmp_opr = SSID_INVALID; if(opnd_stack.size() < 3) { errmsg = "Not enough operands for `? :'"; return false; } opr_stack.pop(tmp_opr); if(tmp_opr != SSID_QUESTION) { errmsg = "Invalid operator `:'"; return false; } opnd_stack.pop(c); opnd_stack.pop(b); opnd_stack.pop(a); log(LOGV_DEBUG, "%s ? %s : %s\n", TransToken(&a), TransToken(&b), TransToken(&c)); result = a.u32_val ? b : c; goto done; } else if( opr != SSID_LOGIC_NOT && opr != SSID_BITWISE_NOT ) { if( ! opnd_stack.pop(b) || ! opnd_stack.pop(a)) goto error_no_operands; log(LOGV_DEBUG, "%s %s %s\n", TransToken(&a), TR(intab,opr), TransToken(&b)); } else { if( ! opnd_stack.pop(a) ) goto error_no_operands; log(LOGV_DEBUG, "! %s\n", TransToken(&a)); } if( ! DoCalculate(a, opr, b, result) ) { return false; } done: opnd_stack.push(result); return true; error_no_operands: errmsg.Format("Not enough operands for opeator '%s'", TR(intab,opr)); return false; }