lightscript

A simple interpreted scripting language implemented in C.

Simple interpreted scripting language built in C. Project has been archived since the code is not maintained anymore. This project was built as a part of my high school graduation thesis.

Much of the syntax was inspired by Ruby and some other scripting languages.

Some examples of the implemented language features:

Recursion somehow works

import stdlib;
 
def fib(n) do
  if n == 0 || n == 1 do
    ret Copy(n);
  else
    ret fib(n - 1) + fib(n - 2);
  end
end
 
a = fib(11);
 
Print(a);

Loops, arrays and string operators

a = 0;
arr = [];
 
while a < 20
do
  arr[a] = a * "*";
  a = a + 1;
end

Imports of modules

import stdlib;

(Maybe, don't remember anymore) Objects

import stdlib;
 
struct File
  filename = "";
  mode = "";
 
  def File(self, fn, m) do
    filename = fn + "";
    mode = m + "";
  end
 
end
 
a = New(File, "config.conf", "r");
 
Print(a:filename);

I remember working on the File object by an internal C implementation, I don't know if I managed to finish custom structs/objects implementation.