Whole file

lark-parser/lark

The author described this change as Raise GrammarError for non-terminal names in %declare. It counts as a record because the check below fails on the code as it stood at 5718472e5 and passes on 59f774f14, with nothing else changed between the two runs.

Fix saved2026-06-04
Sharing licenceMIT · LICENSE
Change size+2 0

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

Raise GrammarError for non-terminal names in %declare

The change

12741274 for symbol in stmt.children:
12751275 assert isinstance(symbol, Symbol), symbol
12761276 is_term = isinstance(symbol, Terminal)
1277+ if not is_term:
1278+ raise GrammarError("Expecting terminal name to follow %%declare, but got rule name %r" % symbol.name)
12771279 if mangle is None:
12781280 name = symbol.name
12791281 else:

The check that tells the two apart

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

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 it5718472e57a08aac3728c2f26f902de56c48d64c
Broken version dated2026-06-03
Modulelark.load_grammar
Units changedGrammarBuilder
Fingerprint6445baafeca58722
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