Code Monkey home page Code Monkey logo

lite-script's Introduction

LiteScript - A little script engine

LiteScript is a little script engine designed for developpers who want to include a script language in their application. The script language is similar to Javascript with object-oriented (it's planned to also create a language similar to assembler). It's developed in C++11 and doesn't need to be installed, it's enough to move the source files in the project. (Development is still in progress)

The objective is to create an alternative of current script engines and integrating features that aren't present (like a state saving to stop execution and store it in a file, or an execution function instruction by instruction, etc...).

The documentation is available here.

Currently finished

  • class Object (contain the variable block memory)
  • class Variable (reference an Object in the memory)
  • class Memory (contain all Objects)
  • class Type (abstract : define all operations for every variable type)
  • class/structure Instruction (a reduced instruction)
  • class State (contain the script/assembler state)
  • Assembler script language
  • Javascript like object-oriented language
  • Garbage collector mark and sweep (Variables contain also a reference counter)
  • Instructions, memory and state save/load
  • Simple interface API
  • French documentation

Types currently defined :

  • undefined
  • null
  • boolean
  • number
  • string (and character but it's hidden)
  • callback (need to complete le calling operator)
  • array
  • namespace
  • class (inherit, static elements, constructor and operator overloading)
  • class object (object created by a class)

In future

  • Documentation in english (coming soon)

Example of Javascript like script

This example is the objective for the javascript like object-oriented language.

// Enter in the namespace named "Game"
namespace Game;

// Person inherits Alive and Human
class Person : Alive, Human {

    // Attributes
    var name;
    var age;
    var gender;
    
    // Constructor
    function Person(name, age, gender) {
    	// Parent constructor
    	this.Alive();
        
    	this.name = name;
        this.age = age;
        this.gender = gender;
    }
    
    // Methods
    function Birthday() {
    	this.age++;
    }
    
    function Say(args...) {
    	Console.WriteLine(this.name + "say : ");
        Console.Write("> ");
    	for (var i = 0; i < args.length; i++) {
        	Console.Write(args[i] + " ");
        }
        Console.WriteLine();
    }
    
    // Operator overloading
    operator add(p) {
        return Person.Merry(this, p);
    }
    
    // Static method
    static function Marry(p1, p2) {
    	return new Person(Random.Name, 0, Random.Gender);
    }
}

// Return to the original namespace
namespace global;

var Anne = new Game.Person("Anne", 21, Gender.FEMALE);
var Henri = new Game.Person("Henri", 22, Gender.MALE);

print(Anne + Henri);

lite-script's People

Contributors

leptitdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.