def handle(self): fa1_path = self.argument('fa1') fa2_path = self.argument('fa2') fa1 = fa_from_file(fa1_path) fa2 = fa_from_file(fa2_path) new_fa = fa1.intersection(fa2) write_file_and_print_table(self, new_fa, self.argument('out'))
def test_fa_save_load(): zero = Symbol('0') one = Symbol('1') Q0 = State('Q0') Q1 = State('Q1') Q2 = State('Q2') fa = FiniteAutomaton( { (Q0, zero): [Q0], (Q0, one): [Q1], (Q1, zero): [Q2], (Q1, one): [Q0], (Q2, zero): [Q1], (Q2, one): [Q2], }, Q0, [Q0], ) path = fa_to_file(fa, 'test') new_fa = fa_from_file(str(path)) assert fa == new_fa path.unlink()
def handle(self): fa_path = self.argument('fa') fa = fa_from_file(fa_path) new_fa = fa.minimize() write_file_and_print_table(self, new_fa, self.argument('out'))
def handle(self): fa_path = self.argument('fa') sentence = self.argument('sentence') fa = fa_from_file(fa_path) accepts = fa.evaluate(Sentence(sentence)) if accepts: self.info('Accepted') else: self.error('Rejected')
def handle(self): fa_path = self.argument('fa') out = self.argument('out') if fa_path is None: raise MissingArguments('Not enough arguments') fa = fa_from_file(fa_path) rg = fa.to_regular_grammar() self.line(str(rg)) if out is not None: path = rg_to_file(rg, out) self.info('Wrote regular grammar to {}'.format(path))