mamba-org / mamba

The Fast Cross-Platform Package Manager
https://mamba.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.89k stars 353 forks source link

maint: Improve the parser of `MatchSpec` #3463

Open jjerphan opened 1 month ago

jjerphan commented 1 month ago

3456 grossly adapted MatchSpec::parse to introduce a robust handling of extra white space in MatchSpec. This current solution is improper (it reallocates memory several time for the edge cases mentioned in #3453), and must be introduced in split_version_and_build as mentioned in https://github.com/mamba-org/mamba/pull/3456#discussion_r1764843646.

Part of the complexity of the parser adaptation comes from MatchSpec's flexibility (for instance numpy 2.0 hxyzw is a valid MatchSpec).

jjerphan commented 1 month ago

I think introducing a formal grammar for MatchSpec, and using parser generators with a generated C++ parser for mamba is the proper solution for this problem.

https://github.com/conda/ceps/pull/82 aims at proposing a grammar.