Simian is a lightweight and expressive custom programming language with a simple syntax designed for learning and experimentation. This interpreter, written in Go, demonstrates the implementation of a basic yet fully functional programming environment.
- Dynamic Typing: Support for integers, booleans, and functions.
- Control Structures: Includes conditionals (
if/else) and loops. - Function Definitions: First-class functions with lexical scoping.
- Arithmetic Operations: Support for basic mathematical operations (
+,-,*,/). - Variable Bindings: Flexible variable declarations.
- REPL (Read-Eval-Print Loop): An interactive shell for immediate evaluation.
-
Run the Docker image:
docker run --rm -it ashabkhan/interpreter
-
Clone the repository:
git clone https://github.com/ashab-k/interpeter_go.git cd simian-lang -
Run the interpreter:
go run main.go
-
Access the REPL (Read-Eval-Print Loop) for immediate code execution.
Once inside the REPL, you can execute Simian code directly:
let x = 5 * 3;
x + 2;
if (x > 10) { x - 1 } else { x + 1 };
To exit the REPL, use Ctrl+C or type exit.
let fib = fn(n) {
if (n < 2) {
n
} else {
fib(n - 1) + fib(n - 2);
}
};
fib(10);
let factorial = fn(n) {
if (n == 0) {
1
} else {
n * factorial(n - 1);
}
};
factorial(5);