# mohitmishra786/compiler architecture

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

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

## Overview

EDG is a configurable C/C++ compiler front end, accompanied by code-generating back ends, template prelinking, IL utilities, a demangler, and a minimal runtime. The principal workflow takes source through front-end analysis and intermediate representation (IL) to generated C or C++. README-level evidence establishes the product capabilities; sampled source also shows pragma processing and IL structures, but does not expose the complete compiler call graph, so internal arrows are limited to documented relationships.

Main entry points: [`src/il_def.h`](https://github.com/mohitmishra786/compiler/blob/main/src/il_def.h) (Intermediate Language), [`src/lexical.c`](https://github.com/mohitmishra786/compiler/blob/main/src/lexical.c) (Lexing and Preprocessing), [`src/decls.c`](https://github.com/mohitmishra786/compiler/blob/main/src/decls.c) (Declarations and Semantics), [`src/expr.c`](https://github.com/mohitmishra786/compiler/blob/main/src/expr.c) (Expressions and Statements)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Compiler Front End"]
  node_lexing["Lexing and Preprocessing<br/>[lexical.c]"]
  node_declarations["Declarations and Semantics<br/>[decls.c]"]
  node_expressions["Expressions and Statements<br/>[expr.c]"]
  node_pragmas["Pragma Processing<br/>[pragma.c]"]
  node_symbols["Symbols and Scope<br/>[symbol_tbl.h]"]
  node_target["Target Configuration<br/>[target.h]"]
end

subgraph group_representation["Intermediate Representation"]
  node_il["Intermediate Language<br/>[il_def.h]"]
  node_il_tools["IL Read and Display<br/>[il_read.c]"]
end

subgraph group_outputs["Code Generation"]
  node_c_backend["C Code Generator<br/>[c_gen_be.c]"]
  node_cpp_backend["C++ Code Generator<br/>[cp_gen_be.c]"]
end

subgraph group_support["Compiler Support"]
  node_prelinker["Template Prelinker<br/>[edg_prelink.c]"]
  node_demangler["Name Demangler<br/>[decode.c]"]
  node_runtime["Minimal Runtime<br/>[runtime.h]"]
end

node_developer(("Source Author"))
node_compiler_user(("Compiler User"))
node_generated_c["Generated C or C++"]

node_developer -->|"provides source"| node_lexing
node_lexing -->|"front-end analysis"| node_declarations
node_declarations -->|"analyzes constructs"| node_expressions
node_expressions -->|"represents program"| node_il
node_pragmas -->|"records pragma data"| node_il
node_symbols -.->|"supports semantic representation"| node_il
node_target -.->|"configures front end"| node_il
node_il -->|"generates C"| node_c_backend
node_il -->|"generates C++"| node_cpp_backend
node_il -->|"writes and reads"| node_il_tools
node_compiler_user -->|"uses template instantiation"| node_prelinker
node_compiler_user -->|"uses name demangling"| node_demangler
node_c_backend -->|"emits C"| node_generated_c
node_cpp_backend -->|"emits C++"| node_generated_c
node_generated_c -.->|"may require support"| node_runtime

click node_lexing "https://github.com/mohitmishra786/compiler/blob/main/src/lexical.c"
click node_declarations "https://github.com/mohitmishra786/compiler/blob/main/src/decls.c"
click node_expressions "https://github.com/mohitmishra786/compiler/blob/main/src/expr.c"
click node_pragmas "https://github.com/mohitmishra786/compiler/blob/main/src/pragma.c"
click node_symbols "https://github.com/mohitmishra786/compiler/blob/main/src/symbol_tbl.h"
click node_target "https://github.com/mohitmishra786/compiler/blob/main/src/target.h"
click node_il "https://github.com/mohitmishra786/compiler/blob/main/src/il_def.h"
click node_il_tools "https://github.com/mohitmishra786/compiler/blob/main/src/il_read.c"
click node_c_backend "https://github.com/mohitmishra786/compiler/blob/main/src/c_gen_be.c"
click node_cpp_backend "https://github.com/mohitmishra786/compiler/blob/main/src/cp_gen_be.c"
click node_prelinker "https://github.com/mohitmishra786/compiler/blob/main/util/edg_prelink.c"
click node_demangler "https://github.com/mohitmishra786/compiler/blob/main/util/decode.c"
click node_runtime "https://github.com/mohitmishra786/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_lexing,node_declarations,node_expressions,node_pragmas,node_symbols,node_target,node_compiler_user toneBlue
class node_il,node_il_tools toneAmber
class node_c_backend,node_cpp_backend toneMint
class node_prelinker,node_demangler,node_runtime toneRose
class node_developer,node_generated_c toneIndigo
```

## Components

### Compiler Front End

- [Lexing and Preprocessing](https://github.com/mohitmishra786/compiler/blob/main/src/lexical.c): `src/lexical.c`
- [Declarations and Semantics](https://github.com/mohitmishra786/compiler/blob/main/src/decls.c): `src/decls.c`
- [Expressions and Statements](https://github.com/mohitmishra786/compiler/blob/main/src/expr.c): `src/expr.c`
- [Pragma Processing](https://github.com/mohitmishra786/compiler/blob/main/src/pragma.c): `src/pragma.c`
- [Symbols and Scope](https://github.com/mohitmishra786/compiler/blob/main/src/symbol_tbl.h): `src/symbol_tbl.h`
- [Target Configuration](https://github.com/mohitmishra786/compiler/blob/main/src/target.h): `src/target.h`

### Intermediate Representation

- [Intermediate Language](https://github.com/mohitmishra786/compiler/blob/main/src/il_def.h): `src/il_def.h`
- [IL Read and Display](https://github.com/mohitmishra786/compiler/blob/main/src/il_read.c): `src/il_read.c`

### Code Generation

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

### Compiler Support

- [Template Prelinker](https://github.com/mohitmishra786/compiler/blob/main/util/edg_prelink.c): `util/edg_prelink.c`
- [Name Demangler](https://github.com/mohitmishra786/compiler/blob/main/util/decode.c): `util/decode.c`
- [Minimal Runtime](https://github.com/mohitmishra786/compiler/blob/main/lib_src/runtime.h): `lib_src/runtime.h`

### Other components

- **Source Author**
- **Compiler User**
- **Generated C or C++**

## Connections

- Source Author → Lexing and Preprocessing: provides source (evidence: `README.md`)
- Lexing and Preprocessing → Declarations and Semantics: front-end analysis (evidence: `README.md`)
- Declarations and Semantics → Expressions and Statements: analyzes constructs (evidence: `README.md`)
- Expressions and Statements → Intermediate Language: represents program (evidence: `README.md`)
- Pragma Processing → Intermediate Language: records pragma data (evidence: `src/pragma.c`)
- Symbols and Scope → Intermediate Language: supports semantic representation
- Target Configuration → Intermediate Language: configures front end
- Intermediate Language → C Code Generator: generates C (evidence: `README.md`)
- Intermediate Language → C++ Code Generator: generates C++ (evidence: `README.md`)
- Intermediate Language → IL Read and Display: writes and reads (evidence: `README.md`)
- Compiler User → Template Prelinker: uses template instantiation (evidence: `README.md`)
- Compiler User → Name Demangler: uses name demangling (evidence: `README.md`)
- C Code Generator → Generated C or C++: emits C (evidence: `README.md`)
- C++ Code Generator → Generated C or C++: emits C++ (evidence: `README.md`)
- Generated C or C++ → Minimal Runtime: may require support
