> I am curious how would you implement this. Without using 100 line long case 
> statements, for each option.

I would say the keyword is **parser combinator** (PC). You can write customized 
parser for each option and then combine them with combinators. And you can 
achieve all 3 bonus features together. The resulting code of PC is usually 
dense, easy to read and maintain.

All you need is to grasp the concept of PC. It is not hard, but yet not short 
enough to be written here. There are many tutorials of PC on the Internet, even 
though they are written for other languages, the concept and usage is pretty 
much transferable.

I found [honeycomb](https://forum.nim-lang.org/postActivity.xml#honeycomb) 
which interface looks okay, though I have to admit that I have never used it =] 
One possible issue you may encounter is that you have to write custom chain+map 
for parsers of different generic for each size e.g. `chainMap3<T1,T2,T3,T>(p1: 
Parser<T1>, p2: Parser<T2>, p3: Parser<T3>, f: proc(t1:T1, t2:T2, t3:T3): T): 
Parser<T>` or a macro for all generics and sizes.

Reply via email to