mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-07 21:34:32 +08:00
s/ilabel/transition/g
This commit is contained in:
@@ -58,7 +58,7 @@ class DFAState(object):
|
||||
self.nfa_set = nfa_set
|
||||
self.is_final = final in nfa_set
|
||||
self.arcs = {} # map from terminals/nonterminals to DFAState
|
||||
self.ilabel_to_plan = {}
|
||||
self.transition_to_plan = {}
|
||||
self.nonterminal_arcs = {}
|
||||
|
||||
def add_arc(self, next_, label):
|
||||
@@ -232,7 +232,7 @@ def generate_grammar(bnf_grammar, token_namespace):
|
||||
reserved_strings,
|
||||
terminal_or_nonterminal
|
||||
)
|
||||
dfa_state.ilabel_to_plan[transition] = DFAPlan(next_dfa)
|
||||
dfa_state.transition_to_plan[transition] = DFAPlan(next_dfa)
|
||||
|
||||
_calculate_tree_traversal(rule_to_dfas)
|
||||
return Grammar(start_nonterminal, rule_to_dfas, reserved_strings)
|
||||
@@ -272,7 +272,7 @@ def _calculate_tree_traversal(nonterminal_to_dfas):
|
||||
for dfa_state in dfas:
|
||||
for nonterminal, next_dfa in dfa_state.nonterminal_arcs.items():
|
||||
for transition, pushes in first_plans[nonterminal].items():
|
||||
dfa_state.ilabel_to_plan[transition] = DFAPlan(next_dfa, pushes)
|
||||
dfa_state.transition_to_plan[transition] = DFAPlan(next_dfa, pushes)
|
||||
|
||||
|
||||
def _calculate_first_plans(nonterminal_to_dfas, first_plans, nonterminal):
|
||||
@@ -282,7 +282,7 @@ def _calculate_first_plans(nonterminal_to_dfas, first_plans, nonterminal):
|
||||
# We only need to check the first dfa. All the following ones are not
|
||||
# interesting to find first terminals.
|
||||
state = dfas[0]
|
||||
for transition, next_ in state.ilabel_to_plan.items():
|
||||
for transition, next_ in state.transition_to_plan.items():
|
||||
# It's a string. We have finally found a possible first token.
|
||||
new_first_plans[transition] = [next_.next_dfa]
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class StackNode(object):
|
||||
return '%s(%s, %s)' % (self.__class__.__name__, self.dfa, self.nodes)
|
||||
|
||||
|
||||
def token_to_ilabel(grammar, type_, value):
|
||||
def _token_to_transition(grammar, type_, value):
|
||||
# Map from token to label
|
||||
if type_.contains_syntax:
|
||||
# Check for reserved words (keywords)
|
||||
@@ -157,13 +157,13 @@ class PgenParser(object):
|
||||
|
||||
def add_token(self, type_, value, start_pos, prefix):
|
||||
"""Add a token; return True if this is the end of the program."""
|
||||
ilabel = token_to_ilabel(self.grammar, type_, value)
|
||||
ilabel = _token_to_transition(self.grammar, type_, value)
|
||||
stack = self.stack
|
||||
grammar = self.grammar
|
||||
|
||||
while True:
|
||||
try:
|
||||
plan = stack[-1].dfa.ilabel_to_plan[ilabel]
|
||||
plan = stack[-1].dfa.transition_to_plan[ilabel]
|
||||
break
|
||||
except KeyError:
|
||||
if stack[-1].dfa.is_final:
|
||||
|
||||
@@ -163,7 +163,7 @@ class Parser(BaseParser):
|
||||
# error recovery.
|
||||
if stack[-1].dfa.from_rule == 'simple_stmt':
|
||||
try:
|
||||
plan = stack[-1].dfa.ilabel_to_plan[PythonTokenTypes.NEWLINE]
|
||||
plan = stack[-1].dfa.transition_to_plan[PythonTokenTypes.NEWLINE]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user