Are you talking about the Sharp Distance Sensors (SDSs) with analog outputs
that Pololu sells? For the rest of this post, I am assuming you are.
On the m3pi, connecting the distance sensor to the 3pi directly will require modifying the 3pi's software because it does not have a command to take and relay analog readings to the mbed. You would have to write that software yourself. The easier and probably more performant way to connect the distance sensor is directly to the mbed. If you prefer modifying the 3pi serial slave program, let me know and I can help you with that.
On the m3pi the analog inputs (pin 15 through pin 20) are used as LED outputs, so you will have to modify the m3pi to disconnect the LED circuit from the mbed. A description of the LEDs
is in the m3pi user's guide. Desoldering the 470 ohm resistor (the resistors that are connected to the m3pi via the red traces in the picture below would be a good way to disconnect the circuit. Save the resistor in case you want to restore the LED circuit! Also, in general, desoldering is harder than soldering so make sure you know how to desolder things before attempting it.
After you've modified your m3pi, here are the connections I recommend:
1. SDS GND to m3pi GND
2. SDS Vcc to m3pi VCC
3. SDS Vo to the mbed analog input you disconnected the LED circuit from
Then you would use the mbed AnalogIn
library to read the sensor.