Browse Source

Minor optimization in LALR (and fix for last commit)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.7.2
Erez Shinan 5 years ago
parent
commit
8e9da6a6d6
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      lark/parsers/grammar_analysis.py

+ 5
- 4
lark/parsers/grammar_analysis.py View File

@@ -38,7 +38,7 @@ class RulePtr(object):


def update_set(set1, set2):
if not set2:
if not set2 or set1 > set2:
return False

copy = set(set1)
@@ -82,10 +82,11 @@ def calculate_sets(rules):
changed = True

for i, sym in enumerate(rule.expansion):
if set(rule.expansion[:i]) > NULLABLE:
if set(rule.expansion[:i]) <= NULLABLE:
if update_set(FIRST[rule.origin], FIRST[sym]):
changed = True
else:
break
if update_set(FIRST[rule.origin], FIRST[sym]):
changed = True

# Calculate FOLLOW
changed = True


Loading…
Cancel
Save