Skip to content

1T17/GGcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

94 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

GGcode Logo

GGcode

GGcode is a parametric G-code compiler that transforms static CNC programs into dynamic, programmable toolpaths. Write JavaScript-like code that generates professional G-code with variables, loops, functions, and math.

🌐 Try GGcode Online β†’ - No installation required!

✨ Key Features

  • Interactive CLI - Smart file selection menu for easy compilation
  • Professional G-code Output - Industry-standard formatting with configurable precision
  • Full Programming Language - Variables, functions, loops, conditionals, and arrays
  • Built-in Math Library - Trigonometry, geometry functions, and constants
  • Cross-platform - Works on Linux, macOS, and Windows
  • Lightweight - Single binary, no dependencies

🎯 Quick Example

Instead of repetitive G-code:

G1 X10 Y0 F300 G1 X20 Y0 F300 G1 X30 Y0 F300

Write parametric GGcode:

let feed = 300 for i = 1..3 { G1 X[i*10] Y0 F[feed] } 

Output:

N10 G1 X10.000 Y0.000 F300.000 N15 X20.000 Y0.000 N20 X30.000 Y0.000

πŸš€ Quick Start

Build & Install

# Install dependencies sudo apt install build-essential gcc make # Ubuntu/Debian xcode-select --install # macOS # Build with automatic global installation prompt make

After building, you'll be prompted:

🌍 Install ggcode globally? (y/N): y Choose installation method: 1) Symlink to /usr/local/bin (recommended) 2) Copy to /usr/local/bin 3) Add to PATH in ~/.bashrc 

Build Options

Command Description
make Build + prompt for global install
make install Install globally (manual)
make uninstall Remove global installation
make test Run unit tests
make win Cross-compile for Windows
make clean Clean build files

�️U Interactive CLI

Default behavior: Run ggcode (if installed globally) or ./GGCODE/ggcode to get an interactive menu:

┏┓┏┓┏┓┏┓┳┓┏┓ ┏┓ β€’β”“ ┏┓┓ β”³ ┃┓┃┓┃ ┃┃┃┃┣ ┃ ┏┓┏┳┓┏┓┓┃┏┓┏┓ ┃ ┃ ┃ β”—β”›β”—β”›β”—β”›β”—β”›β”»β”›β”—β”› ┗┛┗┛┛┗┗┣┛┗┗┗ β”› β”—β”›β”—β”›β”» v1.1.2 Found 3 .ggcode files: 1) part1.ggcode 2) part2.ggcode 3) complex_pattern.ggcode 4) Compile all files h) Show help 0) Exit Select option (0-4, h): 

Command Line Options

# Interactive menu (default) - use globally or locally ggcode # If installed globally ./GGCODE/ggcode # Local binary # Compile specific files ggcode part.ggcode ggcode part1.ggcode part2.ggcode # Compile all files ggcode -a # Custom output ggcode -o custom.gcode part.ggcode ggcode --output-dir ./build *.ggcode # Direct evaluation (testing) ggcode -e "G1 X10 Y20 F300" ggcode -e "for i=1..5 { G1 X[i*10] Y0 }" # Options ggcode -q -a # Quiet mode ggcode --help # Show help ggcode --version # Show version

πŸ“ Project Structure

GGcode/ β”œβ”€β”€ src/ # C source code β”‚ β”œβ”€β”€ lexer/ # Tokenization β”‚ β”œβ”€β”€ parser/ # Syntax parsing and AST β”‚ β”œβ”€β”€ runtime/ # Expression evaluation β”‚ β”œβ”€β”€ generator/ # G-code generation β”‚ β”œβ”€β”€ cli/ # Command line interface β”‚ └── main.c # Main entry point β”œβ”€β”€ tests/ # Unit tests β”œβ”€β”€ GGCODE/ # Compiled binaries β”œβ”€β”€ Makefile # Build system └── README.md # Documentation 

πŸ“ Language Reference

Variables & Arrays

let x = 10 // Variables let points = [1, 2, 3] // 1D arrays let grid = [[1,2], [3,4]] // 2D arrays G1 X[x] Y[points[0]] // Variable interpolation 

Control Flow

if x > 10 { G1 X[x] } // Conditionals for i = 1..5 { G1 X[i] } // Loops while x < 100 { x = x + 1 } // While loops function circle(radius) { // Functions return PI * radius * radius } 

G-code Commands

G0 X[x] Y[y] // Rapid move G1 X[x] Y[y] F[feed] // Linear move M3 S[speed] // Spindle on note {Cut depth: [z]mm} // Comments 

Math & Constants

let angle = 45 * DEG_TO_RAD // Constants: PI, E, TAU, DEG_TO_RAD let dist = sqrt(x*x + y*y) // Math: abs, sqrt, sin, cos, tan, etc. let result = distance(x1, y1, x2, y2) // Geometry functions 

Formatting Control

let decimalpoint = 2 // Control decimal places (0-6) let nline = 0 // Disable line numbering 

🎨 Examples

Parametric Circle

function circle(radius, steps) { for i = 0..steps { let angle = i * (360 / steps) * DEG_TO_RAD let x = radius * cos(angle) let y = radius * sin(angle) G1 X[x] Y[y] F300 } } circle(10, 36) // 10mm radius, 36 steps 

Conditional Machining

let material = 1 // 1=aluminum, 2=steel let speed = material == 1 ? 8000 : 6000 let depth = material == 1 ? -2 : -1 M3 S[speed] G1 Z[depth] F300 

Array Processing

let holes = [[10,10], [20,10], [30,10]] for i = 0..2 { G0 X[holes[i][0]] Y[holes[i][1]] G1 Z-5 F100 G0 Z5 } 

πŸ”§ Troubleshooting

Build Issues:

# Install dependencies sudo apt install build-essential gcc make # Ubuntu/Debian brew install gcc make # macOS # Fix permissions chmod +x GGCODE/ggcode

Runtime Issues:

  • Verify variable names are defined before use
  • Check bracket matching { } and [ ]
  • Use note {} blocks for debugging
  • Run make test to verify installation

πŸ‘¨β€πŸ’» Author

T1 - Creator and Lead Developer

Contributing

  • Report issues on GitHub
  • Submit feature requests
  • Contribute example files
  • Help with documentation and translations

Support


πŸ“œ License

This project is licensed under the MIT License for personal, educational, and small business use.

License Files:

Commercial Use: For commercial licensing inquiries, contact: t@doorbase.io


About

parametric scripting language for generating G-code

Topics

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-COMMERCIAL

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •