mirror of
https://github.com/OlafvdSpek/ctemplate.git
synced 2025-10-05 19:16:54 +08:00
Partial Python 3 support
This commit is contained in:
parent
91f5147cc7
commit
ce1b8fe617
|
@ -264,7 +264,7 @@ class FSMGenerateC(FSMGenerateAbstract):
|
||||||
state_table = {}
|
state_table = {}
|
||||||
|
|
||||||
for state in self._config.states:
|
for state in self._config.states:
|
||||||
state_table[state] = [default_state for col in xrange(255)]
|
state_table[state] = [default_state for col in range(255)]
|
||||||
|
|
||||||
# We process the transition in reverse order while updating the table.
|
# We process the transition in reverse order while updating the table.
|
||||||
for i_transition in range(len(self._config.transitions) - 1, -1, -1):
|
for i_transition in range(len(self._config.transitions) - 1, -1, -1):
|
||||||
|
@ -281,7 +281,7 @@ class FSMGenerateC(FSMGenerateAbstract):
|
||||||
# Create the inner lists which map input characters to destination states.
|
# Create the inner lists which map input characters to destination states.
|
||||||
for state in self._config.states:
|
for state in self._config.states:
|
||||||
transition_row = []
|
transition_row = []
|
||||||
for c in xrange(0, 255):
|
for c in range(0, 255):
|
||||||
transition_row.append(' /* %06s */ %s' % (repr(chr(c)),
|
transition_row.append(' /* %06s */ %s' % (repr(chr(c)),
|
||||||
state_table[state][c]))
|
state_table[state][c]))
|
||||||
|
|
||||||
|
@ -306,17 +306,17 @@ class FSMGenerateC(FSMGenerateAbstract):
|
||||||
def Generate(self):
|
def Generate(self):
|
||||||
"""Returns the generated the C include statements for the statemachine."""
|
"""Returns the generated the C include statements for the statemachine."""
|
||||||
|
|
||||||
print '\n'.join((self._CreateHeader(),
|
print('\n'.join((self._CreateHeader(),
|
||||||
self._CreateNumStates(),
|
self._CreateNumStates(),
|
||||||
self._CreateStatesEnum(),
|
self._CreateStatesEnum(),
|
||||||
self._CreateStatesExternal(),
|
self._CreateStatesExternal(),
|
||||||
self._CreateStatesInternalNames(),
|
self._CreateStatesInternalNames(),
|
||||||
self._CreateTransitionTable()))
|
self._CreateTransitionTable())))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print "usage: generate_fsm.py config_file"
|
print("usage: generate_fsm.py config_file")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
config = FSMConfig()
|
config = FSMConfig()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user