How h2oprooftoaster/bencth works
Bencthc is a small C compiler that accepts a source-file path and emits x86-64 assembly. The visible driver reads and displays the input, then invokes lexing, parsing, and code generation, freeing their arenas afterward. The parser builds translation-unit structures and uses symbol tables; code generation writes assembly. A semantic analyzer and assembly syscall/runtime support are present in the tree, but their connections to the driver are not established by the excerpts. The README is empty, so capability coverage is limited to the source evidence provided.
Main entry points: main.c Compiler driver · parser.c Parser · codeGenerator.c Code generator · file.c File utilities
Components 15
Compiler frontend
- Compiler driver
bencthc/src/main.c - Lexer
bencthc/src/lexer.c - Parser
bencthc/src/parser.c - Grammar structures
bencthc/src/structs.h - Symbol tables
bencthc/src/utils/symbols.c - Semantic analyzer
bencthc/src/semanticAnalyzer.c
Assembly backend
- Code generator
bencthc/src/codeGenerator.c
Runtime support
- File utilities
bencthc/src/utils/file.c - Arena allocator
bencthc/src/utils/allocator.c - String utilities
bencthc/src/utils/string.c - Linux syscalls
bencthc/src/utils/syscalls/syscall.h - Assembly runtime
bencthc/runtime/b_crt.s
Other components
- Compiler user
- Input source
- Assembly output
Connections 15
- Compiler user → Compiler driver: runs
bencthc/src/main.c - Compiler user → Input source: provides
- Compiler driver → File utilities: reads input
bencthc/src/main.c - Compiler driver → Lexer: lexes
bencthc/src/main.c - Compiler driver → Parser: parses
bencthc/src/main.c - Compiler driver → Code generator: generates assembly
bencthc/src/main.c - Compiler driver → Assembly output: writes
- Parser → Symbol tables: uses
bencthc/src/parser.c - Parser → Grammar structures: builds
bencthc/src/parser.c - Code generator → File utilities: writes output
bencthc/src/codeGenerator.c - Code generator → Symbol tables: looks up
bencthc/src/codeGenerator.c - Semantic analyzer → Grammar structures: analyzes
bencthc/src/semanticAnalyzer.c - File utilities → Linux syscalls: uses
bencthc/src/utils/file.c - Arena allocator → Linux syscalls: allocates via
bencthc/src/utils/allocator.c - Assembly runtime → Linux syscalls: wraps