G-code grammar for tree-sitter
npm install @choconao/tree-sitter-gcode[![CI][ci]](https://github.com/ChocolateNao/tree-sitter-gcode/actions/workflows/ci.yml)
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
[![npm][npm]](https://www.npmjs.com/package/@choconao/tree-sitter-gcode)
[![crates][crates]](https://crates.io/crates/tree-sitter-gcode)
[![pypi][pypi]](https://pypi.org/project/tree-sitter-gcode/)
G-code grammar for tree-sitter.
- [x] General codes (like G, axes, parameters etc.)
- [x] Wide range of file extensions supported (see file-types)
- [x] Both inline and end-of-line comments (some G-code flavors support both)
- [x] Indexed axes words (as specified in ISO 6983-1)
- [x] Checksums
- [x] G-code expressions (specified in RS274NGC)
- [x] Named parameters (check named paramters for LinuxCNC)
- [x] M98 and M99 G-Code subprograms with parameter variables (check cnccookbook)
- [x] G-code subroutines with conditionals and loops support (extended O-codes in LinuxCNC)
- [x] Fanuc-style subprograms, conditionals and loops
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.
- Numerical control of machines - ISO 6983-1:2009
- LinuxCNC G-code documentation
- RepRap G-code documentation
- Marlin firmware G-code index
- The NIST RS274NGC Interpreter
[ci]: https://img.shields.io/github/actions/workflow/status/ChocolateNao/tree-sitter-gcode/ci.yml?logo=github&label=CI
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
[npm]: https://img.shields.io/npm/v/@choconao/tree-sitter-gcode?logo=npm
[crates]: https://img.shields.io/crates/v/tree-sitter-gcode?logo=rust
[pypi]: https://img.shields.io/pypi/v/tree-sitter-gcode?logo=pypi&logoColor=ffd242