def __init__(self, expr, **kwargs): super(Circuit, self).__init__(**kwargs) self.tree = run.compiler(expr, False) self.tree = json.loads(self.tree) self.circuit = Cir(self.tree) self.add_widget(self.circuit) self.bind(size=self._update_win, pos=self._update_win)
def __init__(self, expr, **kwargs): super(Circuit, self).__init__(**kwargs) self.tree = run.compiler(expr, False) self.tree = json.loads(self.tree) self.circuit = Cir(self.tree) self.add_widget(self.circuit) self.size_hint = (None, None) self.bind(size=self._update_win, pos=self._update_win) Clock.schedule_once(self.run_sim, 0.1)
def compile_expr(expr): # run.clear_parser() return run.compiler(expr)
from compiler import run def compile_expr(expr): # run.clear_parser() return run.compiler(expr) if __name__ == "__main__": expr = "f = a * (b OR (NOT (c * (NOT i)))) xor (d | c | g) xor (s OR t) xor (NOT (a OR (NOT (u and p)))) and f" # expr = "f = (a + b) and c" tree = run.compiler(expr) # tree.print_tree()
def compile_expr(expr): return run.compiler(expr)