File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 2121"""
2222
2323from .pda import PDA
24+ from .transition_function import TransitionFunction
2425from ..objects .pda_objects import State , Symbol , StackSymbol , Epsilon
2526
2627
2728__all__ = ["PDA" ,
29+ "TransitionFunction" ,
2830 "State" ,
2931 "Symbol" ,
3032 "StackSymbol" ,
Original file line number Diff line number Diff line change @@ -270,7 +270,7 @@ def __contains__(self, transition: InputTransition) -> bool:
270270 input_symbol = to_symbol (input_symbol )
271271 stack_from = to_stack_symbol (stack_from )
272272 s_to = to_state (s_to )
273- stack_to = [ to_stack_symbol (x ) for x in stack_to ]
273+ stack_to = tuple ( to_stack_symbol (x ) for x in stack_to )
274274 return (s_to , stack_to ) in self (s_from , input_symbol , stack_from )
275275
276276 def __iter__ (self ) -> Iterator [Transition ]:
Original file line number Diff line number Diff line change @@ -157,19 +157,16 @@ def to_epsilon_nfa(self) -> EpsilonNFA:
157157 >>> regex.to_epsilon_nfa()
158158
159159 """
160- return self ._to_epsilon_nfa_internal (True )
160+ return self ._to_epsilon_nfa_internal (). copy ( )
161161
162- def _to_epsilon_nfa_internal (self , copy : bool ) -> EpsilonNFA :
163- """
164- Transforms the regular expression into an epsilon NFA.
165- Copy enfa in case of external usage.
166- """
162+ def _to_epsilon_nfa_internal (self ) -> EpsilonNFA :
163+ """ Transforms the regular expression into an epsilon NFA """
167164 if self ._enfa is None :
168165 self ._enfa = EpsilonNFA ()
169166 s_initial = self ._set_and_get_initial_state_in_enfa (self ._enfa )
170167 s_final = self ._set_and_get_final_state_in_enfa (self ._enfa )
171168 self ._process_to_enfa (self ._enfa , s_initial , s_final )
172- return self ._enfa . copy () if copy else self . _enfa
169+ return self ._enfa
173170
174171 def _set_and_get_final_state_in_enfa (self , enfa : EpsilonNFA ) -> State :
175172 s_final = self ._get_next_state_enfa ()
@@ -567,7 +564,7 @@ def accepts(self, word: Iterable[str]) -> bool:
567564 True
568565
569566 """
570- self ._enfa = self ._to_epsilon_nfa_internal (False )
567+ self ._enfa = self ._to_epsilon_nfa_internal ()
571568 return self ._enfa .accepts (word )
572569
573570 @classmethod
You can’t perform that action at this time.
0 commit comments