diff --git a/src/code.cpp b/src/code.cpp index 1c4e840..27c397a 100644 --- a/src/code.cpp +++ b/src/code.cpp @@ -266,15 +266,6 @@ Expr *read_code() "Negative sign with expr that is not an numeric literal."); } } - case Token::Compare: - { - Expr* e1 = read_code(); - Expr* e2 = read_code(); - Expr* e3 = read_code(); - Expr* e4 = read_code(); - eat_token(Token::Close); - return new CExpr(COMPARE, e1, e2, e3, e4); - } case Token::Eof: { report_error("Unexpected end of file."); @@ -642,47 +633,6 @@ Expr *check_code(Expr *_e) } return tp1; } - case COMPARE: - { - SymSExpr *tp0 = (SymSExpr *)check_code(e->kids[0]); - if (tp0->getclass() != SYMS_EXPR || tp0->val) - { - string errstr0 = - (string("\"compare\" is used with a first expression which ") - + string("cannot be a lambda-bound variable.\n") - + string("1. the expression :") + e->kids[0]->toString() - + string("\n2. its type: ") + tp0->toString()); - report_error(errstr0); - } - - SymSExpr *tp1 = (SymSExpr *)check_code(e->kids[1]); - - if (tp1->getclass() != SYMS_EXPR || tp1->val) - { - string errstr1 = - (string("\"compare\" is used with a second expression which ") - + string("cannot be a lambda-bound variable.\n") - + string("1. the expression :") + e->kids[1]->toString() - + string("\n2. its type: ") + tp1->toString()); - report_error(errstr1); - } - - Expr *tp2 = check_code(e->kids[2]); - Expr *tp3 = check_code(e->kids[3]); - tp2 = tp2->followDefs(); - tp3 = tp3->followDefs(); - if (tp2 != tp3) - { - report_error( - string("\"compare\" used with expressions that do not ") - + string("have equal simple datatypes\nfor their types.\n") - + string("\n1. first expression: ") + e->kids[2]->toString() - + string("\n2. second expression: ") + e->kids[3]->toString() - + string("\n3. first expression's type: ") + tp2->toString() - + string("\n4. second expression's type: ") + tp3->toString()); - } - return tp2; - } case IFEQUAL: { Expr *tp0 = check_code(e->kids[0]); @@ -1022,35 +972,6 @@ Expr *run_code(Expr *_e) _e = e->kids[3]; goto start_run_code; } - case COMPARE: - { - Expr *r1 = run_code(e->kids[0]); - if (!r1) return NULL; - if (r1->getclass() != SYM_EXPR && r1->getclass() != SYMS_EXPR) - { - r1->dec(); - return NULL; - } - Expr *r2 = run_code(e->kids[1]); - if (!r2) return NULL; - if (r2->getclass() != SYM_EXPR && r2->getclass() != SYMS_EXPR) - { - r2->dec(); - return NULL; - } - if (r1 < r2) - { - r1->dec(); - r2->dec(); - _e = e->kids[2]; - goto start_run_code; - } - // else - r1->dec(); - r2->dec(); - _e = e->kids[3]; - goto start_run_code; - } case IFEQUAL: { Expr *r1 = run_code(e->kids[0]); diff --git a/src/expr.cpp b/src/expr.cpp index 34f7d81..27dbf61 100644 --- a/src/expr.cpp +++ b/src/expr.cpp @@ -999,11 +999,6 @@ void Expr::print(ostream &os) const print_kids(os, e->kids); os << ")"; break; - case COMPARE: - os << "(compare"; - print_kids(os, e->kids); - os << ")"; - break; case IFEQUAL: os << "(ifequal"; print_kids(os, e->kids); diff --git a/src/expr.h b/src/expr.h index 1e83368..700742a 100644 --- a/src/expr.h +++ b/src/expr.h @@ -57,7 +57,6 @@ enum FAIL, MARKVAR, IFMARKED, - COMPARE, IFEQUAL }; diff --git a/src/lexer.flex b/src/lexer.flex index c27073c..4f383e9 100644 --- a/src/lexer.flex +++ b/src/lexer.flex @@ -62,7 +62,6 @@ comment ;[^\n]*\n "mp_ifneg" return Token::MpIfNeg; "mp_ifzero" return Token::MpIfZero; "mpz_to_mpq" return Token::MpzToMpq; -"compare" return Token::Compare; "ifequal" return Token::IfEqual; "fail" return Token::Fail; diff --git a/src/sccwriter.cpp b/src/sccwriter.cpp index 6d059cc..a169717 100644 --- a/src/sccwriter.cpp +++ b/src/sccwriter.cpp @@ -588,34 +588,6 @@ void sccwriter::write_code( write_dec(expr, os, ind); } break; - case COMPARE: - { - std::string expr1, expr2; - write_expr(((CExpr*)code)->kids[0], - os, - ind, - expr1, - opt_write_check_sym_expr); - write_expr(((CExpr*)code)->kids[1], - os, - ind, - expr2, - opt_write_check_sym_expr); - indent(os, ind); - os << "if( ((SymExpr*)" << expr1.c_str() - << ")->followDefs() < ((SymExpr*)" << expr2.c_str() - << ")->followDefs() ){" << std::endl; - write_code(((CExpr*)code)->kids[2], os, ind + 1, retModStr); - indent(os, ind); - os << "}else{" << std::endl; - write_code(((CExpr*)code)->kids[3], os, ind + 1, retModStr); - indent(os, ind); - os << "}" << std::endl; - // clean up memory - write_dec(expr1, os, ind); - write_dec(expr2, os, ind); - } - break; case IFEQUAL: { std::string expr1, expr2; @@ -963,7 +935,6 @@ void sccwriter::debug_write_code(Expr* code, std::ostream& os, int ind) case FAIL: os << "fail"; break; case MARKVAR: os << "markvar"; break; case IFMARKED: os << "ifmarked"; break; - case COMPARE: os << "compare"; break; default: os << "???"; break; } }