Ejemplo n.º 1
0
 def finite_state_machine(self):
     """ Generates the full Finite State Machine """
     """ and returns it and the Starting State as a Tuple. """
     # setting up the Finite State Machine for parsing...
     # for parse string "(S)V1(V1)(V1)"
     # will be using:
     # 1 for S
     # 2 for V1
     # in the generator.
     fsm_ = [fsm_state(str(x), False) for x in range(0, 6)]
     fsm_[0].remap(False, {1: fsm_[0], 2: fsm_[0]})
     fsm_[1].remap(False, {1: fsm_[2], 2: fsm_[3]})
     fsm_[2].remap(False, {1: fsm_[0], 2: fsm_[3]})
     fsm_[3].remap(True, {1: fsm_[0], 2: fsm_[4]})
     fsm_[4].remap(True, {1: fsm_[0], 2: fsm_[5]})
     fsm_[5].remap(True, {1: fsm_[0], 2: fsm_[0]})
     raise tuple(fsm_, fsm_[1])
Ejemplo n.º 2
0
 def finite_state_machine(self):
     """ Generates the full Finite State Machine """
     """ and returns it and the Starting State as a Tuple. """
     # setting up the Finite State Machine for parsing...
     # for parse string "(S)(C2)C1(C1)(C1)"
     # will be using:
     # 1 for C1
     # 2 for C2
     # 3 for S
     # in the generator.
     fsm_ = [fsm_state(str(x), False) for x in range(0, 7)]
     fsm_[0].remap(False, {1: fsm[1], 2: fsm[2], 3: fsm[3]})
     fsm_[1].remap(False, {1: fsm[6], 2: fsm[2], 3: fsm[3]})
     fsm_[2].remap(False, {1: fsm[6], 2: fsm[6], 3: fsm[3]})
     fsm_[3].remap(True, {1: fsm[6], 2: fsm[6], 3: fsm[4]})
     fsm_[4].remap(True, {1: fsm[6], 2: fsm[6], 3: fsm[5]})
     fsm_[5].remap(True, {1: fsm[6], 2: fsm[6], 3: fsm[6]})
     fsm_[6].remap(False, {1: fsm[6], 2: fsm[6], 3: fsm[6]})
     return tuple(fsm_, fsm_[0])
Ejemplo n.º 3
0
def gen_():
    # setting up the Finite State Machine for parsing...
    # for parse string "(S)(C2)C1(C1)(C1)"
    # will be using:
    # 1 for C1
    # 2 for C2
    # 3 for S
    # in the generator.
    fsm = [fsm_state(str(x), False) for x in range(0, 7)]
    fsm[0].remap(False, {1: fsm[1], 2: fsm[2], 3: fsm[3]})
    fsm[1].remap(False, {1: fsm[6], 2: fsm[2], 3: fsm[3]})
    fsm[2].remap(False, {1: fsm[6], 2: fsm[6], 3: fsm[3]})
    fsm[3].remap(True, {1: fsm[6], 2: fsm[6], 3: fsm[4]})
    fsm[4].remap(True, {1: fsm[6], 2: fsm[6], 3: fsm[5]})
    fsm[5].remap(True, {1: fsm[6], 2: fsm[6], 3: fsm[6]})
    fsm[6].remap(False, {1: fsm[6], 2: fsm[6], 3: fsm[6]})
    t = gen.gen_list(5, [1, 2, 3], 1)
    results = list()
    for i in t:
        if fsm_transversal(i, fsm[0]):
            results.append(i)
    return results
