# adrianmoser1/cmsc124-cardist architecture

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

- Interactive diagram: https://gitdiagram.com/adrianmoser1/cmsc124-cardist
- Repository: https://github.com/adrianmoser1/cmsc124-cardist

## Overview

Cardist is currently a small Go expression-language interpreter, not yet a card-game runtime: the README describes its intended game-rule domain, but the implemented workflow is scanning, parsing, and evaluating expressions. The CLI supports token and AST inspection, file evaluation, and a line-oriented REPL; a plain file argument still echoes the file. The graph shows the implemented runtime stages and output layers. Card-game keywords are recognized lexically, but sampled code does not establish game-specific execution. Edges reflect shown calls; the README also notes that plain execution is a placeholder.

Main entry points: [`main.go`](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/main.go) (CLI and orchestration), [`parser/parser.go`](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/parser/parser.go) (Expression parser), [`parser/ast_printer.go`](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/parser/ast_printer.go) (AST printer), [`evaluator/evaluator.go`](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/evaluator/evaluator.go) (Expression evaluator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_cli["CLI and orchestration<br/>[main.go]"]
  node_stdout(("Printed output"))
end

subgraph group_language["Language pipeline"]
  node_scanner["Scanner<br/>[scanner.go]"]
  node_parser["Expression parser<br/>[parser.go]"]
  node_ast["Expression AST<br/>[expr.go]"]
  node_astprint["AST printer<br/>[ast_printer.go]"]
end

subgraph group_runtime["Evaluation and output"]
  node_evaluator["Expression evaluator<br/>[evaluator.go]"]
  node_valueprint["Value formatter<br/>[printer.go]"]
end

node_user(("CLI user"))
node_repl(("REPL input"))

node_user -->|"selects mode"| node_cli
node_repl -->|"enters prompt"| node_cli
node_cli -->|"scans source"| node_scanner
node_cli -->|"parses tokens"| node_parser
node_parser -->|"builds expressions"| node_ast
node_cli -->|"prints AST"| node_astprint
node_cli -->|"evaluates expressions"| node_evaluator
node_evaluator -->|"visits expressions"| node_ast
node_cli -->|"formats values"| node_valueprint
node_astprint -->|"writes AST"| node_stdout
node_valueprint -->|"writes values"| node_stdout

click node_cli "https://github.com/adrianmoser1/cmsc124-cardist/blob/main/main.go"
click node_scanner "https://github.com/adrianmoser1/cmsc124-cardist/blob/main/scanner/scanner.go"
click node_parser "https://github.com/adrianmoser1/cmsc124-cardist/blob/main/parser/parser.go"
click node_ast "https://github.com/adrianmoser1/cmsc124-cardist/blob/main/parser/expr.go"
click node_astprint "https://github.com/adrianmoser1/cmsc124-cardist/blob/main/parser/ast_printer.go"
click node_evaluator "https://github.com/adrianmoser1/cmsc124-cardist/blob/main/evaluator/evaluator.go"
click node_valueprint "https://github.com/adrianmoser1/cmsc124-cardist/blob/main/evaluator/printer.go"

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_cli,node_stdout,node_user toneBlue
class node_scanner,node_parser,node_ast,node_astprint toneAmber
class node_evaluator,node_valueprint toneMint
class node_repl toneIndigo
```

## Components

### CLI entry

- [CLI and orchestration](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/main.go): `main.go`
- **Printed output**

### Language pipeline

- [Scanner](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/scanner/scanner.go): `scanner/scanner.go`
- [Expression parser](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/parser/parser.go): `parser/parser.go`
- [Expression AST](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/parser/expr.go): `parser/expr.go`
- [AST printer](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/parser/ast_printer.go): `parser/ast_printer.go`

### Evaluation and output

- [Expression evaluator](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/evaluator/evaluator.go): `evaluator/evaluator.go`
- [Value formatter](https://github.com/adrianmoser1/cmsc124-cardist/blob/main/evaluator/printer.go): `evaluator/printer.go`

### Other components

- **CLI user**
- **REPL input**

## Connections

- CLI user → CLI and orchestration: selects mode (evidence: `main.go`)
- REPL input → CLI and orchestration: enters prompt (evidence: `main.go`)
- CLI and orchestration → Scanner: scans source (evidence: `main.go`)
- CLI and orchestration → Expression parser: parses tokens (evidence: `main.go`)
- Expression parser → Expression AST: builds expressions (evidence: `parser/parser.go`)
- CLI and orchestration → AST printer: prints AST (evidence: `main.go`)
- CLI and orchestration → Expression evaluator: evaluates expressions (evidence: `main.go`)
- Expression evaluator → Expression AST: visits expressions (evidence: `evaluator/evaluator.go`)
- CLI and orchestration → Value formatter: formats values (evidence: `main.go`)
- AST printer → Printed output: writes AST
- Value formatter → Printed output: writes values
