GGcode is a hybrid C/Node.js application with two main components:
- Location:
src/directory - Purpose: The heart of GGcode - compiles
.ggcodefiles to G-code - Output: Standalone binary (
GGCODE/ggcode) and shared library (node/libggcode.so)
- Location:
node/directory - Purpose: Provides web-based IDE, examples, help system, and 3D visualization
- Output: Web server running on port 6990
GGcode_DEV/
├── 📁 src/ # Core C compiler source code
│ ├── 📁 lexer/ # Tokenization and lexical analysis
│ ├── 📁 parser/ # Syntax parsing and AST generation
│ ├── 📁 runtime/ # Expression evaluation and runtime state
│ ├── 📁 generator/ # G-code emission and output generation
│ ├── 📁 error/ # Error handling and reporting
│ ├── 📁 config/ # Configuration and settings
│ ├── 📁 utils/ # Utility functions and helpers
│ ├── 📁 bindings/ # Node.js FFI bindings
│ └── 📄 main.c # Main compiler entry point
│
├── 📁 node/ # Web application and interface
│ ├── 📁 views/ # EJS templates for web pages
│ ├── 📁 public/ # Static assets (CSS, JS, images)
│ ├── 📁 data/ # Help content and documentation
│ ├── 📁 GGCODE/ # Example GGcode files
│ ├── 📄 ggcode.js # Express.js web server
│ ├── 📄 libggcode.so # Shared library (built from C code)
│ └── 📄 package.json # Node.js dependencies
│
├── 📁 tests/ # Unit tests and test framework
├── 📁 bin/ # Compiled test binaries
├── 📄 Makefile # Build system and targets
├── 📄 README.md # Project documentation
└── 📄 video.md # Video script for project promotion
- Purpose: Converts GGcode source text into tokens
- Key Files:
lexer.c,token_types.h,keyword_table.h - Function: Identifies keywords, operators, variables, literals
- Purpose: Builds Abstract Syntax Tree (AST) from tokens
- Key Files:
parser.c,ast_nodes.h,ast_helpers.c - Function: Validates syntax, creates program structure
- Purpose: Evaluates expressions and manages program state
- Key Files:
evaluator.c,runtime_state.h - Function: Variable storage, math operations, control flow
- Purpose: Converts AST into G-code commands
- Key Files:
emitter.c,emitter.h - Function: G-code modal behavior, coordinate calculations
- Purpose: Comprehensive error reporting and recovery
- Key Files:
error.c,error.h - Function: Syntax errors, runtime errors, warnings
- Purpose: File I/O, memory management, reporting
- Key Files:
file_utils.c,output_buffer.c,report.c - Function: File operations, memory allocation, output formatting
- Purpose: FFI (Foreign Function Interface) for Node.js
- Key Files:
nodejs.c - Function: Exposes C functions to JavaScript
- index.ejs - Main editor interface
- app.ejs - JavaScript for editor functionality
- helpExamples.ejs - Help system interface
- view.ejs - 3D visualization viewer
- help-template.ejs - Help content template
- style.css - Main application styling
- flags.css - Language flag icons (SVG)
- OrbitControls.js - 3D camera controls
- metadata.json - Language configuration
- en.json, es.json, fr.json, etc. - Help content in 15 languages
- MULTILANGUAGE_GUIDE.md - Translation guidelines
- Basic examples:
basic_circle.ggcode,square.ggcode - Advanced patterns:
Flower Pattern with Arcs.ggcode - Complex geometries:
Gear Teeth.ggcode,True Spiral with Arcs.ggcode - Educational:
configurator_demo.ggcode,math_functions.ggcode
| Command | Description |
|---|---|
make |
Build main compiler binary |
make node |
Build shared library for Node.js |
make test |
Run all unit tests |
make clean |
Remove build artifacts |
make win |
Cross-compile for Windows |
- C Compiler:
src/*.c→GGCODE/ggcode(standalone binary) - Shared Library:
src/*.c→node/libggcode.so(for Node.js) - Web Server:
node/ggcode.js(Express.js application)
GGcode Source (.ggcode)
↓
Lexer (Tokens)
↓
Parser (AST)
↓
Runtime (Evaluation)
↓
Generator (G-code)
↓
Output (.g.gcode)
User Input (GGcode)
↓
Node.js Server
↓
FFI → C Library
↓
Compilation
↓
G-code Output
↓
3D Visualization
- Code Editor - Syntax highlighting, line numbers
- Configurator Modal - Interactive parameter adjustment
- 3D Visualizer - Real-time tool path preview
- Help System - Multi-language documentation
- Examples Library - 30+ example files
- Language Selector - 15 supported languages
- Backend: Node.js + Express.js
- Frontend: EJS templates + vanilla JavaScript
- 3D Graphics: Three.js for visualization
- FFI: ffi-napi for C/JavaScript bridge
- Styling: Custom CSS with RTL support
- Lines of C Code: ~15,000+ (core compiler)
- Lines of JavaScript: ~2,000+ (web interface)
- Example Files: 30+ GGcode programs
- Supported Languages: 15 (help documentation)
- Test Coverage: Comprehensive unit tests
- Build Targets: Linux, Windows, Node.js
- ✅ Variables and expressions
- ✅ Control flow (if/else, loops)
- ✅ Functions and recursion
- ✅ Arrays (1D, 2D, dynamic)
- ✅ Math library (sin, cos, sqrt, etc.)
- ✅ G-code modal behavior
- ✅ Error handling and reporting
- ✅ Real-time compilation
- ✅ Interactive parameter adjustment
- ✅ 3D tool path visualization
- ✅ Multi-language help system
- ✅ Example library browser
- ✅ Syntax highlighting
- ✅ Export functionality
- Core Feature: Modify C code in
src/ - Tests: Add tests in
tests/ - Web Integration: Update
node/if needed - Documentation: Update help content in
node/data/ - Examples: Add examples in
node/GGCODE/
# Build everything
make && make node
# Run tests
make test
# Start web server
cd node && npm start- video.md - Complete script and production plan
- node/GGCODE/ - Example files to demonstrate
- Web Interface - Real-time demonstrations
- Help System - Feature explanations
- Basic Variables -
basic_circle.ggcode - Loops and Patterns -
Flower Pattern with Arcs.ggcode - Complex Geometry -
Gear Teeth.ggcode - Configurator -
configurator_demo.ggcode - 3D Visualization - Real-time preview
This structure makes GGcode a powerful, professional tool that combines the performance of C with the accessibility of a modern web interface! 🚀