Ensure endOfMode and isIllegal test lexemes at the beginning of a string. Otherwise a regexp like /$/ tests to true for any string even if it doesn't start with a line break.
More useful illegals for Ruby and Java.