In the absence of an existing solution that is basically my plan as stated above with antlr, which can generate a python parser. Although once the grammar is codified, there is no shortage of parser generators that could be applied. Some of the reasons Chris points out above lie at the heart of my motivation as well. Perhaps it is a lost cause, but having some sort of what I would call a "gcode lint" tool would allow people who sometimes take a naive approach to gcode extension to have an reality check.
I can certainly say I didn't think there was actually a gcode specification until long after I was exposed to various flavors of gcode in the wild. I think that is probably common, but perhaps not good for consistency of extension. The rs274 bindings seem interesting but from what I can tell are geared toward generating motion type commands (and backplots), and as a native binding don't really lend themselves well to being a portable parser/verifier. Appreciate the input from all so far! Scott On Sat, Jan 21, 2012 at 7:36 PM, Michael Haberler <mai...@mah.priv.at>wrote: > > > On Sat, Jan 21, 2012 at 12:44:14PM -0600, Jon Elson wrote: > > > >> G-code is extremely easy to parse. Every numeric value is preceded by a > >> letter telling what it is. > > The LinuxCNC dialect is a context-free language at least with respect to > expressions and control structures and as such cannot be parsed with > regular expressions, or by looking at letters (which is equivalent to > regexes in expressive power). > > to build a parser, the best route IMO would be to use a flex/bison type > tool combination for C/C++; for Python tools can be found here: > http://wiki.python.org/moin/LanguageParsing (unsure what would be the > tool of choice these days; Yapps is already used for comp in LinuxCNC) > > It would be useful longer term to have such a grammer & scanner > combination to serve both as a concise executable language definition, and > as a basis for both LinuxCNC and other tools (like CAM programs) as well. > > -- > > to just parse a program for backplot-type purposes, you might look into > using the rs274ngc module which sports Python callbacks for machine > primitives. An example can be found here: > http://git.mah.priv.at/gitweb/rs274-python.git > > - Michael > > > > > ------------------------------------------------------------------------------ > Try before you buy = See our experts in action! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-dev2 > _______________________________________________ > Emc-users mailing list > Emc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/emc-users > ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users