Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xmltodict
- import pprint
- class NFA():
- def __init__(self, file=None):
- super(NFA, self).__init__()
- self.af = None
- self.q = None
- self.f = []
- self.load_from_file(file)
- print("FIN")
- def load_from_file(self, filename):
- with open(filename) as ifile:
- self.af = xmltodict.parse(ifile.read())
- for q in self.af["structure"]["automaton"]["state"]:
- print(q)
- if "initial" in q:
- self.q = q["@id"]
- for t in self.af["structure"]["automaton"]["transition"]:
- print(t)
- def run(self, word):
- return self.run_r(word, self.q)
- def run_r(self, word, q):
- return True|False
- if __name__ == '__main__':
- nfa = NFA("xml_folder/AFND_epsilon_even_0_or_1.jff")
RAW Paste Data