def loadFA(self, fileName): obj = fileManipulation.read_file(fileName) if not (isinstance(obj, DFA)) and not (isinstance(obj, NFA)): self.createErrorDialog( "The selected file doesn't represent a Finite Automaton!") return self.createEditor(obj) self.FA = obj self.saved = True self.faUpdated = True self.fileName = fileName self.updateWindowTitle()
def loadRegex(self, filename): obj = fileManipulation.read_file(filename) if not (isinstance(obj, RegularExpression)): self.createErrorDialog( "The selected file doesn't represent a Regular expression!") return self.regex_entry.setText(obj.description) self.REGEX = obj self.saved = True self.regexUpdated = True self.filename = filename self.updateWindowTitle()
def loadFile(self, filename): obj = fileManipulation.read_file(filename) if isinstance(obj, NFA) or isinstance(obj, DFA): self.createFAWindow(obj, filename) elif isinstance(obj, RegularGrammar): self.createGrammarWindow(obj, filename, type='regular') elif isinstance(obj, ContextFreeGrammar): self.createGrammarWindow(obj, filename, type='context-free') elif isinstance(obj, RegularExpression): self.createREWindow(obj, filename) else: # should be unreachable print("Deu ruim")
def loadGramm(self, filename): obj = fileManipulation.read_file(filename) if isinstance(obj, RegularGrammar): self.type = "regular" elif isinstance(obj, ContextFreeGrammar): self.type = "context-free" else: self.createErrorDialog( "The selected file doesn't represent a grammar!") return self.populateEditor(obj) self.GRAMM = obj self.saved = True self.grammUpdated = True self.filename = filename self.updateWindowTitle()
def generateConcatenation(self): if not self.opened: self.createErrorDialog( "You don't have an automaton opened to be combined!!") return if not self.faUpdated: self.getFA() # GET THE AUTOMATA 2 FILE filename, _ = QtWidgets.QFileDialog.getOpenFileName( self, "Open File", "./", "DAT Files (*.dat)") if filename: obj = fileManipulation.read_file(filename) if not (isinstance(obj, DFA)) and not (isinstance(obj, NFA)): self.createErrorDialog( "The selected file doesn't represent a Finite Automaton!") return else: self.parent.createFAWindow(concatenation(self.FA, obj)) else: return