Whole file

lark-parser/lark

The author described this change as fix: raise GrammarError for template usage inside terminals. It counts as a record because the check below fails on the code as it stood at eb015d1b5 and passes on 92047e919, with nothing else changed between the two runs.

Fix saved2026-05-24
Sharing licenceMIT · LICENSE
Change size+2 0

What the code was meant to do, written into the code itself as a save note

fix: raise GrammarError for template usage inside terminals

The change

704704 for name, (term_tree, priority) in term_defs:
705705 if term_tree is None: # Terminal added through %declare
706706 continue
707+ if next(term_tree.find_data('template_usage'), None) is not None:
708+ raise GrammarError("Templates cannot be used inside terminals (%s)" % name)
707709 expansions = list(term_tree.find_data('expansion'))
708710 if len(expansions) == 1 and not expansions[0].children:
709711 raise GrammarError("Terminals cannot be empty (%s)" % name)

The check that tells the two apart

failpass·tests/test_grammar.py::TestGrammar::test_template_in_terminal

Check file tests/test_grammar.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before iteb015d1b5c236b22bf3215fd4a76c891262e1bf8
Broken version dated2026-05-09
Modulelark.load_grammar
Units changedGrammar
Fingerprint9b1a52df1388c430
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in lark-parser/lark