A static, strongly-typed, system-level programming language compiler targeting LLVM IR.
- Static typing with type inference
- System-level programming with pointers, structs, unions, and enums
- LLVM backend for native code generation
- Multiple integer types: i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize
- Floating-point types: f16, f32, f64, f128
- Pointer operations:
*(dereference),&(address-of),->(arrow operator) - Control flow: if/else, while, for, switch, break, continue
- User-defined types: struct, union, enum
- Namespaces and using declarations
- Const and static declarations
dotnet buildcd example/SolidLang.Compilers.Examples
dotnet run -- example1.solidsrc/SolidLang.Compilers/
├── CodeGen/
│ └── LLVMCodeGenerator.cs # LLVM IR code generation
├── Semantic/
│ └── SemanticAnalyzer.cs # Semantic analysis
├── Symbols/
│ ├── Symbol.cs # Symbol definitions
│ └── SymbolTable.cs # Symbol table implementation
├── Types/
│ ├── SolidType.cs # Type system
│ └── TypeRegistry.cs # Type registry for LLVM mapping
├── Compiler.cs # Main compiler entry point
├── SolidLangLexer.cs # Generated lexer
├── SolidLangParser.cs # Generated parser
└── SolidLang.Compilers.csproj
grammar/
├── SolidLangLexer.g4 # Lexer grammar
├── SolidLangParser.g4 # Parser grammar
└── gen/ # Generated .tokens/.interp files
example/SolidLang.Compilers.Examples/
└── example*.solid # Example programs
test/SolidLang.Compilers.Tests/
└── Tests.cs # Unit tests
var x: i32 = 10;
var y = 20; // Type inference
func add(a: i32, b: i32): i32 {
return a + b;
}
struct Point {
x: f32,
y: f32
}
var num: i32 = 10;
var ptr: *i32 = #
var value: i32 = *ptr;
if x > 0 {
// ...
} else {
// ...
}
while x < 10 {
x = x + 1;
}
for var i: i32 = 0; i < 10; i = i + 1 {
// ...
}
switch value {
1 => // case 1
2, 3 => // case 2 or 3
else => // default
}
After modifying grammar files:
java -jar /path/to/antlr-4.13.2-complete.jar -Dlanguage=CSharp -o src/SolidLang.Compilers grammar/SolidLangParser.g4 grammar/SolidLangLexer.g4dotnet testMIT License