示例#1
0
Expr *Condition()
{
   Expr *left = Expression();
   Operator op = RelOp();
   Expr *right = Expression();
   return new Bop(op, left, right);
}
示例#2
0
void Condition()
{
   Expression();
   Operator op = RelOp();
   Expression();
   Gener(BOP, op);
}
示例#3
0
    bool Add(_tK const &Key, _tV const &Value)
        {
        _tRelOp RelOp;
        tNode *pNew    = nullptr;
        tNode *pParent = nullptr;

        if (!pRoot)
            pNew = new tNode(Key, Value);
        else
            {
            tNode *pNode = dynamic_cast<tNode *>(FindNode(dynamic_cast<tNode *>(pRoot), Key, &pParent));
            if (pNode)
                return false;           // Key is already present in Tree.
            pNew = new tNode(Key, Value);
            }

        if (!pParent)
            pRoot = pNew;
        else
            {
            pNew->pUp = pParent;
            if (RelOp(Key, pParent->KV.first))  pParent->pLeft  = pNew;
            else                                pParent->pRight = pNew;
            }

        InvalidateCache();

        ++NodeCount;
        return true;
        }                               // Add()
示例#4
0
文件: Parser.cpp 项目: Newky/3rdYear
void Parser::Expr(int &type) {
    int type1, op;
    SimExpr(type);
    if (la->kind == 14 || la->kind == 15 || la->kind == 16) {
        RelOp(op);
        SimExpr(type1);
        if (type != type1) Err(L"incompatible types");
        gen->Emit(op);
        type = boolean;
    }
}
示例#5
0
bool Parser::Condition()
{
	if (!Expr()) return false;
	
	if (!RelOp()) return false;
	
	if (!Expr()) return false;
	
	std::cout << "Condition => Expr RelOp Expr\n";
	return true;
}
示例#6
0
bool Parser::Condition()
{
	if (!Expr()) return false;
	
	if (!RelOp()) return false;
	
	if (!Expr()) return false;
	
	if (curr_relop == "<") {
		assembly.push_back(icode(a_line, "LESS"));
		++a_line;
	} else if (curr_relop == ">") {
		assembly.push_back(icode(a_line, "GRTR"));
		++a_line;
	} else if (curr_relop == "=") {
		assembly.push_back(icode(a_line, "EQL"));
		++a_line;
	} else if (curr_relop == "<=") {
		assembly.push_back(icode(a_line, "GRTR"));
		++a_line;
		assembly.push_back(icode(a_line, "NOT"));
		++a_line;
	} else if (curr_relop == ">=") {
		assembly.push_back(icode(a_line, "LESS"));
		++a_line;
		assembly.push_back(icode(a_line, "NOT"));
		++a_line;
	} else if (curr_relop == "<>") {
		assembly.push_back(icode(a_line, "EQL"));
		++a_line;
		assembly.push_back(icode(a_line, "NOT"));
		++a_line;
	} else {
		std::cout << "Invalid relation encountered: " << curr_relop << std::endl;
		return false;
	}
	
//	std::cout << "Condition => Expr RelOp Expr\n";
	return true;
}