Base class for writing simple lexers, i.e. for creating small DSLs.