# beefyandtheducks/xmlsharp architecture

> Architecture diagram of the GitHub repository beefyandtheducks/xmlsharp, 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/beefyandtheducks/xmlsharp
- Repository: https://github.com/beefyandtheducks/xmlsharp

## Overview

XMLSharp is a command-line toolchain for a small XMLSharp language: users compile source files to an intermediate representation (IR), or run a file, compiling it first when it is not already IR. The visible run command establishes that compile-if-needed workflow, and the interpreter executes IR instructions through operation handlers. The tree shows compiler stages for lexing, validation, AST construction, desugaring, and IR handling, but their internal calls are not shown in the sampled source. No README is present, so additional documented capabilities cannot be confirmed.

Main entry points: [`XMLSharpCompiler/Compiler.cs`](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/Compiler.cs) (Compiler entry), [`XMLSharpInterpreter/Interpreter.cs`](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpInterpreter/Interpreter.cs) (Interpreter), [`XMLSharp/Program.cs`](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharp/Program.cs) (Command dispatch), [`XMLSharp/Commands/RunCommand.cs`](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharp/Commands/RunCommand.cs) (Run command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_program["Command dispatch<br/>[Program.cs]"]
  node_compile_command["Compile command<br/>[CompileCommand.cs]"]
  node_run_command["Run command<br/>[RunCommand.cs]"]
end

subgraph group_compiler["Compiler"]
  node_compiler_entry["Compiler entry<br/>[Compiler.cs]"]
  node_lexer["Lexer<br/>[Lexer.cs]"]
  node_validator["Syntax validator<br/>[SyntaxValidator.cs]"]
  node_syntax_rules["Syntax rules<br/>[SyntaxRules.cs]"]
  node_ast_generator["AST generator<br/>[AstGenerator.cs]"]
  node_desugarer["Desugarer<br/>[Desugarer.cs]"]
  node_import_expander["Import expansion<br/>[ImportExpander.cs]"]
end

subgraph group_common["Language model"]
  node_ir_writer["IR handling<br/>[IR.cs]"]
  node_ast_model["AST nodes<br/>[AstNodes.cs]"]
  node_ir_model["IR model<br/>[IIR.cs]"]
  node_diagnostics["Diagnostics<br/>[ErrorReporter.cs]"]
end

subgraph group_runtime["Runtime"]
  node_interpreter["Interpreter<br/>[Interpreter.cs]"]
  node_handlers["Operation handlers"]
end

node_user(("CLI user"))
node_source["Source file"]
node_ir_file["IR file"]
node_output(("Program output"))

node_user -->|"invokes"| node_program
node_program -->|"dispatches"| node_compile_command
node_program -->|"dispatches"| node_run_command
node_source -->|"supplies input"| node_compile_command
node_compile_command -->|"compiles"| node_compiler_entry
node_run_command -->|"compiles if needed"| node_compiler_entry
node_run_command -->|"starts"| node_interpreter
node_compiler_entry -->|"uses"| node_lexer
node_compiler_entry -->|"uses"| node_validator
node_validator -->|"applies"| node_syntax_rules
node_compiler_entry -->|"uses"| node_ast_generator
node_ast_generator -->|"creates"| node_ast_model
node_compiler_entry -->|"uses"| node_desugarer
node_compiler_entry -->|"uses"| node_import_expander
node_compiler_entry -->|"emits IR"| node_ir_writer
node_ir_writer -->|"uses"| node_ir_model
node_compiler_entry -->|"reports errors"| node_diagnostics
node_ir_writer -->|"writes"| node_ir_file
node_interpreter -->|"reads"| node_ir_model
node_interpreter -->|"dispatches"| node_handlers
node_handlers -->|"writes"| node_output
node_interpreter -->|"reports status"| node_output

click node_program "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharp/Program.cs"
click node_compile_command "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharp/Commands/CompileCommand.cs"
click node_run_command "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharp/Commands/RunCommand.cs"
click node_compiler_entry "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/Compiler.cs"
click node_lexer "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/Lexer.cs"
click node_validator "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/SyntaxValidator.cs"
click node_syntax_rules "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/SyntaxRules.cs"
click node_ast_generator "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/AstGenerator.cs"
click node_desugarer "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/Desugarer.cs"
click node_import_expander "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/ImportExpander.cs"
click node_ir_writer "https://github.com/beefyandtheducks/xmlsharp/blob/main/Common/IR.cs"
click node_ast_model "https://github.com/beefyandtheducks/xmlsharp/blob/main/Common/AstNodes.cs"
click node_ir_model "https://github.com/beefyandtheducks/xmlsharp/blob/main/Common/IIR.cs"
click node_diagnostics "https://github.com/beefyandtheducks/xmlsharp/blob/main/Common/ErrorReporter.cs"
click node_interpreter "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpInterpreter/Interpreter.cs"
click node_handlers "https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpInterpreter/OperationHandlers.cs"

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_program,node_compile_command,node_run_command,node_user toneBlue
class node_compiler_entry,node_lexer,node_validator,node_syntax_rules,node_ast_generator,node_desugarer,node_import_expander toneAmber
class node_ir_writer,node_ast_model,node_ir_model,node_diagnostics toneMint
class node_interpreter,node_handlers toneRose
class node_source,node_ir_file,node_output toneIndigo
```

## Components

### CLI

- [Command dispatch](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharp/Program.cs): `XMLSharp/Program.cs`
- [Compile command](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharp/Commands/CompileCommand.cs): `XMLSharp/Commands/CompileCommand.cs`
- [Run command](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharp/Commands/RunCommand.cs): `XMLSharp/Commands/RunCommand.cs`

### Compiler

- [Compiler entry](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/Compiler.cs): `XMLSharpCompiler/Compiler.cs`
- [Lexer](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/Lexer.cs): `XMLSharpCompiler/Lexer.cs`
- [Syntax validator](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/SyntaxValidator.cs): `XMLSharpCompiler/SyntaxValidator.cs`
- [Syntax rules](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/SyntaxRules.cs): `XMLSharpCompiler/SyntaxRules.cs`
- [AST generator](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/AstGenerator.cs): `XMLSharpCompiler/AstGenerator.cs`
- [Desugarer](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/Desugarer.cs): `XMLSharpCompiler/Desugarer.cs`
- [Import expansion](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpCompiler/ImportExpander.cs): `XMLSharpCompiler/ImportExpander.cs`

### Language model

- [IR handling](https://github.com/beefyandtheducks/xmlsharp/blob/main/Common/IR.cs): `Common/IR.cs`
- [AST nodes](https://github.com/beefyandtheducks/xmlsharp/blob/main/Common/AstNodes.cs): `Common/AstNodes.cs`
- [IR model](https://github.com/beefyandtheducks/xmlsharp/blob/main/Common/IIR.cs): `Common/IIR.cs`
- [Diagnostics](https://github.com/beefyandtheducks/xmlsharp/blob/main/Common/ErrorReporter.cs): `Common/ErrorReporter.cs`

### Runtime

- [Interpreter](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpInterpreter/Interpreter.cs): `XMLSharpInterpreter/Interpreter.cs`
- [Operation handlers](https://github.com/beefyandtheducks/xmlsharp/blob/main/XMLSharpInterpreter/OperationHandlers.cs): `XMLSharpInterpreter/OperationHandlers.cs`

### Other components

- **CLI user**
- **Source file**
- **IR file**
- **Program output**

## Connections

- CLI user → Command dispatch: invokes
- Command dispatch → Compile command: dispatches
- Command dispatch → Run command: dispatches
- Source file → Compile command: supplies input
- Compile command → Compiler entry: compiles
- Run command → Compiler entry: compiles if needed
- Run command → Interpreter: starts
- Compiler entry → Lexer: uses
- Compiler entry → Syntax validator: uses
- Syntax validator → Syntax rules: applies
- Compiler entry → AST generator: uses
- AST generator → AST nodes: creates
- Compiler entry → Desugarer: uses
- Compiler entry → Import expansion: uses
- Compiler entry → IR handling: emits IR
- IR handling → IR model: uses
- Compiler entry → Diagnostics: reports errors
- IR handling → IR file: writes
- Interpreter → IR model: reads
- Interpreter → Operation handlers: dispatches
- Operation handlers → Program output: writes
- Interpreter → Program output: reports status
