@@ -17,20 +17,44 @@ Sharpy.Compiler/
1717│ │ ├── Node.cs # Base AST node types
1818│ │ ├── Statement.cs # Statement nodes
1919│ │ ├── Expression.cs # Expression nodes
20- │ │ └── Types.cs # Type annotations
21- │ └── Parser.cs # Recursive descent parser
20+ │ │ ├── Types.cs # Type annotations
21+ │ │ ├── Pattern.cs # Pattern matching nodes
22+ │ │ └── ... # Visitors, validators, future nodes
23+ │ ├── Parser.cs # Recursive descent parser (6 partial files)
24+ │ └── Parser.*.cs # .Definitions, .Expressions, .Primaries, .Statements, .Types
2225├── Diagnostics/ # Unified error handling
2326│ ├── DiagnosticBag.cs # Structured diagnostic collection
2427│ └── DiagnosticCodes.cs # SPY error code catalog
2528├── Semantic/ # Semantic analysis
2629│ ├── Symbol.cs # Symbol definitions
2730│ ├── Scope.cs # Scope management
2831│ ├── SymbolTable.cs # Symbol table
29- │ └── BuiltinRegistry.cs # Builtin types/functions registry
30- └── CodeGen/ # Code generation
31- ├── RoslynEmitter.cs # Generates C# using Roslyn
32- ├── NameMangler.cs # Name conversion (snake_case → PascalCase)
33- └── CodeGenContext.cs # Code generation state
32+ │ ├── BuiltinRegistry.cs # Builtin types/functions registry
33+ │ ├── TypeChecker.cs # Type checking (8 partial files)
34+ │ ├── TypeChecker.*.cs # .Definitions, .Expressions, .Expressions.Access,
35+ │ │ # .Expressions.Literals, .Expressions.Operators,
36+ │ │ # .Statements, .Utilities
37+ │ └── Validation/ # Pluggable validation pipeline (16 validators)
38+ ├── CodeGen/ # Code generation
39+ │ ├── RoslynEmitter.cs # Generates C# using Roslyn (11 partial files)
40+ │ ├── RoslynEmitter.*.cs # .Expressions, .Expressions.Access, .Expressions.Literals,
41+ │ │ # .Expressions.Operators, .Statements, .TypeDeclarations,
42+ │ │ # .ClassMembers, .CompilationUnit, .ModuleClass, .Operators
43+ │ ├── TypeMapper.cs # Maps Sharpy types to C# types
44+ │ ├── NameMangler.cs # Name conversion (snake_case → PascalCase)
45+ │ ├── CodeGenContext.cs # Code generation state
46+ │ └── CodeValidator.cs # Validates generated code compiles
47+ ├── Project/ # Multi-file project compilation
48+ │ ├── ProjectCompiler.cs # Orchestrates compilation (7 partial files)
49+ │ ├── SpyProject.cs # Project file parsing
50+ │ ├── DependencyGraph.cs # Build ordering
51+ │ └── IncrementalCompilationCache.cs # Incremental compilation
52+ ├── Services/ # Centralized compiler services layer
53+ ├── Discovery/ # CLR type discovery
54+ ├── Model/ # Core data model (CompilationUnit, ProjectModel)
55+ ├── Analysis/ # Control flow graph infrastructure
56+ ├── Shared/ # Constants, keyword escaping, type names
57+ └── Text/ # Source text, spans, locations
3458```
3559
3660### Sharpy.Core
@@ -39,15 +63,24 @@ The runtime library that compiled Sharpy code depends on.
3963```
4064Sharpy.Core/
4165├── Builtins/ # Always-available types and functions
42- │ └── Exports.cs # Global functions (print, len, etc.)
66+ │ ├── Builtins.cs # Builtin function dispatch (partial class)
67+ │ └── Exceptions.cs # Builtin exception types
4368├── Partial.List/ # List[T] implementation (partial class pattern)
4469├── Partial.Set/ # Set[T] implementation
45- ├── Partial.*/ # Other type implementations split by interface
70+ ├── Partial.Complex/ # Complex number implementation
71+ ├── Partial.Iterator/ # Iterator base implementation
72+ ├── Partial.ListIterator/ # List iterator
73+ ├── Partial.ListReverseIterator/ # Reverse list iterator
74+ ├── Partial.SetIterator/ # Set iterator
4675├── Collections/ # Collection interfaces
4776├── Dict.cs # dict[K,V] implementation
4877├── Range.cs # range() builtin
4978├── Enumerate.cs # enumerate() builtin
50- └── *.cs # Other builtins (Zip, Map, Filter, etc.)
79+ ├── Print.cs # print() builtin
80+ ├── Len.cs # len() builtin
81+ ├── ISized.cs # Protocol interface for len()
82+ ├── IBoolConvertible.cs # Protocol interface for bool()
83+ └── *.cs # Other builtins (Zip, Map, Filter, Sorted, etc.)
5184```
5285
5386## Key Design Decisions
@@ -63,7 +96,7 @@ var methods = listType.GetMethods(); // Get all Sharpy list methods
6396
6497### 2. Roslyn Code Generation
6598Uses Microsoft.CodeAnalysis (Roslyn) to:
66- - Generate C# syntax trees
99+ - Generate C# syntax trees via ` SyntaxFactory ` (no string templating)
67100- Emit optimized IL directly
68101- Produce PDB debug symbols
69102- Leverage existing .NET optimizations
0 commit comments