How nathan4044/c-lisp-interpreter works
Key Components to Include:
Scanner/Lexer Component (scanner.c/h)
• First stage of interpretation
• Converts source text into tokens
• Should be represented as the entry point
Compiler Component (compiler.c/h)
• Transforms tokens into bytecode
• Works with chunks of code
• Interfaces with memory management
Virtual Machine (vm.c/h)
• Core execution engine
• Interprets the bytecode
• Manages runtime environment
Memory Management System (memory.c/h)
• Handles allocation and garbage collection
• Supports both the compiler and VM
Object System (object.c/h)
• Represents Lisp data types
• Manages runtime objects
Value System (value.c/h)
• Handles different value types
• Works closely with the object system
Hash Table Implementation (table.c/h)
• Supports symbol tables and environment
Native Functions (nativeFns.c/h)
• Built-in function implementation
• Extends VM functionality
Supporting systems as parallel components
• Memory Manager (connected to all major components)
• Object System (connected to VM and Compiler)
• Hash Tables (connected to VM and Compiler)
• Native Functions (connected to VM)
• Blue: Core pipeline components (Scanner, Compiler, VM)
• Green: Memory management and storage (Memory Manager, Hash Tables)
• Yellow: Data representation (Object System, Value System)
• Purple: Runtime support (Native Functions)
Relationships to Show:
• Source text → Scanner → Tokens → Compiler → Bytecode → VM → Execution
• Memory Manager ↔ All Components
• Object System ↔ VM
• Object System ↔ Compiler
• Hash Tables ↔ VM
• Native Functions → VM
Additional Elements:
Debug System (debug.c/h)
• As a cross-cutting concern
Chunk System (chunk.c/h)
• As part of the compiler output
• Represents the bytecode container
Brief notes describing key interactions
Level of Detail:
• Keep component internals abstract
• Inter-component communication
• LISP-specific features
• Memory management interaction points
The relationship between objects and values
This design reflects a traditional interpreter architecture while highlighting the specific requirements of a Lisp implementation, such as symbol management and garbage collection.