From 71c4abfb245c30507cf0dc3ae1d0f62895282121 Mon Sep 17 00:00:00 2001 From: Erez Shinan Date: Sun, 11 Aug 2019 11:26:31 +0200 Subject: [PATCH] Fixed error message (Issue #380) --- lark/load_grammar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lark/load_grammar.py b/lark/load_grammar.py index f6c1d22..8cd5742 100644 --- a/lark/load_grammar.py +++ b/lark/load_grammar.py @@ -538,7 +538,7 @@ class Grammar: for dups in duplicates.values(): if len(dups) > 1: if dups[0].expansion: - raise GrammarError("Rules defined twice: %s" % ', '.join(str(i) for i in duplicates)) + raise GrammarError("Rules defined twice: %s\n\n(Might happen due to colliding expansion of optionals: [] or ?)" % ''.join('\n * %s' % i for i in dups)) # Empty rule; assert all other attributes are equal assert len({(r.alias, r.order, r.options) for r in dups}) == len(dups)