I've never done any of this before, hopefully someone will have experience of CNC.
Anyway, I took a look at the Wikipedia page on G-Code.
G-code
It does look possible to write an interpreter to take some input and translate it into g-code. You face two problems:
- Can you write a clearer language than g-code:- The answer is almost certainly yes. Wikipedia even gives you a head start, for example you can simply replace M07 with CoolantOnMist and M08 with CoolantOnFlood for example, and just do a replace.
- You have the proble of checking the program symantically. e.g. if the program starts the coolant, does the program end the coolant. It the lathe spindle stopped before the program finishes? Does the program do anything that will damage the lathe or prevent the lathe from working?
You could almost create a database (or XML definition???) of friendly names versus G-Code codes. This would immediately resolve point 1. Point 2 is more difficult, it depends how much time and effort you are willing to put in.
I found some free CNC simulators, I don't know how good they are, but they should help you test your generate code before it touches the hardware:
http://www.cncsimulator.com/[
^]