예제 #1
0
 def testDadaUmaGramaticaRegularSabeQualEhOSeuAFDMinimoCorrespondente(self):
   afd1 = construirAFDComABOndeAsEhPar()
   afd2 = util.obter_afd(construirGRComABOndeAsEhPar())
   
   self.assertTrue(util.sao_equivalentes_af(afd1, afd2))
   self.assertTrue(afd2.ehDeterministico())
   self.assertTrue(afd2.ehMinimo())
예제 #2
0
 def testSeAGramaticaNaoForRegularRetornaNoneAoTentarObterOAFD(self):
   vn = set(['S', 'V'])
   vt = set(['a', 'b', 'c'])
   s = 'S'
   producoes_s = set([Producao('S', 'a V S'), Producao('S', 'b')])
   producoes_v = set([Producao('V', 'a S V'), Producao('V', 'c')])
   producoes = set()
   producoes.update(producoes_s)
   producoes.update(producoes_v)
   
   g = Gramatica(producoes, vn,vt,s)
   afd2 = util.obter_afd(g)
   self.assertEqual(None, afd2)
예제 #3
0
 def testPodeSalvarECarregarUmaGramaticaRegularDoDisco(self):
   gr1 = util.obter_gramatica_regular(construirAFDComABOndeBsEhImpar())
   util.salvar(gr1, os.path.join(os.getcwd(), 'teste.gr'))
   gr2 = util.carregar(os.path.join(os.getcwd(), 'teste.gr'))
   self.assertTrue(util.sao_equivalentes_af(util.obter_afd(gr1), util.obter_afd(gr2)))
예제 #4
0
 def testDadoUmAFDSabeQualEhASuaGramaticaRegularCorrespondenteQuandoAFDNaoProduzEpsilon(self):
   gr1 = util.obter_gramatica_regular(construirAFDComABOndeBsEhImpar())
   afd1  = util.obter_afd(gr1)
   afd2 = construirAFDComABOndeBsEhImpar()
   
   self.assertTrue(util.sao_equivalentes_af(afd1, afd2))
예제 #5
0
 def testDadoUmAFDQueGeraApenasUmSimboloSabeQualEhASuaGramaticaRegularCorrespondente(self):
   gr1 = util.obter_gramatica_regular(construirAFDQueGeraOSimboloA())
   afd1  = util.obter_afd(gr1)
   afd2 = construirAFDQueGeraOSimboloA()
   
   self.assertTrue(util.sao_equivalentes_af(afd1, afd2))
예제 #6
0
    def clicouTransformarEmAFD(self):
        try:
            self._janela_principal.obterAFGUI().setarAF(util.remover_estados_mortos_afd(util.obter_afd(self.obterGR())))

        except Exception as excecao:
            self.mostrarErro(str(excecao))