Remove a while loop that is not necessary

This commit is contained in:
Dave Halter
2018-06-21 21:14:14 +02:00
parent cc8038966b
commit 12e11b3d16
+3 -3
View File
@@ -167,14 +167,12 @@ class PgenParser(object):
ilabel = token_to_ilabel(self.grammar, type_, value) ilabel = token_to_ilabel(self.grammar, type_, value)
stack = self.stack stack = self.stack
while True:
ilabel
try: try:
plan = stack[-1].current_dfa.ilabel_to_plan[ilabel] plan = stack[-1].current_dfa.ilabel_to_plan[ilabel]
except KeyError: except KeyError:
self.error_recovery(self.grammar, stack, type_, self.error_recovery(self.grammar, stack, type_,
value, start_pos, prefix, self.add_token) value, start_pos, prefix, self.add_token)
break return False
stack[-1].current_dfa = plan.next_dfa stack[-1].current_dfa = plan.next_dfa
for push in plan.pushes: for push in plan.pushes:
@@ -199,6 +197,8 @@ class PgenParser(object):
except IndexError: except IndexError:
# Stack is empty, set the rootnode. # Stack is empty, set the rootnode.
self.rootnode = new_node self.rootnode = new_node
return True
return False
def add_token(self, type_, value, start_pos, prefix): def add_token(self, type_, value, start_pos, prefix):
"""Add a token; return True if this is the end of the program.""" """Add a token; return True if this is the end of the program."""