geecode
G-Code parser
Summary
| Latest Version | 0.2.0 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:27 |
Tags
Authors
- geecode
Installation
nimble install geecode
choosenim install geecode
git clone https://github.com/elcritch/geecode
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| geecode | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 1.6.0 | No |
Source
| Repository | https://github.com/elcritch/geecode |
|---|---|
| Homepage | https://github.com/elcritch/geecode |
| Registry Source | nimble_official |
README
Geecode
Geecode is a Nim library for parsing G-code programs into a structured representation suited for CNC and 3D printing workflows. It tokenizes each line into words, addresses, percent markers, and comments while preserving metadata like deleted lines and line numbers.
Features
- Parses G-code into
GCodeProgram,Block,Chunk, andAddressobjects for inspection or transformation - Supports word/address pairs, isolated words, percent markers, and multiple comment styles (
(),[],;) - Tracks deleted lines prefixed with
/and optionalNline numbers without dropping later tokens - Provides equality helpers for comparing addresses, chunks, and blocks in tests
parseGcodeSavingBlockTextalso records printable debug text for each parsed line
Installation
Use Atlas for dependency setup:
atlas use https://github.com/elcritch/geecode
Usage
A minimal example showing parsing and inspection:
import geecode
let program = parseGcode("N10 G1 X1.0 Y2.0 ; move")
let blks = program.getBlock(0)
echo program.numBlocks # 1
echo blks.chunkAt(0) # G1
echo blks.chunkAt(2) # Y2.0
let debugProgram = parseGcodeSavingBlockText("G0 X0 Y0")
echo debugProgram.getBlock(0).debugText # "G0 X0 Y0 "
Tests
Run the test suite with:
nim test
Attribution
Geecode is derived from dillonhuff/gpr and continues under the same MIT license.
License
MIT. See LICENSE for details.