# edgcpp/compiler architecture

> Architecture diagram of the GitHub repository edgcpp/compiler, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/edgcpp/compiler
- Repository: https://github.com/edgcpp/compiler

## Overview

EDG is primarily a configurable C/C++ compiler front end, with source-to-source back ends, template prelinking, IL utilities, a demangler, and a minimal C++ runtime. The principal workflow is source input through front-end analysis to generated C or C++; the prelinker and IL tools are additional product capabilities. The source excerpts mainly expose interfaces, so internal front-end call relationships are not asserted; documented capabilities are cited to the README.

Main entry points: [`src/cfe.c`](https://github.com/edgcpp/compiler/blob/main/src/cfe.c) (Front-End Driver), [`src/il.h`](https://github.com/edgcpp/compiler/blob/main/src/il.h) (Intermediate Language), [`util/edg_prelink.c`](https://github.com/edgcpp/compiler/blob/main/util/edg_prelink.c) (Template Prelinker), [`src/il_read.c`](https://github.com/edgcpp/compiler/blob/main/src/il_read.c) (IL Reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["C/C++ Front End"]
  node_frontend_entry["Front-End Driver<br/>[cfe.c]"]
  node_lexical["Lexical Analysis<br/>[lexical.c]"]
  node_preprocessor["Preprocessing<br/>[preproc.c]"]
  node_declarations["Declarations<br/>[decls.c]"]
  node_expressions["Expressions<br/>[expr.c]"]
  node_types_symbols["Types and Symbols<br/>[symbol_tbl.h]"]
  node_intermediate_language["Intermediate Language<br/>[il.h]"]
end

subgraph group_backend["Translation Back Ends"]
  node_c_backend["C Generator<br/>[c_gen_be.c]"]
  node_cpp_backend["C++ Generator<br/>[cp_gen_be.c]"]
end

subgraph group_utilities["Compiler Utilities"]
  node_prelinker["Template Prelinker<br/>[edg_prelink.c]"]
  node_il_write["IL Writer<br/>[il_write.c]"]
  node_il_read["IL Reader<br/>[il_read.c]"]
  node_il_display["IL Display<br/>[il_display.c]"]
  node_demangler["Name Demangler<br/>[decode.c]"]
end

subgraph group_runtime["Runtime Support"]
  node_runtime["C++ Runtime<br/>[runtime.h]"]
end

node_source_author(("Source Author"))

node_source_author -->|"compiles source"| node_frontend_entry
node_frontend_entry -->|"can generate C"| node_c_backend
node_frontend_entry -->|"can generate C++"| node_cpp_backend
node_prelinker -->|"handles instantiation"| node_frontend_entry
node_intermediate_language -->|"can be serialized"| node_il_write
node_il_read -->|"reconstructs"| node_intermediate_language
node_il_display -->|"displays"| node_intermediate_language

click node_frontend_entry "https://github.com/edgcpp/compiler/blob/main/src/cfe.c"
click node_lexical "https://github.com/edgcpp/compiler/blob/main/src/lexical.c"
click node_preprocessor "https://github.com/edgcpp/compiler/blob/main/src/preproc.c"
click node_declarations "https://github.com/edgcpp/compiler/blob/main/src/decls.c"
click node_expressions "https://github.com/edgcpp/compiler/blob/main/src/expr.c"
click node_types_symbols "https://github.com/edgcpp/compiler/blob/main/src/symbol_tbl.h"
click node_intermediate_language "https://github.com/edgcpp/compiler/blob/main/src/il.h"
click node_c_backend "https://github.com/edgcpp/compiler/blob/main/src/c_gen_be.c"
click node_cpp_backend "https://github.com/edgcpp/compiler/blob/main/src/cp_gen_be.c"
click node_prelinker "https://github.com/edgcpp/compiler/blob/main/util/edg_prelink.c"
click node_il_write "https://github.com/edgcpp/compiler/blob/main/src/il_write.c"
click node_il_read "https://github.com/edgcpp/compiler/blob/main/src/il_read.c"
click node_il_display "https://github.com/edgcpp/compiler/blob/main/src/il_display.c"
click node_demangler "https://github.com/edgcpp/compiler/blob/main/util/decode.c"
click node_runtime "https://github.com/edgcpp/compiler/blob/main/lib_src/runtime.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_entry,node_lexical,node_preprocessor,node_declarations,node_expressions,node_types_symbols,node_intermediate_language toneBlue
class node_c_backend,node_cpp_backend toneAmber
class node_prelinker,node_il_write,node_il_read,node_il_display,node_demangler toneMint
class node_runtime toneRose
class node_source_author toneIndigo
```

## Components

### C/C++ Front End

- [Front-End Driver](https://github.com/edgcpp/compiler/blob/main/src/cfe.c): `src/cfe.c`
- [Lexical Analysis](https://github.com/edgcpp/compiler/blob/main/src/lexical.c): `src/lexical.c`
- [Preprocessing](https://github.com/edgcpp/compiler/blob/main/src/preproc.c): `src/preproc.c`
- [Declarations](https://github.com/edgcpp/compiler/blob/main/src/decls.c): `src/decls.c`
- [Expressions](https://github.com/edgcpp/compiler/blob/main/src/expr.c): `src/expr.c`
- [Types and Symbols](https://github.com/edgcpp/compiler/blob/main/src/symbol_tbl.h): `src/symbol_tbl.h`
- [Intermediate Language](https://github.com/edgcpp/compiler/blob/main/src/il.h): `src/il.h`

### Translation Back Ends

- [C Generator](https://github.com/edgcpp/compiler/blob/main/src/c_gen_be.c): `src/c_gen_be.c`
- [C++ Generator](https://github.com/edgcpp/compiler/blob/main/src/cp_gen_be.c): `src/cp_gen_be.c`

### Compiler Utilities

- [Template Prelinker](https://github.com/edgcpp/compiler/blob/main/util/edg_prelink.c): `util/edg_prelink.c`
- [IL Writer](https://github.com/edgcpp/compiler/blob/main/src/il_write.c): `src/il_write.c`
- [IL Reader](https://github.com/edgcpp/compiler/blob/main/src/il_read.c): `src/il_read.c`
- [IL Display](https://github.com/edgcpp/compiler/blob/main/src/il_display.c): `src/il_display.c`
- [Name Demangler](https://github.com/edgcpp/compiler/blob/main/util/decode.c): `util/decode.c`

### Runtime Support

- [C++ Runtime](https://github.com/edgcpp/compiler/blob/main/lib_src/runtime.h): `lib_src/runtime.h`

### Other components

- **Source Author**

## Connections

- Source Author → Front-End Driver: compiles source (evidence: `README.md`)
- Front-End Driver → C Generator: can generate C (evidence: `README.md`)
- Front-End Driver → C++ Generator: can generate C++ (evidence: `README.md`)
- Template Prelinker → Front-End Driver: handles instantiation (evidence: `README.md`)
- Intermediate Language → IL Writer: can be serialized (evidence: `README.md`)
- IL Reader → Intermediate Language: reconstructs (evidence: `README.md`)
- IL Display → Intermediate Language: displays (evidence: `README.md`)
