Various people have done this - however most of the links seem to point to a [then defunct] blog by Martin Howard (Randomwraith) from 2004.
A more recent, and available, post on this, using newer pieces can be seen here:
LEGO Logic by Keshav Saharia
Based on a lack of gears and rack and pinion elements, Keshav decided to rebuild the logic gates using an approach based around levers. Extra care was taken to ensure that the movements were uniform so that the outputs moved the same distance as the inputs.
Starting with the simplest gate, a NOT Gate was built:
Then going back to first principles, a NOR Gate:
Combining a NOR with two NOTs gives an AND Gate:
Finally Keshav built the XOR Gate out of 3 NORs and 2 NOTs (or 2 NORs and an AND):
All images used with permission