Seulawah Framework
Domain-Specific Language for Industrial Control Systems
Seulawah Framework
Production Ready
Codeberg →
CI: Passing
Seulawah Framework is a domain-specific language (DSL) designed for industrial control systems, IoT, and robotics. It provides clean syntax, strong type safety, and compiles to NodeJS runtime for广泛 deployment.
Output Target
NodeJS Runtime
Runtime
JavaScript ES2020+
Core Components
DSL Design
Syntax, grammar, and semantics for control systems
Parser
Lexical analysis and syntax parsing with error recovery
AST
Abstract Syntax Tree with validation and transformation
Transpiler
AST to NodeJS/TypeScript code generation
Compilation Pipeline
1
DSL Design — Syntax & Grammar
Define language syntax with declarative constructs for devices, sensors,
actuators, and control logic. Grammar rules with BNF notation and type system.
2
Parser — Lexical & Syntax Analysis
Tokenizer (lexer) breaks source into tokens. Parser builds initial parse tree
with error recovery, syntax validation, and meaningful error messages.
3
AST — Abstract Syntax Tree
Current Focus
Transform parse tree into clean AST with semantic analysis, type checking,
scope resolution, and optimization passes. Validation rules for control flow safety.
4
Transpiler — Code Generation
AST traversal generates NodeJS/TypeScript code with async/await patterns,
event-driven architecture, and hardware abstraction layers for ESP32, sensors, actuators.
5
Runtime — Execution & Monitoring
Generated JS runs on NodeJS runtime with built-in monitoring, logging,
error recovery, and hot-reload support for development workflow.
Language Syntax (Draft)
Example Seulawah code for industrial motor control:
// Define a motor device with sensors
device MotorController {
input temperature: Sensor
input vibration: Sensor
output speed: Actuator
output torque: Actuator
rule safety_check {
when temperature > 80.0 or vibration > 5.0 {
speed = 0
torque = 0
alert("Critical: Motor shutdown")
}
}
control pid_loop {
target_speed = 1500
kp = 2.0, ki = 0.5, kd = 1.0
loop 100ms {
error = target_speed - speed.read()
speed.write(pid(error))
}
}
}
Declarative: Device definitions with typed I/O
Rule-based: Safety rules with automatic enforcement
Completed Milestones
Core DSL syntax and grammar defined
BNF notation, type system, control flow constructs, device abstraction patterns
Parser with error recovery built
Lexer (tokenizer), recursive descent parser, meaningful error messages, recovery strategies
AST with validation implemented
Tree structure, semantic analysis, type checking, scope resolution, safety validation
Transpiler to NodeJS/TypeScript created
AST traversal, code generation, async patterns, hardware abstraction, runtime libraries
Runtime libraries built
ESP32 drivers, sensor interfaces, actuator control, event system, monitoring dashboard
Tested with real hardware
Motor control, environmental sensors, smart lock prototype, industrial PLC integration
Quick Start
Install and run your first Seulawah program:
# Install the CLI
npm install -g seulawah
# Create a new project
seulawah init my-controller
cd my-controller
# Define a device
cat > main.sw << 'EOF'
device Motor {
input temp: Sensor<float>
output speed: Actuator<int>
rule thermal {
when temp > 75.0 {
speed = 0
alert("Overheat")
}
}
}
EOF
# Compile and run
seulawah build main.sw
seulawah run
1
Install —
npm install -g seulawah2
Init —
seulawah init <project> scaffolds a new project3
Write — Define devices, sensors, actuators, and control rules in
.sw files4
Build & Run —
seulawah build compiles; seulawah run executesDependencies
Parser Generator
PEG.js / Ohm.js for grammar-based parser generation
AST Library
Custom AST with visitor pattern for traversal and transformation
Type System
Static type checking with inference for sensor/actuator types
Code Generator
Template-based code generation with Babel for JS/TS output