# kevyn04/scannerp1 architecture

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

- Interactive diagram: https://gitdiagram.com/kevyn04/scannerp1
- Repository: https://github.com/kevyn04/scannerp1

## Overview

MatrixLang is a desktop text editor with lexical scanning and LL(1) syntax parsing. The main workflow is a user editing source, requesting a token view or parse, and seeing tokens, scanner errors, a parse tree, or a syntax error in the editor. The grammar and parse table support the parser; token and tree structures carry its input and result. The excerpts show the editor-to-scanner/parser calls and parser internals. File-management behavior is visible only partially, so no unsupported file-operation links are included.

Main entry points: [`src/parser/Parser.java`](https://github.com/kevyn04/scannerp1/blob/master/src/parser/Parser.java) (Parser), [`src/TextEditor.java`](https://github.com/kevyn04/scannerp1/blob/master/src/TextEditor.java) (Text editor), [`src/lexer/Lexer.java`](https://github.com/kevyn04/scannerp1/blob/master/src/lexer/Lexer.java) (Lexer), [`src/lexer/Token.java`](https://github.com/kevyn04/scannerp1/blob/master/src/lexer/Token.java) (Token record)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editor["Desktop editor"]
  node_main["Application launch<br/>[Main.java]"]
  node_text_editor["Text editor<br/>[TextEditor.java]"]
end

subgraph group_lexing["Lexical scanning"]
  node_lexer["Lexer<br/>[Lexer.java]"]
  node_token["Token record<br/>[Token.java]"]
  node_token_type["Token types<br/>[TokenType.java]"]
end

subgraph group_parsing["Syntax parsing"]
  node_parser["Parser<br/>[Parser.java]"]
  node_grammar["Grammar rules<br/>[Grammar.java]"]
  node_parse_table["LL&#40;1&#41; table<br/>[ParseTable.java]"]
  node_parse_node["Parse tree node<br/>[Node.java]"]
  node_parse_error["Syntax errors"]
end

node_user(("Editor user"))

node_user -->|"edits and requests"| node_text_editor
node_main -->|"launches"| node_text_editor
node_text_editor -->|"scans text"| node_lexer
node_text_editor -->|"parses tokens"| node_parser
node_text_editor -->|"renders tree"| node_parse_node
node_lexer -->|"creates tokens"| node_token
node_lexer -->|"assigns types"| node_token_type
node_token -->|"stores type"| node_token_type
node_parser -->|"reads tokens"| node_token
node_parser -->|"checks symbols"| node_grammar
node_parser -->|"selects productions"| node_parse_table
node_parser -->|"builds tree"| node_parse_node
node_parser -->|"throws on mismatch"| node_parse_error
node_parse_table -->|"derives table"| node_grammar

click node_main "https://github.com/kevyn04/scannerp1/blob/master/src/Main.java"
click node_text_editor "https://github.com/kevyn04/scannerp1/blob/master/src/TextEditor.java"
click node_lexer "https://github.com/kevyn04/scannerp1/blob/master/src/lexer/Lexer.java"
click node_token "https://github.com/kevyn04/scannerp1/blob/master/src/lexer/Token.java"
click node_token_type "https://github.com/kevyn04/scannerp1/blob/master/src/lexer/TokenType.java"
click node_parser "https://github.com/kevyn04/scannerp1/blob/master/src/parser/Parser.java"
click node_grammar "https://github.com/kevyn04/scannerp1/blob/master/src/parser/Grammar.java"
click node_parse_table "https://github.com/kevyn04/scannerp1/blob/master/src/parser/ParseTable.java"
click node_parse_node "https://github.com/kevyn04/scannerp1/blob/master/src/parser/Node.java"
click node_parse_error "https://github.com/kevyn04/scannerp1/blob/master/src/parser/ParseException.java"

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,node_text_editor,node_user toneBlue
class node_lexer,node_token,node_token_type toneAmber
class node_parser,node_grammar,node_parse_table,node_parse_node,node_parse_error toneMint
```

## Components

### Desktop editor

- [Application launch](https://github.com/kevyn04/scannerp1/blob/master/src/Main.java): `src/Main.java`
- [Text editor](https://github.com/kevyn04/scannerp1/blob/master/src/TextEditor.java): `src/TextEditor.java`

### Lexical scanning

- [Lexer](https://github.com/kevyn04/scannerp1/blob/master/src/lexer/Lexer.java): `src/lexer/Lexer.java`
- [Token record](https://github.com/kevyn04/scannerp1/blob/master/src/lexer/Token.java): `src/lexer/Token.java`
- [Token types](https://github.com/kevyn04/scannerp1/blob/master/src/lexer/TokenType.java): `src/lexer/TokenType.java`

### Syntax parsing

- [Parser](https://github.com/kevyn04/scannerp1/blob/master/src/parser/Parser.java): `src/parser/Parser.java`
- [Grammar rules](https://github.com/kevyn04/scannerp1/blob/master/src/parser/Grammar.java): `src/parser/Grammar.java`
- [LL(1) table](https://github.com/kevyn04/scannerp1/blob/master/src/parser/ParseTable.java): `src/parser/ParseTable.java`
- [Parse tree node](https://github.com/kevyn04/scannerp1/blob/master/src/parser/Node.java): `src/parser/Node.java`
- [Syntax errors](https://github.com/kevyn04/scannerp1/blob/master/src/parser/ParseException.java): `src/parser/ParseException.java`

### Other components

- **Editor user**

## Connections

- Editor user → Text editor: edits and requests (evidence: `src/TextEditor.java`)
- Application launch → Text editor: launches (evidence: `src/Main.java`)
- Text editor → Lexer: scans text (evidence: `src/TextEditor.java`)
- Text editor → Parser: parses tokens (evidence: `src/TextEditor.java`)
- Text editor → Parse tree node: renders tree (evidence: `src/TextEditor.java`)
- Lexer → Token record: creates tokens (evidence: `src/lexer/Lexer.java`)
- Lexer → Token types: assigns types (evidence: `src/lexer/Lexer.java`)
- Token record → Token types: stores type (evidence: `src/lexer/Token.java`)
- Parser → Token record: reads tokens (evidence: `src/parser/Parser.java`)
- Parser → Grammar rules: checks symbols (evidence: `src/parser/Parser.java`)
- Parser → LL(1) table: selects productions (evidence: `src/parser/Parser.java`)
- Parser → Parse tree node: builds tree (evidence: `src/parser/Parser.java`)
- Parser → Syntax errors: throws on mismatch (evidence: `src/parser/Parser.java`)
- LL(1) table → Grammar rules: derives table (evidence: `src/parser/ParseTable.java`)
