A streaming gcode parser built with embedded applications in mind
See the codeA gcode parser designed for use in #[no_std] environments. G-code is the
common name for the programming language used by CNC machines and 3D printers.
Design goals:
core visitor API)Default features: alloc, serde. Omit alloc for zero-allocation parsing
via the core visitor API. Requires Rust 1.85+.
First, add gcode to your dependencies:
$ cargo add gcode
Then, you can start using it. Here is a simple example that parses a G-code program using the alloc feature:
fn main() -> Result<(), gcode::Diagnostics> {
let src = "G90 G00 X10 Y20";
let program = gcode::parse(src)?;
assert_eq!(program.blocks.len(), 1);
Ok(())
}
For a visitor-based example, see the pretty_print_visitor example. Run it with
cargo run --example pretty_print_visitor.
This project is licensed under either of
at your option.
It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies, including this one.
The intent of this crate is to be free of soundness bugs. The developers will do their best to avoid them, and welcome help in analyzing and fixing them.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
138 followers · starred Nov 2017
197 followers · starred May 2017
28 followers · starred May 2020
G-code
71.2%
Rust
28.8%
A streaming gcode parser built with embedded applications in mind
See the codeA gcode parser designed for use in #[no_std] environments. G-code is the
common name for the programming language used by CNC machines and 3D printers.
Design goals:
core visitor API)Default features: alloc, serde. Omit alloc for zero-allocation parsing
via the core visitor API. Requires Rust 1.85+.
First, add gcode to your dependencies:
$ cargo add gcode
Then, you can start using it. Here is a simple example that parses a G-code program using the alloc feature:
fn main() -> Result<(), gcode::Diagnostics> {
let src = "G90 G00 X10 Y20";
let program = gcode::parse(src)?;
assert_eq!(program.blocks.len(), 1);
Ok(())
}
For a visitor-based example, see the pretty_print_visitor example. Run it with
cargo run --example pretty_print_visitor.
This project is licensed under either of
at your option.
It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies, including this one.
The intent of this crate is to be free of soundness bugs. The developers will do their best to avoid them, and welcome help in analyzing and fixing them.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
138 followers · starred Nov 2017
197 followers · starred May 2017
28 followers · starred May 2020
G-code
71.2%
Rust
28.8%