# File lib/asciidoctor/table.rb, line 353
  def initialize reader, table, attributes = {}
    @reader = reader
    @table = table
    # IMPORTANT if reader.cursor becomes a reference, this assignment would require .dup
    @last_cursor = reader.cursor

    if attributes.key? 'format'
      if FORMATS.include?(xsv = attributes['format'])
        if xsv == 'tsv'
          # NOTE tsv is just an alias for csv with a tab separator
          @format = 'csv'
        elsif (@format = xsv) == 'psv' && table.document.nested?
          xsv = '!sv'
        end
      else
        warn %(asciidoctor: ERROR: #{reader.prev_line_info}: illegal table format: #{xsv})
        @format, xsv = 'psv', (table.document.nested? ? '!sv' : 'psv')
      end
    else
      @format, xsv = 'psv', (table.document.nested? ? '!sv' : 'psv')
    end

    if attributes.key? 'separator'
      if (sep = attributes['separator']).nil_or_empty?
        @delimiter, @delimiter_re = DELIMITERS[xsv]
      # QUESTION should we support any other escape codes or multiple tabs?
      elsif sep == '\t'
        @delimiter, @delimiter_re = DELIMITERS['tsv']
      else
        @delimiter, @delimiter_re = sep, /#{::Regexp.escape sep}/
      end
    else
      @delimiter, @delimiter_re = DELIMITERS[xsv]
    end

    @colcount = table.columns.empty? ? -1 : table.columns.size
    @buffer = ''
    @cellspecs = []
    @cell_open = false
    @active_rowspans = [0]
    @column_visits = 0
    @current_row = []
    @linenum = -1
  end