Skip to content

Source status: no status is stated in the source document, so none is assigned here. Do not treat this page as a finalized specification. The normative rules are in the Technical Specification.

Compiler Architecture

The compiler will process source code through a sequence of independent stages. Each stage will validate specific properties before allowing compilation to continue.

1. Lexical Analysis

  • Convert source text into tokens.
  • Identify invalid characters and malformed tokens.

2. Parsing

  • Convert tokens into a structured representation of the program.
  • Enforce grammatical rules.
  • Reject malformed declarations and expressions.

3. Semantic Analysis

  • Validate types, function signatures, scopes, and module references.
  • Check that declarations are internally consistent.

4. Contract Verification

  • Validate preconditions, postconditions, and invariants.
  • Check whether implementations satisfy declared guarantees.
  • Identify properties that cannot be proven.

5. Effect and Permission Analysis

  • Check declared side effects.
  • Enforce permission boundaries.
  • Reject unauthorized operations.

6. Safety Analysis

  • Check ownership, resource lifetimes, concurrency rules, and security constraints.
  • Identify unsafe operations.

7. Intermediate Representation

  • Convert validated code into a standardized internal representation.
  • Preserve contracts, types, permissions, and verification metadata.

8. Code Generation

  • Translate the intermediate representation into executable machine code or a supported compilation target.

9. Verification Report

  • Produce a structured report describing successful checks, failures, and unverified properties.
  • Preserve evidence of which requirements were checked.

Compiler Rule

A failed mandatory check must prevent the affected program from being accepted as a valid build.

Unverified properties must remain explicitly identified and must never be reported as proven.

Design Goal

The compiler must act as an enforcement system, not merely a translator from source code into machine instructions.


Source and authority

This page migrates COMPILER.md in full. It is an explanatory / implementation document, not the normative specification. Where it simplifies a rule, the Technical Specification governs. The original file is preserved in source-original/LANG/.