Skip to content

Aergiaaa/simpg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(Idiotic) SimpleScript

A stupidly minimal and simplistic interpreted language written in go.

Instalation

Prerequisites: Go 1.21 or higher

do this for installing the interpreter to your system

make install

do this if you want to build it locally

make build

do this to uninstall it from system

make uninstall

Usage

REPL Mode

idiot

Run a Script

idiot run script.simp

Language Feature

Datatype

  • Integers : 1, 67, -69
  • Booleans : true, false
  • Strings : "Hello World!"
  • Arrays : [1,2,3]
  • Hashmaps : {6:"seven"}

Variables

let x = 5;
let six = "seven";
let eliteBallKnowledge = ["apple", "grapes", "durian"];

Functions

let add = ft(x, y) {
    return x + y;
}

let brainrot = add(6,7);

Control Flow

if (x == 6) {
    return 7;
} else {
    return 89;
}

for () {
    print("six sevennnn");
    if (x == 67){
        break;
    }
    x = x + 1;
}

Operators

  • Arithmetic : +,-,*,/
  • Comparison : ==,!=,<,>,<=,>=
  • Logical : !
  • Assignment : =

Builtin Functions

  • len(x) - Returns length of string or array
  • head(arr) - Returns first element of array
  • tail(arr) - Returns last element of array
  • killHead(arr) - Returns array without first element
  • push(arr, x) - Returns array with element appended
  • print(x) - Prints values to stdout

Example

let fibonacci = ft(n) {
   if (n < 2) {
       return n;
   }
   return fibonacci(n - 1) + fibonacci(n - 2);
};

let result = fibonacci(10);
print(result);

Development

Run Test

make test

Run Directy

make run

Project Structure

  • lexer/ - Tokenization
  • token/ - Token definitions
  • ast/ - Abstract syntax tree
  • parser/ - Parser implementation
  • object/ - Object system and environment
  • evaluator/ - Tree-walking evaluator
  • repl/ - Read-eval-print loop

About

a simple interpreter that builds from scratch using golang

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors