private static TokenType getTypeOf(String s){
        for (TokenType t : TokenType.values()){
            if (s.matches(t.getPattern())){
                return t;
            }
        }
        return null;
    }