I'm trying to find a definitive G Code syntax specification, NOT the individual G Codes meaning, specification for this i everywhere, i mean detailed syntax specification, for the purpose of writing a parser.
I have no problem writing a parser, i'm just looking for syntax specs, eg. i know you don't always have to give full xyz coordinates for some Gcodes, and in that case the machine will use last value of a missing coordinate, but i can't seem to find any definitive rule about when it can happen. Also some instruction can be tucked in a single line, and some can't, and again, no definitive rules seem to exist.
Long story:
So i have a diy cnc machine, had it for a while, recently upgraded it to a stable enough state, where i can mill some PCB's. The thing is, it's really tricky to do double sided ones, because mechanical ways of indexing both sides aren't accurate enough.
So there are a few projects aiming at utilising usb camera, with which you aim at known points and then the app calculates and applies a transformation to the gcode, so it compensates for the misalignment.
But the problem is, i want to do this by means other than a camera, and also those projects are unfinished or abandoned.
So i thought, i could make a simple parser for gfcode, but any "specification" i find, only talks about meaning of particular instructions, never about syntax.
I wrote a parser in the past for a subset. G-Code is specified as the ISO 6983 standard (although there are variants from different manufacturers). But the specification documents, as far as I know, are not free (they can be purchased on line). If your goal is to write a parser, there are some open source ones already out there. You may be interested in this doc from the RepRap guys:
http://reprap.org/wiki/G-code
Here is the source code for one parser:
https://github.com/reprappro/RepRapFirmware
Also, take a look to the LinuxCNC project: http://linuxcnc.org/