docs: document the source-to-binary compiler pipeline - #13
Draft
xodn348 wants to merge 1 commit into
Draft
Conversation
Add an end-to-end section to the README tracing 출력(1 + 2 * 3) through lexer, parser, type checker, and LLVM IR codegen, with a table of what each stage transforms and what it reports. Also spell out where Han's responsibility ends and LLVM's begins, and separate the two independent levels at which LLVM appears: rustc using it to build hgl, and hgl emitting IR for user programs. Those are routinely conflated. Update docs/src/internals/architecture.md to match the current tree. The pipeline diagram omitted the type checker entirely, and the module list still referenced interpreter.rs and codegen.rs, which are directories now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a How It Works: Source to Binary section to the README, tracing
출력(1 + 2 * 3)through every stage of the toolchain:source text → lexer → tokens → parser → AST → type checker → validated AST → codegen → LLVM IR → clang → binarywith a table of what each stage transforms and what it reports, and the interpreter branch shown alongside the compiled one.
Why
The README described the pipeline only in passing (
hgl build(LLVM IR → clang → binary)). Anyone evaluating the project had no single place showing the stage boundaries or where the type checker sits.The new Where LLVM fits subsection also separates two things that are routinely conflated:
cargo buildhands Han's Rust source torustc, which uses LLVM to produce thehglbinary.hgl buildhands the user's.hglsource through Han's own four stages into LLVM IR, and clang produces the user's binary.Same back end, two unrelated levels. LLVM is a code generation library, not a runtime.
Also
docs/src/internals/architecture.mdhad drifted from the tree:interpreter.rsandcodegen.rs, which are directories nowtypechecker.rsandbuiltins/were missingFixed, since the new README section links here and would otherwise contradict it.
Verification
Docs only, no code touched. Every path and module name in the new text was checked against the working tree, and every claim against source:
run_pipelineinsrc/main.rsconfirms lexer → parser → typechecker ordering and that both back ends share it;typechecker::checkreturningVec<TypeError>confirms type problems are collected rather than fatal;src/parser.rsconfirms precedence climbing;compile_to_binaryconfirms IR is written as text and passed toclang.🤖 Generated with Claude Code