private static void parseCharacter(PsiBuilder builder) {
    final PsiBuilder.Marker marker = builder.mark();
    if (builder.getTokenType() == RegExpTT.NAMED_CHARACTER) {
      builder.advanceLexer();
      checkMatches(builder, RegExpTT.LBRACE, RegExpBundle.message("parse.error.opening.brace.expected"));
      checkMatches(builder, RegExpTT.NAME, RegExpBundle.message("parse.error.unicode.character.name.expected"));
      checkMatches(builder, RegExpTT.RBRACE, RegExpBundle.message("parse.error.closing.brace.expected"));
      marker.done(RegExpElementTypes.NAMED_CHARACTER);
    }
    else if (builder.getTokenType() == RegExpTT.UNICODE_CHAR) {
      final String text1 = builder.getTokenText();
      assert text1 != null;
      final int value1 = RegExpCharImpl.unescapeChar(text1);
      builder.advanceLexer();
      // merge surrogate pairs into single regexp char
      if (!Character.isSupplementaryCodePoint(value1) && Character.isHighSurrogate((char)value1)) {
        final String text2 = builder.getTokenText();
        if (text2 != null) {
          final int value2 = RegExpCharImpl.unescapeChar(text2);
          if (!Character.isSupplementaryCodePoint(value2) && Character.isLowSurrogate((char)value2)) {
            builder.advanceLexer();
          }
        }
      }
      marker.done(RegExpElementTypes.CHAR);
    }
    else {
      builder.advanceLexer();
      marker.done(RegExpElementTypes.CHAR);
    }
  }
private static void parseCharacter(PsiBuilder builder)