mirror of
https://github.com/davidhalter/parso.git
synced 2026-02-20 08:38:40 +08:00
isfinal -> is_final
This commit is contained in:
@@ -118,7 +118,7 @@ class Grammar(object):
|
|||||||
arcs = []
|
arcs = []
|
||||||
for terminal_or_nonterminal, next_ in state.arcs.items():
|
for terminal_or_nonterminal, next_ in state.arcs.items():
|
||||||
arcs.append((self._make_label(terminal_or_nonterminal), dfas.index(next_)))
|
arcs.append((self._make_label(terminal_or_nonterminal), dfas.index(next_)))
|
||||||
if state.isfinal:
|
if state.is_final:
|
||||||
arcs.append((0, dfas.index(state)))
|
arcs.append((0, dfas.index(state)))
|
||||||
states.append(arcs)
|
states.append(arcs)
|
||||||
self.states.append(states)
|
self.states.append(states)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class DFAState(object):
|
|||||||
assert isinstance(final, NFAState)
|
assert isinstance(final, NFAState)
|
||||||
self.from_rule = from_rule
|
self.from_rule = from_rule
|
||||||
self.nfa_set = nfa_set
|
self.nfa_set = nfa_set
|
||||||
self.isfinal = final in nfa_set
|
self.is_final = final in nfa_set
|
||||||
self.arcs = {} # map from terminals/nonterminals to DFAState
|
self.arcs = {} # map from terminals/nonterminals to DFAState
|
||||||
self.ilabel_to_plan = {}
|
self.ilabel_to_plan = {}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ class DFAState(object):
|
|||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
# Equality test -- ignore the nfa_set instance variable
|
# Equality test -- ignore the nfa_set instance variable
|
||||||
assert isinstance(other, DFAState)
|
assert isinstance(other, DFAState)
|
||||||
if self.isfinal != other.isfinal:
|
if self.is_final != other.is_final:
|
||||||
return False
|
return False
|
||||||
# Can't just return self.arcs == other.arcs, because that
|
# Can't just return self.arcs == other.arcs, because that
|
||||||
# would invoke this method recursively, with cycles...
|
# would invoke this method recursively, with cycles...
|
||||||
@@ -150,7 +150,7 @@ def _dump_nfa(start, finish):
|
|||||||
def _dump_dfas(dfas):
|
def _dump_dfas(dfas):
|
||||||
print("Dump of DFA for", dfas[0].from_rule)
|
print("Dump of DFA for", dfas[0].from_rule)
|
||||||
for i, state in enumerate(dfas):
|
for i, state in enumerate(dfas):
|
||||||
print(" State", i, state.isfinal and "(final)" or "")
|
print(" State", i, state.is_final and "(final)" or "")
|
||||||
for nonterminal, next_ in state.arcs.items():
|
for nonterminal, next_ in state.arcs.items():
|
||||||
print(" %s -> %d" % (nonterminal, dfas.index(next_)))
|
print(" %s -> %d" % (nonterminal, dfas.index(next_)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user