# radimir007/ifj_compiler_2026 architecture

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

- Interactive diagram: https://gitdiagram.com/radimir007/ifj_compiler_2026
- Repository: https://github.com/radimir007/ifj_compiler_2026

## Overview

IFJ2026 is a compiler that reads source from standard input and emits IFJcode26 to standard output. Its main workflow is scanning tokens, parsing declarations and expressions into an AST, semantic analysis, then code generation. The graph also shows the symbol-table layer used for semantic state. The README provides no capability detail; scanner, parser, semantic, and code-generation behavior is based on the supplied source excerpts and index, so unsampled internal calls are omitted where not established.

Main entry points: [`src/main.c`](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/main.c) (Compiler driver), [`src/parser.c`](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/parser.c) (Syntax parser), [`src/scanner.c`](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/scanner.c) (Scanner), [`src/expr_parser.c`](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/expr_parser.c) (Expression parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Compiler entry"]
  node_main["Compiler driver<br/>[main.c]"]
end

subgraph group_front["Front end"]
  node_scanner["Scanner<br/>[scanner.c]"]
  node_tokens["Token model<br/>[token.h]"]
  node_parser["Syntax parser<br/>[parser.c]"]
  node_expr["Expression parser<br/>[expr_parser.c]"]
  node_ast["AST<br/>[ast.c]"]
end

subgraph group_sem["Semantic analysis"]
  node_semantic["Semantic analyzer<br/>[semantic.c]"]
  node_symtable[("Symbol tables<br/>[symtable.c]")]
end

subgraph group_backend["Code generation"]
  node_codegen["IFJcode26 generator<br/>[codegen.c]"]
end

node_source(("Source input"))
node_output["Generated code"]

node_source -->|"reads stdin"| node_main
node_main -->|"initializes"| node_scanner
node_parser -->|"fetches tokens"| node_scanner
node_scanner -->|"produces"| node_tokens
node_parser -->|"parses expressions"| node_expr
node_parser -->|"constructs"| node_ast
node_expr -->|"constructs"| node_ast
node_main -->|"parses source"| node_parser
node_main -->|"analyzes AST"| node_semantic
node_semantic -->|"uses scopes"| node_symtable
node_main -->|"generates code"| node_codegen
node_codegen -->|"writes code"| node_output

click node_main "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/main.c"
click node_scanner "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/scanner.c"
click node_tokens "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/token.h"
click node_parser "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/parser.c"
click node_expr "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/expr_parser.c"
click node_ast "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/ast.c"
click node_semantic "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/semantic.c"
click node_symtable "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/symtable.c"
click node_codegen "https://github.com/radimir007/ifj_compiler_2026/blob/main/src/codegen.c"

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_main toneBlue
class node_scanner,node_tokens,node_parser,node_expr,node_ast toneAmber
class node_semantic,node_symtable toneMint
class node_codegen toneRose
class node_source,node_output toneIndigo
```

## Components

### Compiler entry

- [Compiler driver](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/main.c): `src/main.c`

### Front end

- [Scanner](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/scanner.c): `src/scanner.c`
- [Token model](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/token.h): `src/token.h`
- [Syntax parser](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/parser.c): `src/parser.c`
- [Expression parser](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/expr_parser.c): `src/expr_parser.c`
- [AST](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/ast.c): `src/ast.c`

### Semantic analysis

- [Semantic analyzer](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/semantic.c): `src/semantic.c`
- [Symbol tables](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/symtable.c): `src/symtable.c`

### Code generation

- [IFJcode26 generator](https://github.com/radimir007/ifj_compiler_2026/blob/main/src/codegen.c): `src/codegen.c`

### Other components

- **Source input**
- **Generated code**

## Connections

- Source input → Compiler driver: reads stdin (evidence: `src/main.c`)
- Compiler driver → Scanner: initializes (evidence: `src/main.c`)
- Syntax parser → Scanner: fetches tokens (evidence: `src/parser.c`)
- Scanner → Token model: produces
- Syntax parser → Expression parser: parses expressions (evidence: `src/parser.c`)
- Syntax parser → AST: constructs (evidence: `src/parser.c`)
- Expression parser → AST: constructs
- Compiler driver → Syntax parser: parses source (evidence: `src/main.c`)
- Compiler driver → Semantic analyzer: analyzes AST (evidence: `src/main.c`)
- Semantic analyzer → Symbol tables: uses scopes
- Compiler driver → IFJcode26 generator: generates code (evidence: `src/main.c`)
- IFJcode26 generator → Generated code: writes code
