class YARD::Parser::Ruby::Legacy::RubyLex::BufferedReader

@private
original line, but then skip the here document body.
here document. Once complete, it needs to read the rest of the
line, and keeps it around for later. It then reads the body of the
When the lexer encounters the <<A, it reads until the end of the
B
for
stuff
A
for
stuff
do_something(<<-A, <<-B)
document was initially encountered. For example, we might have
the other to read the rest of the input line where the here
stream into two parts: one to read the body of the here document,
document. At this point we effectively need to split the input
little gem comes about when the lexer encounters a here
We also have to allow for the here document diversion. This
pointers.
into a buffer initially, and then simply traversing it using
We simplify the implementation greatly by reading the entire input
ungetting of characters just read.
Read an input stream character by character. We allow for unlimited

def column

def column
  @offset - @last_newline
end

def divert_read_from(reserve)

def divert_read_from(reserve)
  @content[@offset, 0] = reserve
  @size = @content.size
end

def get_read

def get_read
  res = @content[@read_back_offset...@offset]
  @read_back_offset = @offset
  res
end

def getc

def getc
  return nil if @offset >= @size
  ch = @content[@offset, 1]
  @offset += 1
  @hwm = @offset if @hwm < @offset
  if @newline_pending
    @line_num += 1
    @last_newline = @offset - 1
    @newline_pending = false
  end
  if ch == "\n"
    @newline_pending = true
  end
  ch
end

def getc_already_read

def getc_already_read
  getc
end

def initialize(content)

def initialize(content)
  if /\t/ =~ content
    tab_width = 2
    content = content.split(/\n/).map do |line|
      1 while line.gsub!(/\t+/) { ' ' * (tab_width * $&.length - $`.length % tab_width) } && $~ #`
      line
    end .join("\n")
  end
  @content = String.new(content)
  @content << "\n" unless @content[-1, 1] == "\n"
  @size      = @content.size
  @offset    = 0
  @hwm       = 0
  @line_num  = 1
  @read_back_offset = 0
  @last_newline = 0
  @newline_pending = false
end

def peek(at)

def peek(at)
  pos = @offset + at
  if pos >= @size
    nil
  else
    @content[pos, 1]
  end
end

def peek_equal(str)

def peek_equal(str)
  @content[@offset, str.length] == str
end

def ungetc(_ch)

def ungetc(_ch)
  raise "unget past beginning of file" if @offset <= 0
  @offset -= 1
  if @content[@offset] == ?\n
    @newline_pending = false
  end
end