Look up how a mass spectrometer works. I believe the fusion torch concept is something of a variation on this. You don't need fusion to make it work, just an abundant energy source. It could be solar powered, for example.
First you heat the substance to a very high temperature (start with a mirror based solar concentrator, then zap the pre-heated material with a laser to reach the very high temperatures). This produces positive ions because electrons (which carry negative charge) are lighter than atomic nuclei (which carry positive charge). If you heat it up enough, any molecules will break down (since molecular bonds are based on shared electrons).
Then you magnetically propel the ions along a curved trajectory. An ultra hard vacuum (like exists in space or on the lunar surface) is necessary, otherwise they would bump into too many air molecules for this to work. Heavier ions retain their forward momentum longer, causing them to be separated from lighter ones as they are magnetically deflected around the curve. On the other hand, particles with higher charge are deflected more due to higher interaction with the magnetic field. So there is separation based on the charge-mass ratio of the atoms. These atoms end up forming different "beams" of particles, one beam for each element.
This concept is discussed by Freitas as an Atomic Separator Replicator. It isn't particularly energy efficient, but this is an "omnivorous" refining strategy, which means you can take just about any material and feed it in, and get the elements that it is comprised of. For self replication in an energy rich environment (i.e. since there is a lot of solar energy in space), an all-in-one process like that plausibly makes the most sense. The main design goals would be to eliminate the need for human involvement in the construction, operation, and maintenance of the machinery. Lunar regolith (just like dirt on earth) is about 10% aluminum, but the process we use for separating it out here on earth is rather complex, relies on specific ores, and would require pressurized tanks and specialized electrodes for high temperature electrolysis.
Something you could perhaps refine more easily would be iron, which is present in small amounts throughout the lunar regolith as a result of meteor fragmentation. You would collect the iron using magnets attached to rovers. That would produce a mixture of iron oxide (rust) and nickle-iron. Heating it to remove the oxygen would result in a metallic iron-nickle alloy. Further processing with carbon would be needed to make steel, but high quality steel might not be needed for your self replicating units -- the gravity is only a sixth there.