Simple statically typed and compiled programming language implemented in Zig, with support for variables, control flow, functions, and code generation using LLVM.
- Ensure you have Zig and LLVM installed on your system.
- Run the compiler on an example file:
zig build run -- examples/8.src compile
- Link the generated object file to create an executable:
cc output.o
- Run the executable:
./a.out
- Variables and Declarations: Uses
let
for variable declaration. - Control Flow: Supports
if
andwhile
statements. - Functions: Supports function declarations with parameters and return types.
- Expressions: Includes additive, multiplicative, equality, and unary expressions.
- Code Generation with LLVM: Translates AST to LLVM IR and generates object files for native execution.
let main = () => i64 {
let fib = (n: i64) => i64 {
if n == 0 {
return 0;
};
if n == 1 {
return 1;
};
return fib(n-2) + fib(n-1);
};
let result = fib(30);
print(result);
return result;
};
Output: 832040