Browse Source

Merge pull request #89 from psboyce/patch-1

Use a nested loop for flow control instead of catching StopIteration
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.5
Erez Shinan 6 years ago
committed by GitHub
parent
commit
db1dabc87b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 7 deletions
  1. +2
    -7
      lark/parsers/lalr_parser.py

+ 2
- 7
lark/parsers/lalr_parser.py View File

@@ -66,9 +66,7 @@ class _Parser:
value_stack.append(value)

# Main LALR-parser loop
try:
token = next(stream)
i += 1
for i, token in enumerate(stream):
while True:
action, arg = get_action(token.type)
assert arg != self.end_state
@@ -77,12 +75,9 @@ class _Parser:
state_stack.append(arg)
value_stack.append(token)
if set_state: set_state(arg)
token = next(stream)
i += 1
break # next token
else:
reduce(arg)
except StopIteration:
pass

while True:
_action, arg = get_action('$END')


Loading…
Cancel
Save