@@ -69,33 +69,23 @@ def __init__(self,
6969 transition_function : TransitionFunction = None ,
7070 start_state : Hashable = None ,
7171 start_stack_symbol : Hashable = None ,
72- final_states : AbstractSet [Hashable ] = None ):
72+ final_states : AbstractSet [Hashable ] = None ) -> None :
7373 # pylint: disable=too-many-arguments
74- if states is not None :
75- states = {to_state (x ) for x in states }
76- if input_symbols is not None :
77- input_symbols = {to_symbol (x ) for x in input_symbols }
78- if stack_alphabet is not None :
79- stack_alphabet = {to_stack_symbol (x ) for x in stack_alphabet }
80- if start_state is not None :
81- start_state = to_state (start_state )
82- if start_stack_symbol is not None :
83- start_stack_symbol = to_stack_symbol (start_stack_symbol )
84- if final_states is not None :
85- final_states = {to_state (x ) for x in final_states }
86- self ._states : Set [State ] = states or set ()
87- self ._input_symbols : Set [PDASymbol ] = input_symbols or set ()
88- self ._stack_alphabet : Set [StackSymbol ] = stack_alphabet or set ()
74+ self ._states = {to_state (x ) for x in states or set ()}
75+ self ._input_symbols = {to_symbol (x ) for x in input_symbols or set ()}
76+ self ._stack_alphabet = {to_stack_symbol (x )
77+ for x in stack_alphabet or set ()}
8978 self ._transition_function = transition_function or TransitionFunction ()
90- self ._start_state : Optional [ State ] = start_state
79+ self ._start_state = None
9180 if start_state is not None :
92- self ._states .add (start_state )
93- self ._start_stack_symbol : Optional [StackSymbol ] = start_stack_symbol
81+ self ._start_state = to_state (start_state )
82+ self ._states .add (self ._start_state )
83+ self ._start_stack_symbol = None
9484 if start_stack_symbol is not None :
95- self ._stack_alphabet . add (start_stack_symbol )
96- self . _final_states : Set [ State ] = final_states or set ( )
97- for state in self . _final_states :
98- self ._states .add ( state )
85+ self ._start_stack_symbol = to_stack_symbol (start_stack_symbol )
86+ self . _stack_alphabet . add ( self . _start_stack_symbol )
87+ self . _final_states = { to_state ( x ) for x in final_states or set ()}
88+ self ._states .update ( self . _final_states )
9989
10090 @property
10191 def states (self ) -> Set [State ]:
0 commit comments