# jigeesharane/mycompiler architecture

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

- Interactive diagram: https://gitdiagram.com/jigeesharane/mycompiler
- Repository: https://github.com/jigeesharane/mycompiler

## Overview

MyCompiler is a small C interpreter for a language with variables, arithmetic, printing, conditionals, and loops. A user supplies source on standard input; the lexer produces tokens, the parser builds an AST, and parser actions print and interpret it. The interpreter evaluates expressions and statements, maintaining variable values and sending program output to standard output. The README documents the language capabilities; the sampled parser excerpt confirms the AST-print and evaluation calls, while lexer and grammar internals were not sampled.

Main entry points: [`src/parser.y`](https://github.com/jigeesharane/mycompiler/blob/main/src/parser.y) (Parser), [`src/interpreter.c`](https://github.com/jigeesharane/mycompiler/blob/main/src/interpreter.c) (Evaluator), [`src/lexer.l`](https://github.com/jigeesharane/mycompiler/blob/main/src/lexer.l) (Lexer), [`src/ast.c`](https://github.com/jigeesharane/mycompiler/blob/main/src/ast.c) (AST printer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Language Front End"]
  node_lexer["Lexer<br/>[lexer.l]"]
  node_parser["Parser<br/>[parser.y]"]
end

subgraph group_ast["AST"]
  node_astnodes["AST nodes<br/>[ast.c]"]
  node_astprinter["AST printer<br/>[ast.c]"]
end

subgraph group_runtime["Interpreter Runtime"]
  node_evaluator["Evaluator<br/>[interpreter.c]"]
  node_variables[("Variable table<br/>[interpreter.c]")]
end

node_user(("Program author"))
node_stdout(("Standard output"))

node_user -->|"provides source"| node_lexer
node_lexer -->|"returns tokens"| node_parser
node_parser -->|"builds AST"| node_astnodes
node_parser -->|"calls printAST"| node_astprinter
node_parser -->|"calls evaluate"| node_evaluator
node_evaluator -->|"reads and writes"| node_variables
node_astprinter -->|"prints AST"| node_stdout
node_evaluator -->|"prints results"| node_stdout

click node_lexer "https://github.com/jigeesharane/mycompiler/blob/main/src/lexer.l"
click node_parser "https://github.com/jigeesharane/mycompiler/blob/main/src/parser.y"
click node_astnodes "https://github.com/jigeesharane/mycompiler/blob/main/src/ast.c"
click node_astprinter "https://github.com/jigeesharane/mycompiler/blob/main/src/ast.c"
click node_evaluator "https://github.com/jigeesharane/mycompiler/blob/main/src/interpreter.c"
click node_variables "https://github.com/jigeesharane/mycompiler/blob/main/src/interpreter.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_lexer,node_parser toneBlue
class node_astnodes,node_astprinter toneAmber
class node_evaluator,node_variables toneMint
class node_user,node_stdout toneIndigo
```

## Components

### Language Front End

- [Lexer](https://github.com/jigeesharane/mycompiler/blob/main/src/lexer.l): `src/lexer.l`
- [Parser](https://github.com/jigeesharane/mycompiler/blob/main/src/parser.y): `src/parser.y`

### AST

- [AST nodes](https://github.com/jigeesharane/mycompiler/blob/main/src/ast.c): `src/ast.c`
- [AST printer](https://github.com/jigeesharane/mycompiler/blob/main/src/ast.c): `src/ast.c`

### Interpreter Runtime

- [Evaluator](https://github.com/jigeesharane/mycompiler/blob/main/src/interpreter.c): `src/interpreter.c`
- [Variable table](https://github.com/jigeesharane/mycompiler/blob/main/src/interpreter.c): `src/interpreter.c`

### Other components

- **Program author**
- **Standard output**

## Connections

- Program author → Lexer: provides source
- Lexer → Parser: returns tokens
- Parser → AST nodes: builds AST
- Parser → AST printer: calls printAST
- Parser → Evaluator: calls evaluate
- Evaluator → Variable table: reads and writes
- AST printer → Standard output: prints AST
- Evaluator → Standard output: prints results
