Browse Source

Better error message for reduce collisions in lalr

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.4
Erez Shinan 6 years ago
parent
commit
9d84c52140
2 changed files with 4 additions and 1 deletions
  1. +3
    -0
      lark/parsers/grammar_analysis.py
  2. +1
    -1
      lark/parsers/lalr_analysis.py

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

@@ -35,6 +35,9 @@ class RulePtr(object):


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

copy = set(set1)
set1 |= set2
return set1 != copy


+ 1
- 1
lark/parsers/lalr_analysis.py View File

@@ -91,7 +91,7 @@ class LALR_Analyzer(GrammarAnalyzer):

for k, v in lookahead.items():
if not len(v) == 1:
raise GrammarError("Collision in %s: %s" %(k, v))
raise GrammarError("Collision in %s: %s" %(k, ', '.join(['\n * %s: %s' % x for x in v])))

self.states[state] = {k:v[0] for k, v in lookahead.items()}



Loading…
Cancel
Save