Skip to content

Commit 0362719

Browse files
committed
minor style changes in automata
1 parent c5864bc commit 0362719

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

pyformlang/finite_automaton/deterministic_transition_function.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
NondeterministicTransitionFunction
1414
from .nondeterministic_finite_automaton import InvalidEpsilonTransition
1515

16+
1617
class DeterministicTransitionFunction(NondeterministicTransitionFunction):
1718
"""A deterministic transition function in a finite automaton
1819

pyformlang/finite_automaton/transition_function.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .state import State
1212
from .symbol import Symbol
1313

14+
1415
class TransitionFunction(Iterable[Tuple[State, Symbol, State]]):
1516
""" General transition function representation """
1617

pyformlang/rsa/recursive_automaton.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@ def __init__(self,
3636
for box in boxes:
3737
self._nonterminal_to_box[box.nonterminal] = box
3838

39+
@property
40+
def nonterminals(self) -> Set[Symbol]:
41+
""" The set of nonterminals """
42+
return set(self._nonterminal_to_box.keys())
43+
44+
@property
45+
def boxes(self) -> Set[Box]:
46+
""" The set of boxes """
47+
return set(self._nonterminal_to_box.values())
48+
49+
@property
50+
def start_nonterminal(self) -> Symbol:
51+
""" The start nonterminal """
52+
return self._start_nonterminal
53+
54+
@property
55+
def start_box(self) -> Box:
56+
""" The start box """
57+
return self._nonterminal_to_box[self.start_nonterminal]
58+
3959
def get_box_by_nonterminal(self, nonterminal: Hashable) -> Optional[Box]:
4060
"""
4161
Box by nonterminal
@@ -58,26 +78,6 @@ def get_number_boxes(self) -> int:
5878
""" Size of set of boxes """
5979
return len(self._nonterminal_to_box)
6080

61-
@property
62-
def nonterminals(self) -> Set[Symbol]:
63-
""" The set of nonterminals """
64-
return set(self._nonterminal_to_box.keys())
65-
66-
@property
67-
def boxes(self) -> Set[Box]:
68-
""" The set of boxes """
69-
return set(self._nonterminal_to_box.values())
70-
71-
@property
72-
def start_nonterminal(self) -> Symbol:
73-
""" The start nonterminal """
74-
return self._start_nonterminal
75-
76-
@property
77-
def start_box(self) -> Box:
78-
""" The start box """
79-
return self._nonterminal_to_box[self.start_nonterminal]
80-
8181
@classmethod
8282
def from_regex(cls, regex: Regex, start_nonterminal: Hashable) \
8383
-> "RecursiveAutomaton":

0 commit comments

Comments
 (0)