Ejemplo n.º 4
0
 def finite_state_machine(self):
     # for parse string:
     # "(C3) >> (C2) >> C1 >> (C4) >> (C5 >> (C5)) >> (C6)"
     # will be using:
     # 0 for C1
     # 1 for C2
     # 2 for C3
     # 3 for C4
     # 4 for C5
     # 5 for C6
     # in the generator.
     fsm_ = [ fsm_state(str(x),False) for x in range(0,10) ]
     fsm_[0].remap(False, {0 : fsm_[0],
                           1 : fsm_[0],
                           2 : fsm_[0],
                           3 : fsm_[0],
                           4 : fsm_[0],
                           5 : fsm_[0]} )
     fsm_[1].remap(False, {0 : fsm_[4],
                           1 : fsm_[2],
                           2 : fsm_[3],
                           3 : fsm_[0],
                           4 : fsm_[0],
                           5 : fsm_[0]} )
     fsm_[2].remap(False, {0 : fsm_[4],
                           1 : fsm_[0],
                           2 : fsm_[0],
                           3 : fsm_[0],
                           4 : fsm_[0],
                           5 : fsm_[0]} )
     fsm_[3].remap(False, {0 : fsm_[4],
                           1 : fsm_[2],
                           2 : fsm_[0],
                           3 : fsm_[0],
                           4 : fsm_[0],
                           5 : fsm_[0]} )
     fsm_[4].remap(True,  {0 : fsm_[6],
                           1 : fsm_[6],
                           2 : fsm_[6],
                           3 : fsm_[5],
                           4 : fsm_[7],
                           5 : fsm_[9]} )
     fsm_[5].remap(True,  {0 : fsm_[6],
                           1 : fsm_[6],
                           2 : fsm_[6],
                           3 : fsm_[6],
                           4 : fsm_[7],
                           5 : fsm_[9]} )
     fsm_[6].remap(False, {0 : fsm_[6],
                           1 : fsm_[6],
                           2 : fsm_[6],
                           3 : fsm_[6],
                           4 : fsm_[6],
                           5 : fsm_[6]} )
     fsm_[7].remap(True,  {0 : fsm_[6],
                           1 : fsm_[6],
                           2 : fsm_[6],
                           3 : fsm_[6],
                           4 : fsm_[8],
                           5 : fsm_[9]} )
     fsm_[8].remap(True,  {0 : fsm_[6],
                           1 : fsm_[6],
                           2 : fsm_[6],
                           3 : fsm_[6],
                           4 : fsm_[6],
                           5 : fsm_[9]} )
     fsm_[9].remap(True,  {0 : fsm_[0],
                           1 : fsm_[0],
                           2 : fsm_[0],
                           3 : fsm_[0],
                           4 : fsm_[0],
                           5 : fsm_[0]} )
     return tuple(fsm_,fsm_[1])
Ejemplo n.º 5
0
 def __finite_state_machine(self):
     fsm_ = [fsm_state(str(x), False) for x in range(0, 10)]
     fsm_[0].remap(False, {
         0: fsm_[0],
         1: fsm_[0],
         2: fsm_[0],
         3: fsm_[0],
         4: fsm_[0]
     })
     fsm_[1].remap(False, {
         0: fsm_[2],
         1: fsm_[3],
         2: fsm_[0],
         3: fsm_[0],
         4: fsm_[0]
     })
     fsm_[2].remap(True, {
         0: fsm_[4],
         1: fsm_[6],
         2: fsm_[5],
         3: fsm_[7],
         4: fsm_[9]
     })
     fsm_[3].remap(False, {
         0: fsm_[2],
         1: fsm_[0],
         2: fsm_[0],
         3: fsm_[0],
         4: fsm_[0]
     })
     fsm_[4].remap(True, {
         0: fsm_[6],
         1: fsm_[6],
         2: fsm_[5],
         3: fsm_[7],
         4: fsm_[9]
     })
     fsm_[5].remap(True, {
         0: fsm_[0],
         1: fsm_[0],
         2: fsm_[0],
         3: fsm_[7],
         4: fsm_[9]
     })
     fsm_[6].remap(False, {
         0: fsm_[6],
         1: fsm_[6],
         2: fsm_[6],
         3: fsm_[6],
         4: fsm_[6]
     })
     fsm_[7].remap(True, {
         0: fsm_[6],
         1: fsm_[6],
         2: fsm_[6],
         3: fsm_[8],
         4: fsm_[9]
     })
     fsm_[8].remap(True, {
         0: fsm_[6],
         1: fsm_[6],
         2: fsm_[6],
         3: fsm_[6],
         4: fsm_[9]
     })
     fsm_[9].remap(True, {
         0: fsm_[0],
         1: fsm_[0],
         2: fsm_[0],
         3: fsm_[0],
         4: fsm_[0]
     })
     return tuple(fsm_, fsm_[1])