code: public static TokenRegex compile(String pattern) throws ParseException {
        ExpressionIterator p = QueryToPredicate.PARSER.parse(pattern);
        Expression exp;
        TransitionFunction top = null;
        while ((exp = p.next()) != null) {
           if (top == null) {
              top = consumerize(exp);
           } else {
              top = new TransitionFunction.Sequence(top, consumerize(exp));
           }
        }
        return new TokenRegex(top);
     }
docs: Compiles the regular expression
  
  @param pattern The token regex pattern
  @return A compiled TokenRegex
  @throws ParseException the parse exception