How tap-lang/tap works
tap is a C-implemented, LLVM-backed programming language. Its primary workflow is source input through lexing, parsing, module/prelude loading and language lowering, then LLVM code generation and output or execution. The repository also provides an imported Tap standard library and a C runtime for native programs. The main driver and README document the workflow and compiler modes; several standard-library connections reflect README capabilities because their implementations were not sampled.
Main entry points: main.c CLI driver · codegen.c LLVM codegen · parser.c Parser · prelude.tp Standard prelude
Components 20
Compiler front end
- CLI driver
src/main.c - Lexer
src/lexer.c - Parser
src/parser.c - AST model
src/ast.c - Module loader
src/module.c - Prelude loader
src/prelude.c
Language lowering
- Enum lowering
src/tagged.c - Generic specialization
src/generics.c
Code generation and execution
- LLVM codegen
src/codegen.c - Native and lli runner
src/run.c
Runtime and libraries
- C runtime
runtime/src/runtime.c - Runtime ABI
runtime/include/tap_runtime.h - Standard prelude
std/prelude.tp - Math library
std/math.tp - Standard modules
std
Other components
- Program author
- Tap source
- LLVM
- IR, object, executable
- Compiled Tap program
Connections 22
- Program author → Tap source: writes
README.md - Tap source → CLI driver: submits
README.md - CLI driver → Lexer: creates lexer
src/main.c - Lexer → Parser: provides tokens
src/parser.c - CLI driver → Parser: creates parser
src/main.c - Parser → AST model: builds AST
src/parser.c - CLI driver → Module loader: loads imports
src/main.c - CLI driver → Prelude loader: loads prelude
src/main.c - CLI driver → Enum lowering: lowers enums
src/main.c - CLI driver → Generic specialization: specializes generics
src/main.c - CLI driver → LLVM codegen: generates code
src/main.c - LLVM codegen → LLVM: builds LLVM IR
README.md - CLI driver → Native and lli runner: selects execution
src/main.c - Native and lli runner → IR, object, executable: writes or runs
- LLVM codegen → IR, object, executable: emits IR or object
- IR, object, executable → Compiled Tap program: executes
README.md - C runtime → Runtime ABI: implements ABI
runtime/src/runtime.c - Standard prelude → Runtime ABI: uses runtime functions
- Math library → Standard modules: is imported as
README.md - Standard modules → Tap source: imported by
README.md - Standard prelude → Tap source: loaded automatically
README.md - Compiled Tap program → C runtime: uses runtime services