private static void patternExpected(PsiBuilder builder) {
    final IElementType token = builder.getTokenType();
    if (token == RegExpTT.GROUP_END || token == RegExpTT.RBRACE || token == RegExpTT.CLASS_END) {
      builder.error(RegExpBundle.message("parse.error.unmatched.closing.bracket", builder.getTokenText()));
    }
    else if (token == RegExpTT.LBRACE) {
      builder.error(RegExpBundle.message("error.dangling.opening.bracket"));
      // try to recover
      builder.advanceLexer();
      while (builder.getTokenType() == RegExpTT.NUMBER || builder.getTokenType() == RegExpTT.COMMA) {
        builder.advanceLexer();
      }
      if (builder.getTokenType() == RegExpTT.RBRACE) {
        builder.advanceLexer();
      }
    }
    else if (RegExpTT.QUANTIFIERS.contains(token)) {
      builder.error(RegExpBundle.message("error.dangling.metacharacter", builder.getTokenText()));
    }
    else {
      builder.error(RegExpBundle.message("parse.error.pattern.expected"));
    }
    builder.advanceLexer();
  }
private static void patternExpected(PsiBuilder builder)