# misakana/cse340_project03 architecture

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

- Interactive diagram: https://gitdiagram.com/misakana/cse340_project03
- Repository: https://github.com/misakana/cse340_project03

## Overview

This repository implements a small compiler/interpreter for a structured language: it tokenizes source from standard input, parses statements into an instruction representation, then executes that representation. The main product flow is documented in compiler.h and visible in compiler.cc; demo.cc contains the parser and lexer.cc handles tokenization. The README is empty, so capabilities are inferred from the sampled source. The parser excerpt is partial, limiting detail about some grammar branches.

Main entry points: [`compiler.cc`](https://github.com/misakana/cse340_project03/blob/master/compiler.cc) (Instruction Executor), [`demo.cc`](https://github.com/misakana/cse340_project03/blob/master/demo.cc) (Parser and IR Builder), [`inputbuf.cc`](https://github.com/misakana/cse340_project03/blob/master/inputbuf.cc) (Character Buffer), [`lexer.cc`](https://github.com/misakana/cse340_project03/blob/master/lexer.cc) (Lexer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front_end["Front End"]
  node_parser["Parser and IR Builder<br/>[demo.cc]"]
  node_lexer["Lexer<br/>[lexer.cc]"]
  node_ir["Instruction Representation<br/>[compiler.h]"]
end

subgraph group_runtime["Interpreter Runtime"]
  node_executor["Instruction Executor<br/>[compiler.cc]"]
  node_memory[("Runtime Memory<br/>[compiler.cc]")]
end

subgraph group_input["Input Handling"]
  node_inputbuf["Character Buffer<br/>[inputbuf.cc]"]
end

node_source(("Program Source"))

node_source -->|"provides characters"| node_inputbuf
node_inputbuf -->|"supplies characters"| node_lexer
node_parser -->|"requests tokens"| node_lexer
node_parser -->|"builds instructions"| node_ir
node_executor -->|"invokes parser"| node_parser
node_executor -->|"executes instructions"| node_ir
node_executor -->|"reads and writes"| node_memory

click node_parser "https://github.com/misakana/cse340_project03/blob/master/demo.cc"
click node_lexer "https://github.com/misakana/cse340_project03/blob/master/lexer.cc"
click node_ir "https://github.com/misakana/cse340_project03/blob/master/compiler.h"
click node_executor "https://github.com/misakana/cse340_project03/blob/master/compiler.cc"
click node_memory "https://github.com/misakana/cse340_project03/blob/master/compiler.cc"
click node_inputbuf "https://github.com/misakana/cse340_project03/blob/master/inputbuf.cc"

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_parser,node_lexer,node_ir toneBlue
class node_executor,node_memory toneAmber
class node_inputbuf toneMint
class node_source toneIndigo
```

## Components

### Front End

- [Parser and IR Builder](https://github.com/misakana/cse340_project03/blob/master/demo.cc): `demo.cc`
- [Lexer](https://github.com/misakana/cse340_project03/blob/master/lexer.cc): `lexer.cc`
- [Instruction Representation](https://github.com/misakana/cse340_project03/blob/master/compiler.h): `compiler.h`

### Interpreter Runtime

- [Instruction Executor](https://github.com/misakana/cse340_project03/blob/master/compiler.cc): `compiler.cc`
- [Runtime Memory](https://github.com/misakana/cse340_project03/blob/master/compiler.cc): `compiler.cc`

### Input Handling

- [Character Buffer](https://github.com/misakana/cse340_project03/blob/master/inputbuf.cc): `inputbuf.cc`

### Other components

- **Program Source**

## Connections

- Program Source → Character Buffer: provides characters (evidence: `inputbuf.cc`)
- Character Buffer → Lexer: supplies characters (evidence: `lexer.cc`)
- Parser and IR Builder → Lexer: requests tokens (evidence: `demo.cc`)
- Parser and IR Builder → Instruction Representation: builds instructions (evidence: `demo.cc`)
- Instruction Executor → Parser and IR Builder: invokes parser (evidence: `compiler.cc`)
- Instruction Executor → Instruction Representation: executes instructions (evidence: `compiler.cc`)
- Instruction Executor → Runtime Memory: reads and writes (evidence: `compiler.cc`)
