typescript interpreter

This is a fully programming language made from from scratch with TypeScript. It supports OOP, classes, inheritance, user define functions, built in functions, variable assignments and loops.

features

OOP

class Doughnut {
  cook() {
    print "Fry until golden brown.";
  }
}

class BostonCream < Doughnut{}

BostonCream().cook();

functions

fun fib(n) {
  if (n <= 1) {
    return n;
  }
  return fib(n - 2) + fib(n - 1);
}

for (var i = 0; i < 20; i = i + 1) {
  print fib(i);
}

loops

for(var i = 0; i < 20; i = i + 1) {
  print i;
}

var i = 0;
while(i < 20) {
  print i;
  i = i + 1;
}

boolean

var x = 12 > 10+1 ? true : false;
print x;

if(true and false){
  print "true and false is true";
}else{
  print "true and false is false";
}

math

var x = 12;
var y = 13;
var z = 14;

print (x + y) * z;
print x + y * z;
print (x - 10) ** (y - 11) - z;
print x + y ** -1;
print x / y / z;
print y + 0.0;
print x % 20 + x % 10;

string

var x = "hello";
var y = "world";

print x + " "+ y;
print x + 3;

built in functions

print "Hello";
print clock();

comment

/*
  the clock method is a built in function
*/
print clock();  // this will print the time