Skip to content

ashab-k/interpeter_go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simian Programming Language Interpreter

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.

Features

  • 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.

Getting Started

Run through Docker

  1. Run the Docker image:

    docker run --rm -it ashabkhan/interpreter

Installation

  1. Clone the repository:

    git clone https://github.com/ashab-k/interpeter_go.git
    cd simian-lang
  2. Run the interpreter:

    go run main.go
  3. Access the REPL (Read-Eval-Print Loop) for immediate code execution.

Usage

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.

Example Programs

Fibonacci Sequence

let fib = fn(n) {
  if (n < 2) {
    n
  } else {
    fib(n - 1) + fib(n - 2);
  }
};

fib(10);

Factorial

let factorial = fn(n) {
  if (n == 0) {
    1
  } else {
    n * factorial(n - 1);
  }
};

factorial(5);

About

An interpreter written in golang for a custom programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published