docopt / docopt.c

C-code generator for docopt language.
MIT License
318 stars 46 forks source link

Lib rather than generator? #38

Open mcandre opened 7 years ago

mcandre commented 7 years ago

Could doctopt provide a more typical C-style library, instead of a code generator?

I would like to be able to #include "docopt.h", gcc -ldocopt, etc.

kroq-gar78 commented 7 years ago

I'm dumping my thoughts here on how this would work.

If this were to happen, aside from translating most of the logic from Python to C, the struct would also have to be changed to some sort of map. It looks like almost everywhere else, you can substitute code generation with some for loops (e.g. with a list of possible options). For default arguments, that would probably also have to be a map.

Aside from those, the rest of the work would really come from parsing the docopt file.