sharkdp / pastel

A command-line tool to generate, analyze, convert and manipulate colors
Apache License 2.0
5k stars 97 forks source link

Add combinator parsing to parser.rs #106

Closed halfbro closed 4 years ago

halfbro commented 4 years ago

Relates to #12 This PR adds combinator-based parsing using nom.

This allows the code to uniformly handle numerics (percentages, decimals, integers), and can also eventually provide error output in case of parser failure (not implemented yet).

I haven't had a chance to benchmark the differences between the parsers yet.

sharkdp commented 4 years ago

Thank you very much for your contribution.

This is a bit hard to review, since you also refactored the test cases (which is probably a good thing, haven't looked at it in detail). I am assuming that you did not delete or alter any test cases?

sharkdp commented 4 years ago

Any update on this?

sharkdp commented 4 years ago

I re-instated the removed tests (I don't really understand why they were removed).

I also added a simple benchmark which shows that this new implementation is significantly faster :+1:

image

sharkdp commented 4 years ago

@halfbro Thank you very much!