How khyeo1011/btw works
btw is a command-line language tool with check, run, build, assembly, token, parse, and language-server commands. The documented flow reads a source file, lexes and parses it, checks it, then either reports diagnostics, interprets it, or generates assembly for native linking. The README contains no capability details; the workflow and additional compiler stages below are supported by the CLI and driver excerpts. Parser, checker, interpreter, code generator, and LSP implementations were not included in the sampled source, so their paths are limited to the existing src/btw directory.
Main entry points: driver.py Compiler driver · cli.py Command CLI · lexer.py Lexer · diagnostics.py Diagnostic model
Components 19
CLI and language service
- Command CLI
src/btw/cli.py - Language server
src/btw - Compiler driver
src/btw/driver.py
Compiler frontend
- Lexer
src/btw/lexer.py - Tokens and comments
src/btw/tokens.py - AST model
src/btw/ast.py - Parser
src/btw
Checks and diagnostics
- Semantic checker
src/btw - Complexity checks
src/btw - Diagnostic suppression
src/btw - Diagnostic model
src/btw/diagnostics.py - Source positions
src/btw/span.py - Diagnostic output
src/btw/printing.py
Execution and output
- Interpreter
src/btw - Assembly generator
src/btw
Other components
- CLI user
- GCC linker
- Program output
- Error output
Connections 22
- CLI user → Command CLI: invokes
- Command CLI → Compiler driver: dispatches
src/btw/cli.py - Command CLI → Diagnostic output: prints diagnostics
src/btw/cli.py - Command CLI → Language server: starts server
src/btw/cli.py - Compiler driver → Language server: starts service
src/btw/driver.py - Compiler driver → Lexer: lexes source
src/btw/driver.py - Compiler driver → Parser: parses tokens
src/btw/driver.py - Compiler driver → Semantic checker: checks program
src/btw/driver.py - Compiler driver → Complexity checks: checks complexity
src/btw/driver.py - Compiler driver → Diagnostic suppression: applies suppression
src/btw/driver.py - Compiler driver → Interpreter: runs program
src/btw/driver.py - Compiler driver → Assembly generator: generates assembly
src/btw/driver.py - Compiler driver → GCC linker: links assembly
src/btw/driver.py - Compiler driver → Program output: passes output stream
src/btw/driver.py - Compiler driver → Error output: passes error stream
src/btw/driver.py - Lexer → Tokens and comments: emits tokens
src/btw/lexer.py - Lexer → Diagnostic model: emits diagnostics
src/btw/lexer.py - Lexer → Source positions: tracks positions
src/btw/lexer.py - AST model → Source positions: uses spans
src/btw/ast.py - AST model → Tokens and comments: types comments
src/btw/ast.py - Diagnostic model → Source positions: locates issues
src/btw/diagnostics.py - Diagnostic output → Diagnostic model: formats issues
src/btw/printing.py