Skip to content

Commit 87bb8ef

Browse files
authored
better error messages for shift/reduct conflicts (#1531)
* better error messages for shift reduct conflicts * fix format string
1 parent 6d0f4b6 commit 87bb8ef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lark/parsers/lalr_analysis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ def compute_lalr1_states(self) -> None:
285285
rule ,= rules
286286
if la in actions:
287287
if self.strict:
288-
raise GrammarError(f"Shift/Reduce conflict for terminal {la.name}. [strict-mode]\n ")
288+
msg = f'Shift/Reduce conflict for terminal {la.name}. [strict-mode]\n' \
289+
f' * {rule}\n'
290+
raise GrammarError(msg)
289291
elif self.debug:
290292
logger.warning('Shift/Reduce conflict for terminal %s: (resolving as shift)', la.name)
291293
logger.warning(' * %s', rule)

0 commit comments

Comments
 (0)