--- from: http://rosettacode.org/wiki/Compiler/lexical_analyzer