I've spent sometime making the `lexbase` version: [https://gist.github.com/alaviss/83a48f0344d55efbebcca3bce35e4157](https://gist.github.com/alaviss/83a48f0344d55efbebcca3bce35e4157)
This beast has ~310 LoC, so it's just ~100 LoC more than your `re` version :) After writing mine, I noted a few points in your version that could be changed: * It's possible to assign a string to an `enum`, see my version and [Manual#Enumeration Types](http://nim-lang.github.io/Nim/manual#types-enumeration-types). This should allow you to drop `tkNames`. * You should use `object` instead of `tuple`. Unlike other programming languages, `object` in Nim is fairly lightweight, and doesn't cause any slowdown compared to `tuple`, and also carries some perks like having a type constructor. * You should reduce the amount of `return` in your code. In Nim, `return` should only be used when you need the control flow semantic of it. If you wanted to return a result, use the `result` variable or an expression at the end of the `proc`. * Line 202: Use `let` please :) P/s: If you are looking to submit your version to Rosetta Code, please submit mine as well, I'm rather lazy creating yet another account :P
