def removeDups(rExprs): seen = [] isUnique = True for rExpr in rExprs: for item in seen: #if equalExpr(rExpr.expr, item.expr): if gen.equalExpr(rExpr.expr, item.expr) and rExpr.reduct == item.reduct: isUnique = False if isUnique: seen.append(rExpr) isUnique = True return seen;
def removeDups(rExprs): seen = [] isUnique = True for rExpr in rExprs: for item in seen: #if equalExpr(rExpr.expr, item.expr): if gen.equalExpr(rExpr.expr, item.expr) and rExpr.reduct == item.reduct: isUnique = False if isUnique: seen.append(rExpr) isUnique = True return seen
g.signatures = a.retrieveSignatures( yada.children[0] ) # validates signatues are correct before doing anything else # if any formating is incorrect prints a message and then # exits the program if validateSignatures( g.signatures ): g.equations = a.retrieveEquations( yada.children[1] ) if( validateEquations( g.equations, g.signatures ) ): ##### Tests ##### #expr1 = Expr('top', [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : "empty"}), dict({'ArgType' : "int" ,'Value' : 2})])})]) #expr2 = Expr('top', [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("empty", [])}),dict({'ArgType' : 'int', 'Value' : Expr("top", [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("empty", [])}), dict({'ArgType' : 'int', 'Value' : 2})])})])})])})]) #expr3 = Expr('top', [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("pop", [dict({'ArgType' : 'StackInt', 'Value', Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("empty", [])}),dict({'ArgType' : 'int', 'Value' : 2})]})]})]}),dict({'ArgType' : 'int', 'Value' : Expr("top", [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("empty", [])}), dict({'ArgType' : 'int', 'Value' : 2})])})])})])})]) #print rewriteExpr(expr2, 0) #print rewriteExpr(expr3) ##### Tests ##### #expr1 = Expr('top', [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : "empty"}), dict({'ArgType' : "int" ,'Value' : 2})])})]) #expr2 = Expr('top', [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("empty", [])}),dict({'ArgType' : 'int', 'Value' : Expr("top", [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("empty", [])}), dict({'ArgType' : 'int', 'Value' : 2})])})])})])})]) #expr3 = Expr('top', [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("pop", [dict({'ArgType' : 'StackInt', 'Value', Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("empty", [])}),dict({'ArgType' : 'int', 'Value' : 2})]})]})]}),dict({'ArgType' : 'int', 'Value' : Expr("top", [dict({'ArgType' : 'StackInt', 'Value' : Expr("push", [dict({'ArgType' : 'StackInt', 'Value' : Expr("empty", [])}), dict({'ArgType' : 'int', 'Value' : 2})])})])})])})]) #print rewriteExpr(expr2, 0) #print rewriteExpr(expr3) #for sig in signatures : #base = findBaseCase(sig) rExprs = ExprGen.genNumIterExpressions(400, g.signatures) blackboxer.writeBlackBoxer(g.signatures, output, fileName, rExprs) file.close() output.close()