Browse Source

Minor optimization in LALR (thanks to @Raekye)

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

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

@@ -82,9 +82,10 @@ def calculate_sets(rules):
changed = True changed = True


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


# Calculate FOLLOW # Calculate FOLLOW
changed = True changed = True


Loading…
Cancel
Save