Repository Map¶
Why the repository structure deserves its own page¶
When people first enter a compiler repository, they usually hit two questions immediately:
- which file should I read first?
- which directories are core implementation and which are support material?
This page is meant to answer that.
How to read the top-level structure¶
The most important parts of the repository are:
src/c_core_compiler/tests/examples/docs-site/- several top-level documentation files
You can think of them as four categories:
- compiler implementation
- validation and testing
- example programs
- project documentation
src/c_core_compiler/ is the real implementation core¶
This is where the compiler itself lives.
If you map it by compilation stage, the key files include:
tokens.py: token definitionslexer.py: lexical analysisast_nodes.py: AST node definitionsparser.py: parsingsymbol_table.py: symbol tablesemantic.py: semantic analysisir.py: IR structuresir_builder.py: AST-to-IR loweringoptimizer.py: conservative optimizationcodegen/: backend code generationtoolchain.py: system toolchain invocationpipeline.py: shared compilation pipelinecli.py: command-line entry point
If you only want the main path first, prioritize:
pipeline.pycli.pylexer.pyparser.pysemantic.pyir_builder.pycodegen/_portable_c.py
tests/ tells you what the project considers stable behavior¶
If you want to know which behaviors the project explicitly tries to preserve, the test directory is often more direct than the README.
It roughly covers:
- lexing tests
- parsing and AST tests
- semantic tests
- IR tests
- backend tests
- CLI tests
- end-to-end tests
When reading tests, look not only at whether they pass, but at what they imply the project considers part of the stable contract.
examples/ are the most direct input samples¶
This directory contains example C programs.
They are useful for:
- minimal CLI inputs
- end-to-end demonstrations
- understanding the actual supported language subset
If you are unsure whether a feature is supported, looking here is usually faster than guessing from memory.
docs-site/ is the documentation project¶
This is the MkDocs documentation site directory. It contains:
- documentation pages
- site configuration
- dependency definitions
- documentation PRDs
It is intentionally separated from the compiler implementation so the docs system can be maintained independently.
What the top-level documentation files do¶
At the repository root, there are several explanation files, such as:
README.md/README_CN.mdARCHITECTURE.mdTESTING.mdDEVELOPMENT.mdRELEASE.mdPRD.md
One useful way to think about them is:
README*: public entry pointARCHITECTURE.md: short architecture summaryTESTING.md: short testing strategy summaryDEVELOPMENT.md: development notesRELEASE.md: release notesPRD.md: project goals and requirements context
A good first-pass reading order¶
It is usually better not to start by randomly opening files.
A more reliable order is:
- start with
README.mdorREADME_CN.md - read the high-level docs under
docs-site/ - inspect
pipeline.py - then read
lexer -> parser -> semantic -> ir_builder -> backend - finally circle back to the tests
That order makes it much easier not to get lost.