Implement the lexer

Since it's pretty much my first non-trivial piece of Scala code, more than one person may want to review this...

Fixes #19.
+1. Just add `@annotation.tailrec` to the method so that the compiler checks whether the method is in fact a tail call optimizable.