lark-parser / lark

Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
MIT License
4.62k stars 395 forks source link

Correctly put terminals into non-capturing groups when combining them #1415

Open MegaIng opened 1 month ago

MegaIng commented 1 month ago

Fix #1414

The core issue is that A B got turned into /{A}{B}/ instead of /(?:{A})(?:{B})/. Most of the time, this doesn't matter, however if B is a manually defined regex, for example /c|d/, the overall regex ended up being /ac|d/, which ofcourse means something else than the BNF was supposed to express.

This is technically a breaking change if people were relying on this buggy behavior.

erezsh commented 1 month ago

Good change. But I have a feeling this might trigger some hidden bugs in various repos.