class RDoc::Parser::Ruby

def scan

def scan
  reset
  catch :eof do
    begin
      parse_top_level_statements @top_level
    rescue StandardError => e
      if @content.include?('<%') and @content.include?('%>') then
        # Maybe, this is ERB.
        $stderr.puts "\033[2KRDoc detects ERB file. Skips it for compatibility:"
        $stderr.puts @file_name
        return
      end
      if @scanner_point >= @scanner.size
        now_line_no = @scanner[@scanner.size - 1][:line_no]
      else
        now_line_no = peek_tk[:line_no]
      end
      first_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no }
      last_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no + 1 }
      last_tk_index = last_tk_index ? last_tk_index - 1 : @scanner.size - 1
      code = @scanner[first_tk_index..last_tk_index].map{ |t| t[:text] }.join
      $stderr.puts <<-EOF
self.class} failure around line #{now_line_no} of
@file_name}
      EOF
      unless code.empty? then
        $stderr.puts code
        $stderr.puts
      end
      raise e
    end
  end
  @top_level
end