about summary refs log tree commit diff
path: root/README.md
blob: 3e5ef9aa2c63cb9ceb1615aae4e32029801a2ac6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Pry Programming Language

Pry is a simple, elegant, statically typed and compiled programming language implemented in Zig, with support for variables, control flow, functions, and code generation using LLVM.

## Building and Running

1. Ensure you have Zig and LLVM installed on your system.
2. Run the compiler on an example file:
   ```
   zig build run -- examples/8.pry
   ```
3. Link the generated object file to create an executable:
   ```
   cc output.o
   ```
4. Run the executable:
   ```
   ./a.out
   ```

## Language Features

- **Variables and Declarations**: Uses `let` for variable declaration.
- **Control Flow**: Supports `if` and `while` 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.
- **Import System**: Allows importing libraries and other Pry files.

## Example Program

```js
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
```