> 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