diff --git a/lark/load_grammar.py b/lark/load_grammar.py index 77095a8..356d03d 100644 --- a/lark/load_grammar.py +++ b/lark/load_grammar.py @@ -478,6 +478,7 @@ class Grammar: rules = [] for name, rule_tree, options in rule_defs: ebnf_to_bnf.rule_options = RuleOptions(keep_all_tokens=True) if options.keep_all_tokens else None + ebnf_to_bnf.prefix = name tree = transformer.transform(rule_tree) res = ebnf_to_bnf.transform(tree) rules.append((name, res, options)) diff --git a/lark/parsers/lalr_analysis.py b/lark/parsers/lalr_analysis.py index 7822485..05c1ce8 100644 --- a/lark/parsers/lalr_analysis.py +++ b/lark/parsers/lalr_analysis.py @@ -253,10 +253,10 @@ class LALR_Analyzer(GrammarAnalyzer): actions[la] = (Shift, next_state.closure) for la, rules in state.lookaheads.items(): if len(rules) > 1: - raise GrammarError('Collision in %s: %s' % (la, ', '.join([ str(r) for r in rules ]))) + raise GrammarError('Reduce/Reduce collision in %s between the following rules: %s' % (la, ''.join([ '\n\t\t- ' + str(r) for r in rules ]))) if la in actions: if self.debug: - logging.warning('Shift/reduce conflict for terminal %s: (resolving as shift)', la.name) + logging.warning('Shift/Reduce conflict for terminal %s: (resolving as shift)', la.name) logging.warning(' * %s', list(rules)[0]) else: actions[la] = (Reduce, list(rules)[0])