2 releases

0.1.1 Jun 15, 2025
0.1.0 Jun 15, 2025

#518 in Text editors

Download history 224/week @ 2025-06-15 7/week @ 2025-06-22

231 downloads per month

MIT license

325KB
11K SLoC

C 10K SLoC JavaScript 315 SLoC // 0.1% comments Scheme 90 SLoC // 0.1% comments Rust 32 SLoC // 0.1% comments

tree-sitter-gcode

CI discord matrix npm crates pypi

G-code grammar for tree-sitter.

Features

  • General codes (like G, axes, parameters etc.)
  • Wide range of file extensions supported (see file-types)
  • Both inline and end-of-line comments (some G-code flavors support both)
  • Indexed axes words (as specified in ISO 6983-1)
  • Checksums
  • G-code expressions (specified in RS274NGC)
  • Named parameters (check named paramters for LinuxCNC)
  • M98 and M99 G-Code subprograms with parameter variables (check cnccookbook)
  • G-code subroutines with conditionals and loops support (extended O-codes in LinuxCNC)
  • Fanuc-style subprograms, conditionals and loops

Status

This parser was written using a list of references described in the References section. It should work with most cases. Due to wide range of G-code implementations, some unique features may not be supported in this grammar. However, I was trying my best to match common specifications as precise as possible.

Feel free to open an issue with a feature request or do a pull request to extend this grammar to support more features.

References

Dependencies

~4–280KB