Lexi is a toy Scala implementation of a lexer generator. It provides a small DSL that allows you to define tokens using regular expressions and consequently compiles them to a finite state automaton. To produce the sequence of tokens from an input string, Lexi will then interpret said automaton.
See Lexi.scala for an example of how to use lexi to tokenize a simple input language.