How 61131/echidna works
Main Components
a. Compiler Frontend
• Lexer (src/lexer.l)
• Parser (src/grammar.y)
• Symbol Table (src/symbol.c)
• Abstract Syntax Tree (src/tree.c)
b. Compiler Backend
• Bytecode Generator (src/bytecode/)
• Code Optimization
• Binary Output Generation
c. Virtual Machine Runtime
• Task Scheduler (src/runtime/rt_task.c)
• Context Management (src/runtime/rt_context.c)
• Function Execution (src/runtime/rt_function.c)
• Error Handling (src/runtime/rt_error.c)
d. Standard Library
• Arithmetic Operations (src/standard/std_arithmetic.c)
• Bitwise Operations (src/standard/std_bitwise.c)
• Timer Functions (src/standard/std_timers.c)
• String Operations (src/standard/std_string.c)
e. Hardware Interface
• PiFace Digital I/O (src/hardware/piface.c)
• Hardware Abstraction Layer
Data Flow
Key interactions:
a. Compilation Phase:
• Source code → Lexer → Parser → AST → Bytecode
• Symbol table interactions
• Configuration file processing
b. Runtime Phase:
• Bytecode loading
• Task scheduling
• Function execution
• Hardware I/O operations
External Dependencies
Integration points for:
• libev (Event loop)
• libconfig (Configuration processing)
• protobuf-c (Data serialization)
• Hardware drivers