Пример #1
0
def NFAtoDFA(N):
    q0 = frozenset(N.q0)
    Q = set([q0])
    unprocessedQ = Q.copy()
    delta = {}
    F = []
    Sigma = N.alphabet()

    while len(unprocessedQ) > 0:
        qSet = unprocessedQ.pop()
        delta[qSet] = {}
        for a in Sigma:
            nextStates = reduce(lambda x, y: x | y,
                                [N.getStateBySimbol(q, a) for q in qSet])
            nextStates = frozenset(nextStates)
            if (nextStates is not frozenset([])):
                delta[qSet][a] = nextStates
            if not nextStates in Q:
                if (nextStates is not frozenset([])):
                    Q.add(nextStates)
                    unprocessedQ.add(nextStates)
    for qSet in Q:
        if len(qSet & N.F) > 0:
            F.append(qSet)
    M = DFA(delta, q0, F)
    return M
def NFAtoDFA(N):
	q0 = frozenset(N.q0)
	Q = set([q0])
	unprocessedQ = Q.copy()
	delta = {}
	F = []
	Sigma = N.alphabet()
	
	while len(unprocessedQ) > 0:
		qSet = unprocessedQ.pop()
		delta[qSet] = {}
		for a in Sigma: 
		    nextStates = reduce(lambda x,y: x | y, [N.getStateBySimbol(q,a) for q in qSet])
		    nextStates = frozenset(nextStates)
		    if (nextStates is not frozenset([])):
		        delta[qSet][a] = nextStates
		    if not nextStates in Q: 
		        if (nextStates is not frozenset([])):
		            Q.add(nextStates)
		            unprocessedQ.add(nextStates)
	for qSet in Q: 
		if len(qSet & N.F) > 0: 
			F.append(qSet)
	M = DFA(delta, q0, F)
	return M
Пример #3
0
from __builtin__ import frozenset

__author__ = "Chris Bandy"

import os

_basedir = os.path.abspath(os.path.dirname(__file__))

DEBUG = True

SECRET_KEY = "testkey"
ADMINS = frozenset(["wiper"])

MONGO_HOST = "localhost"
MONGO_PORT = 27017
MONGO_USERNAME = ""
MONGO_PASSWORD = ""

FACEBOOK_KEY = ""
FACEBOOK_SECRET = ""
GOOGLE_KEY = ""
GOOGLE_SECRET = ""
TWITTER_KEY = ""
TWITTER_SECRET = ""


del os