BOOL CCalculator::Operand(CCalcExpression** ppcExpression) { BOOL bReturn; CCalcParentheses* pcParentheses; CCalcConstExpression* pcConst; bReturn = Parentheses(&pcParentheses); if (bReturn) { *ppcExpression = pcParentheses; return TRUE; } bReturn = Value(&pcConst); if (bReturn) { *ppcExpression = pcConst; return TRUE; } bReturn = Identifier(&pcConst); if (bReturn) { *ppcExpression = pcConst; return TRUE; } *ppcExpression = NULL; return FALSE; }
/* * Check for primitives * Flags, Registers, Numbers, Addresses and parentheses */ Condition* Primitive(const char** str, Condition* c) { if (isFlag(next)) /* Flags */ { if (c->type1 == TYPE_NO) { c->type1 = TYPE_FLAG; c->value1 = next; } else { c->type2 = TYPE_FLAG; c->value2 = next; } scan(str); return c; } else if (isRegister(next)) /* Registers */ { if (c->type1 == TYPE_NO) { c->type1 = TYPE_REG; c->value1 = next; } else { c->type2 = TYPE_REG; c->value2 = next; } scan(str); return c; } else if (isPCBank(next)) /* PC Bank */ { if (c->type1 == TYPE_NO) { c->type1 = TYPE_PC_BANK; c->value1 = next; } else { c->type2 = TYPE_PC_BANK; c->value2 = next; } scan(str); return c; } else if (isDataBank(next)) /* Data Bank */ { if (c->type1 == TYPE_NO) { c->type1 = TYPE_DATA_BANK; c->value1 = next; } else { c->type2 = TYPE_DATA_BANK; c->value2 = next; } scan(str); return c; } else if (next == '#') /* Numbers */ { unsigned int number = 0; if (!getNumber(&number, str)) { return 0; } if (c->type1 == TYPE_NO) { c->type1 = TYPE_NUM; c->value1 = number; } else { c->type2 = TYPE_NUM; c->value2 = number; } return c; } else if (next == '$') /* Addresses */ { if ((**str >= '0' && **str <= '9') || (**str >= 'A' && **str <= 'F')) /* Constant addresses */ { unsigned int number = 0; if (!getNumber(&number, str)) { return 0; } if (c->type1 == TYPE_NO) { c->type1 = TYPE_ADDR; c->value1 = number; } else { c->type2 = TYPE_ADDR; c->value2 = number; } return c; } else if (**str == '[') /* Dynamic addresses */ { scan(str); Parentheses(str, c, '[', ']'); if (c->type1 == TYPE_NO) { c->type1 = TYPE_ADDR; } else { c->type2 = TYPE_ADDR; } return c; } else { return 0; } } else if (next == '(') { return Parentheses(str, c, '(', ')'); } return 0; }