Skip to content

Commit

Permalink
added PlainIndexNameGenerator, which is now the default
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbarrette committed Nov 26, 2009
1 parent 94fdc83 commit 2e03262
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions finenight/python/fsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions finenight/python/nameGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2e03262

Please sign in to comment.