How guille-ux/zynklite works
Project type and purpose
• Zynk Lite is a lightweight, embeddable scripting language implemented in Python (with a future C target).
• It provides both an interpreter and (in progress) a bytecode compiler.
File structure
• Top‐level:
• zynk-lite/ — the actual language implementation and packaging
• zynk-lite/src/zynk_lite/
• frontend/ (lexer.py)
• ast/ (parser.py, expressions.py, eval.py, zenv.py)
• bytecode/ (bytecode definitions)
• compiler.py
• interpreter.py
• cli.py (entry‐point)
• native_funcs/ (built‐in host functions)
• tokens.py, errors.py
• Configuration & build: pyproject.toml, build.sh, dist/
• Tests: zynk-lite/tests/
Key insights from the README
• Provides both CLI and Python API interfaces.
• Stages in roadmap: interpreter → bytecode compiler → C transpiler.
• Core features: lexer, parser, AST evaluator, native I/O, modular imports.
Main components & interactions
a. Components
1. CLI / Python API layer (cli.py, dev.py)
2. Frontend (lexer → parser)
3. AST module (expressions, eval, environment)
4. Interpreter engine (immediate AST execution)
5. Compiler engine (AST→bytecode)
6. Bytecode runner / VM (executes bytecode)
7. Native functions module (file I/O, sleep, arrays)
8. Host environment (Python runtime, OS file system)
9. Packaging & distribution (build scripts, wheel/tar.gz)
10. Test harness
b. Interactions & data flows
• User input or script file → CLI/Python API
• CLI invokes Frontend → produces AST
• Two parallel flows from AST:
• AST → Interpreter → Native functions → Host
• AST → Compiler → Bytecode → VM → Native functions → Host
• All flows return results to CLI or embedding Python program
• Packaging tools read src → produce distribution artifacts
• Tests invoke CLI/API and validate outputs
Architectural patterns & design principles
• Compiler pipeline: clear stages (lexing, parsing, AST generation, code generation, execution)
• Modular design: separate folders for each stage
• Embeddability: CLI and direct Python API share the same core modules
• Extensibility: native_funcs as plugin point for host operations
Technologies & frameworks
• Python 3.6+ (runtime for all components)
• Hatch/pyproject.toml for packaging
• Bash for install scripts (mimes)
• pytest or unittest (in tests/)