quick and dirty implementation of lex