How sanjay7978/ai-iot-dsl-compiler works
Kelvin is an IoT-rule compiler with an optional English-to-DSL AI front end and a browser Studio. The main workflow is English or DSL input, compilation and rule checks, optimization, target-code generation, then inspection or simulation in the Studio. The README documents the compiler stages and targets; the excerpts show the UI’s compile requests, AI verification, and simulation calls. Some internal compiler and server wiring is unsampled, so those documented relationships are cited to the README and uncertain links are omitted.
Main entry points: main.js Studio controller · ai.py English draft · server.py HTTP API · semantic.cpp Semantic and rule analysis
Components 24
Input and AI
- English draft
ai.py - DSL source
src/main.cpp
Compiler
- Compile driver
src/compiler.cpp - Lexer
src/lexer.cpp - Parser and grammar
src/parser.cpp - AST
src/ast.cpp - Semantic and rule analysis
src/semantic.cpp - Rule conflict analysis
src/rule_analysis.cpp - Intermediate code
src/ir.cpp - Control-flow graph
src/cfg.cpp - Optimizer
src/optimizer.cpp - Target code generation
src/codegen.cpp
Server and targets
- HTTP API
server.py - Target runtimes
runtime
Studio
- DSL editor
web/js/editor.js - Studio controller
web/js/main.js - Compiler result panes
web/js/panes.js - Compile X-ray
web/js/xray.js - Compiler visualizations
web/js/graph.js
Simulation
- Digital twin
web/js/twin.js - IR virtual machine
web/js/vm.js
Other components
- Rule author
- Model providers
- Sensor remote
Connections 27
- Rule author → English draft: describes rule
README.md - English draft → Model providers: requests draft
ai.py - Model providers → English draft: returns DSL
ai.py - English draft → DSL source: produces DSL
README.md - Rule author → DSL source: writes rule
README.md - DSL source → HTTP API: submits source
- HTTP API → Compile driver: invokes compile
- English draft → HTTP API: requests verification
server.py - HTTP API → English draft: checks compiler result
ai.py - Compile driver → Lexer: lexes
README.md - Lexer → Parser and grammar: supplies tokens
README.md - Parser and grammar → AST: builds tree
README.md - AST → Semantic and rule analysis: checks meaning
README.md - Semantic and rule analysis → Rule conflict analysis: analyzes rules
src/semantic.cpp - Semantic and rule analysis → Intermediate code: lowers to IR
README.md - Intermediate code → Control-flow graph: forms control flow
README.md - Control-flow graph → Optimizer: guides passes
README.md - Optimizer → Target code generation: emits optimized program
README.md - Target code generation → Target runtimes: targets runtime
README.md - Studio controller → DSL editor: reads source
web/js/main.js - Studio controller → HTTP API: requests compile
web/js/main.js - Studio controller → Compiler result panes: renders results
web/js/main.js - Compiler result panes → Compiler visualizations: draws AST and CFG
web/js/panes.js - Studio controller → Compile X-ray: opens trace
web/js/main.js - Studio controller → IR virtual machine: executes optimized IR
web/js/main.js - IR virtual machine → Digital twin: updates device state
web/js/main.js - Sensor remote → Studio controller: sets sensor values
README.md