I am both learning nim and how programming languages work in general, and thought about writing some toy compiler in nim. First (and only) thing I found about parser generators which are both somewhat mature and actively maintained for nim is npeg, but that one looks pretty good. Still would prefer to have the grammar in a separate file than as a DSL but guess this way I'll learn more nim :)
Have been looking for other -small- interpreters, specially written in nim, but only found Arturo which is way above of what I do understand at the moment.
Maybe you guys know more?
I prefer the way Araq writes his parser. He writes them pretty much from scratch without parser generators. It's actually not that hard and you can give better errors to the user.
See an example for json: https://github.com/nim-lang/Nim/blob/version-1-4/lib/pure/parsejson.nim
See an example for SQL: https://github.com/nim-lang/Nim/blob/version-1-4/lib/pure/parsesql.nim
See an example for XML: https://github.com/nim-lang/Nim/blob/version-1-4/lib/pure/parsexml.nim
And finally see the example for Nim itself: https://github.com/nim-lang/Nim/blob/version-1-4/compiler/parser.nim
I use same style when writing my own parser generators. I have written a parser for my own language that compiles to SQL in the same way.