As I read, Nim has seamless with any C libraries and code, so for the lexer, you can use Ragel, it produces readable and compact code with -G2 option (I use it on low-end microcontrollers for command parsing).
The more interesting question is Nim able to do backtracking to implement DCG parsing for real complex context-sensitive and arbitrary syntaxes.
