There are sources of G/M code for various receivers and parts... but usually, someone has had to work pretty hard to create those programs and they're going to want some money for it.
If you want to create your own G/M code for a CNC machine, you could start with a dimensioned engineering drawing of what you want to machine.
EDM: Yes, EDM can be used to machine gun parts. It's slower than using a lathe or mill, but it can be highly accurate. EDM is good when you want to create inside corners on something like a magazine well (eg, AR-15 receiver mag wells are often wire EDM'ed) or you want to put in a blind hole without a broach (you then use what is known as a "die sinker" EDM machine).