How coldchip/chip works
Chip is a compiled and interpreted programming language. In the compile workflow, a user invokes the CLI on source code; Chip tokenizes and parses it, checks semantics, generates bytecode, and optimizes the generated instructions. In the run workflow, the interpreter loads bytecode and executes it, including system calls and managed object collection. Type and variable-scope modules support semantic checking. The README documents the compiler stages; implementation excerpts show CLI dispatch and interpreter behavior, but not the full optimizer or library wiring.
Main entry points: main.c CLI Dispatch · intepreter.c Bytecode Interpreter · semantic.c Semantic Analyzer · parse.c Recursive Parser
Components 16
Source Front End
- CLI Dispatch
src/main.c - Tokenizer
src/tokenize.c - Recursive Parser
src/parse.c - Expression Parser
src/parse_expr.c
Semantic Analysis
- Semantic Analyzer
src/semantic.c - Type System
src/type.c - Variable Scopes
src/varscope.c
Bytecode Compiler
- Code Generator
src/codegen.c - Bytecode Optimizer
src/optimize.c - Bytecode File
Execution Runtime
- Bytecode Interpreter
src/intepreter.c - Object Collector
src/intepreter.c - Host System Calls
- Chip Libraries
libchip
Other components
- User
- Chip Source
Connections 17
- User → CLI Dispatch: invokes
src/main.c - Chip Source → CLI Dispatch: provides source
src/main.c - CLI Dispatch → Tokenizer: tokenizes
src/main.c - Tokenizer → Recursive Parser: tokens
README.md - Recursive Parser → Expression Parser: parses expressions
- Recursive Parser → Semantic Analyzer: AST
- Semantic Analyzer → Type System: checks types
src/semantic.c - Semantic Analyzer → Variable Scopes: tracks variables
src/semantic.c - Semantic Analyzer → Code Generator: checked AST
- Code Generator → Bytecode Optimizer: optimizes instructions
src/codegen.c - Bytecode Optimizer → Bytecode File: emits bytecode
README.md - User → CLI Dispatch: selects run
src/main.c - CLI Dispatch → Bytecode Interpreter: dispatches run
src/main.c - Bytecode File → Bytecode Interpreter: loaded by
src/intepreter.c - Bytecode Interpreter → Object Collector: collects objects
src/intepreter.c - Bytecode Interpreter → Host System Calls: dispatches syscalls
src/intepreter.c - Chip Libraries → Bytecode Interpreter: uses runtime calls