Skip to content

Documentation: Add architecture overview and phase documentation #148

Description

@clank-hayen

Problem

The Bishop compiler is well-organized into phases (lexer, parser, typechecker, codegen), but there's no high-level documentation explaining:

  1. How the phases interact
  2. Data flow between phases (what each phase produces/consumes)
  3. The role of mutable AST fields
  4. How module imports work through the pipeline
  5. The stdlib generation architecture

New contributors must read through multiple source files to understand the architecture.

Suggested Content

docs/ARCHITECTURE.md

# Bishop Compiler Architecture

## Compilation Phases

1. **Lexer** (src/lexer/)
   - Input: Source text
   - Output: Token stream
   - Handles: Keywords, literals, operators, comments

2. **Parser** (src/parser/)
   - Input: Token stream
   - Output: AST (untyped)
   - Handles: Syntax validation, AST construction

3. **Type Checker** (src/typechecker/)
   - Input: AST (untyped)
   - Output: AST (annotated with types via mutable fields)
   - Handles: Type inference, semantic validation

4. **Code Generator** (src/codegen/)
   - Input: Typed AST
   - Output: C++ source code
   - Handles: C++ emission, stdlib integration

## Data Flow Diagram
[ASCII art or Mermaid diagram]

## Key Abstractions
- ASTNode hierarchy
- TypeInfo struct
- Module system
...

Suggested Additional Docs

  1. CONTRIBUTING.md - How to add new language features
  2. docs/stdlib.md - How stdlib modules work
  3. docs/error-handling.md - Bishop's error model (fail/or)

Priority

High - This significantly reduces onboarding time for contributors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions