def write_clauses(vars, prefix, name, mode='w'): f = open(name, mode) i = 0 for v in vars: f.write(prefix + str(i) + ' := ' + translate(v) + ";\n") i += 1 f.flush() f.close()
def write_range_clause(clause, min, max, value, name, mode='w'): f = open(name, mode) cv = translate(value) assert(cv[0:3] == 'AND') nv = "[" + str(min) + "," + str(max) + "]" + cv[3:] f.write(clause + ' := ' + nv + ";\n") f.flush() f.close()
def write_dedupe(prefix_match=None, name="02-dedupe.txt", mode='w'): global clause_dedupe_s f = open(name, mode) for k in clause_dedupe_s: if prefix_match == None or (prefix_match != None and len(prefix_match) > 0 and prefix == k[0:len(prefix)]): f.write(k + " := " + translate(clause_dedupe_s[k]) + ";\n") f.flush() f.close()
def write_literal(f, dest, source, eval_table, prefix): if not source in ['T', 'F']: clause = simplify(source) var = clause_dedupe(clause, prefix) #print([dest, source, var]) if not dest in eval_table: eval_table[dest] = var if f != None: f.write(dest + " := " + var + ";\n") elif dest in eval_table and f != None: if eval_table[dest] in ['T', 'F']: f.write(dest + " := " + var + ";\n") f.write("etc" + dest + " := " + dest + " == " + eval_table[dest] + ";\n") elif type(eval_table[dest]) == type(dest): print("Here2") f.write(eval_table[dest] + " := " + translate(simplify(source)) + ";\n") else: print("Unknown eval_table entry for `" + dest + "`: " + eval_table[dest]) else: eval_table[dest] = source return eval_table
def writeo(f, prefix, zz, n, eval_table): for i in range(0, 32): name = prefix + str(n) + str(i) if not zz[i] in ['T', 'F']: clause = simplify(zz[i]) var = clause_dedupe(clause, prefix) if not name in eval_table: eval_table[name] = var if f != None: f.write(name + " := " + var + ";\n") elif name in eval_table and f != None: if eval_table[name] in ['T', 'F']: f.write(name + " := " + var + ";\n") f.write("etc" + name + " := " + name + " == " + eval_table[name] + ";\n") elif type(eval_table[name]) == type(name): print("Here2") f.write(eval_table[name] + " := " + translate(simplify(zz[i])) + ";\n") else: print("Unknown eval_table entry for `" + name + "`: " + eval_table[name]) else: eval_table[name] = zz[i] if f != None: f.write(name + " := " + zz[i] + ";\n") return eval_table
def write_clause(clause, value, name, mode='w'): f = open(name, mode) f.write(clause + ' := ' + translate(value) + ";\n") f.flush() f.close()