@Override
  @NotNull
  public ASTNode parse(@NotNull IElementType root, @NotNull PsiBuilder builder) {
    final PsiBuilder.Marker rootMarker = builder.mark();
    while (!builder.eof()) {
      IElementType type = builder.getTokenType();
      if (type == RestTokenTypes.EXPLISIT_MARKUP_START) {
        parseMarkup(builder);
      }
      else if (type == RestTokenTypes.REFERENCE_NAME || type == RestTokenTypes.SUBSTITUTION) {
        PsiBuilder.Marker marker = builder.mark();
        builder.advanceLexer();
        marker.done(RestTokenTypes.REFERENCE_NAME);
      }
      else if (type == RestTokenTypes.TITLE) {
        PsiBuilder.Marker marker = builder.mark();
        builder.advanceLexer();
        marker.done(RestTokenTypes.TITLE);
      }
      else if (type == RestTokenTypes.FIELD) {
        parseFieldList(builder);
      }
      else if (type == RestTokenTypes.INLINE_LINE) {
        PsiBuilder.Marker marker = builder.mark();
        builder.advanceLexer();
        marker.done(RestElementTypes.INLINE_BLOCK);
      }
      else if (type == RestTokenTypes.ANONYMOUS_HYPERLINK) {
        PsiBuilder.Marker marker = builder.mark();
        builder.advanceLexer();
        marker.done(RestElementTypes.REFERENCE_TARGET);
      }
      else if (type == RestTokenTypes.LINE) {
        parseLineText(builder, type);
      }
      else {
        builder.advanceLexer();
      }
    }
    rootMarker.done(root);
    return builder.getTreeBuilt();
  }
@Override
  @NotNull
  public ASTNode parse(@NotNull IElementType root, @NotNull PsiBuilder builder)