diff --git a/finenight/python/fsa.py b/finenight/python/fsa.py index 9bc9a19..8399d52 100644 --- a/finenight/python/fsa.py +++ b/finenight/python/fsa.py @@ -2,7 +2,7 @@ import pdb from error import * -from nameGenerator import IndexNameGenerator +from nameGenerator import PlainIndexNameGenerator from pprint import pprint, pformat from state import State @@ -56,12 +56,12 @@ def __rename__(fsa, nameGenerator): def rename(nfa, nameGenerator = None): """This function will return a FSA with all states renamed according to the nameGenerator class. If the nameGenerator - is not given, the function will use the IndexNameGenerator + is not given, the function will use the PlainIndexNameGenerator class. """ if nameGenerator is None: - nameGenerator = IndexNameGenerator() + nameGenerator = PlainIndexNameGenerator() newNfa = copy.deepcopy(nfa) newKeys = __rename__(nfa, nameGenerator) @@ -97,7 +97,7 @@ def binaryOperationRenaming(lhs, rhs, renameStates, nameGenerator): #this is the renaming procedures if renameStates is True: if nameGenerator is None: - nameGenerator = IndexNameGenerator() + nameGenerator = PlainIndexNameGenerator() newLhs = rename(lhs, nameGenerator) newRhs = rename(rhs, nameGenerator) elif isNameColliding(lhs, rhs) is True: diff --git a/finenight/python/nameGenerator.py b/finenight/python/nameGenerator.py index 88753b9..94e2d71 100644 --- a/finenight/python/nameGenerator.py +++ b/finenight/python/nameGenerator.py @@ -12,3 +12,16 @@ def generate(self): self.index += 1 return name +class PlainIndexNameGenerator: + """Renaming states with this class is not stable, that is, + it's not sure that renaming the FSA will give allways the + same result. + """ + def __init__(self): + self.index = 0 + + def generate(self): + name = str(self.index) + self.index += 1 + return name +