0

I am writing a parser (in C++) and I have a small list of strings (less than 100) where each one represents a valid parser tag. I need to map each such known tag to an enum value for further processing. As all strings are known at compile time, I have been looking into using a perfect hash function for this purpose.

I am aware of existing tools and algorithms for perfect hash function generation s.a. gperf, mph, cmph. However, all such tools/implementations are under some restrictive license (such as GPL, LGPL, MPL), while due to my limitations I am looking for some code which is under a relaxed license for reuse (such as MIT license) and preferably in C/C++ or C#. Are you aware of any such tool or code ?

Pouria
  • 155
  • 3
  • 12
  • A search for minimal perfect hash implementations returns http://stevehanov.ca/blog/index.php?id=119, among others. It's in python, but should be easily converted to any C-like language. – Jim Mischel Oct 31 '18 at 19:00
  • This question has answers (code and links) that might help: https://stackoverflow.com/questions/55824130/is-it-possible-to-create-a-minimal-perfect-hash-function-without-a-separate-look – Thomas Mueller May 09 '19 at 09:27

1 Answers1

0

Yes, here's one that seems to fit your parameters:
https://www.codeproject.com/Articles/989340/Practical-Perfect-Hashing-in-Csharp

Note it's using a license agreement that I'm not particularly familiar with. But it doesn't look like its GPL related.

Burt_Harris
  • 6,415
  • 2
  • 29
  • 64