All Projects → Enalye → grimoire

Enalye / grimoire

Licence: other
A fast, concurrent based scripting language for D.

Programming Languages

d
599 projects

Projects that are alternatives of or similar to grimoire

Umka Lang
Umka: a statically typed embeddable scripting language
Stars: ✭ 308 (+1366.67%)
Mutual labels:  virtual-machine, concurrency
Corium
Corium is a modern scripting language which combines simple, safe and efficient programming.
Stars: ✭ 18 (-14.29%)
Mutual labels:  virtual-machine, concurrency
wa-avd-docker
A Docker image based on Ubuntu Desktop with VNC and noVNC access, that runs a lightweight Android Virtual Device with WhatsApp pre-installed.
Stars: ✭ 113 (+438.1%)
Mutual labels:  virtual-machine
c8c
The chip8 compiler, assembler, and virtual machine
Stars: ✭ 110 (+423.81%)
Mutual labels:  virtual-machine
ratelimiter
A concurrent rate limiter library for Golang based on Sliding-Window rate limiter algorithm.
Stars: ✭ 218 (+938.1%)
Mutual labels:  concurrency
EEL VM
EEL2 compiler and execution VM with enhanced routines for real-time signal processing
Stars: ✭ 27 (+28.57%)
Mutual labels:  virtual-machine
gcl
A graph concurrent library for C++
Stars: ✭ 21 (+0%)
Mutual labels:  concurrency
thread-pool
BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
Stars: ✭ 1,043 (+4866.67%)
Mutual labels:  concurrency
myshoes
Auto-scaling VirtualMachine runner 🏃 for GitHub Actions
Stars: ✭ 68 (+223.81%)
Mutual labels:  virtual-machine
jitana
A graph-based static-dynamic hybrid DEX code analysis tool
Stars: ✭ 35 (+66.67%)
Mutual labels:  virtual-machine
portal
A lightweight framework for golang object (struct) serialization (mapping). Inspired heavily by marshmallow (a Python library).
Stars: ✭ 24 (+14.29%)
Mutual labels:  concurrency
pinboard
A threadsafe way to publish data, just stick it on the pinboard
Stars: ✭ 24 (+14.29%)
Mutual labels:  concurrency
practice
Java并发编程与高并发解决方案:http://coding.imooc.com/class/195.html Java开发企业级权限管理系统:http://coding.imooc.com/class/149.html
Stars: ✭ 39 (+85.71%)
Mutual labels:  concurrency
appdata-environment-desktop
A selection of script and the manual for Privacy International's data interception environment
Stars: ✭ 70 (+233.33%)
Mutual labels:  virtual-machine
rust-concurrency-patterns
Examples of concurrency patterns implemented in Rust
Stars: ✭ 29 (+38.1%)
Mutual labels:  concurrency
ubuntu-vnc-xfce-firefox
Retired. Headless Ubuntu/Xfce containers with VNC/noVNC and Firefox (Generation 1)
Stars: ✭ 20 (-4.76%)
Mutual labels:  virtual-machine
go-workshops
Go language basic workshops for devz
Stars: ✭ 68 (+223.81%)
Mutual labels:  concurrency
ComposableAsync
Create, compose and inject asynchronous behaviors in .Net Framework and .Net Core.
Stars: ✭ 28 (+33.33%)
Mutual labels:  concurrency
cl-gserver
Actor framework featuring actors and agents for easy access to state and asynchronous operations.
Stars: ✭ 121 (+476.19%)
Mutual labels:  concurrency
Dots
Lightweight Concurrent Networking Framework
Stars: ✭ 35 (+66.67%)
Mutual labels:  concurrency

Grimoire

Grimoire is a simple and fast concurrent programming language that can easily be embedded into another D programs. You can very easily interface your program with Grimoire's scripts.

Hope you have fun with this project !

Documentation here !

What it looks like:

//Hello World
event main() {
    "Hello World!":print;
}
//Invert a string
event main() {
    assert("Hello World !":invert == "! dlroW olleH");
}

function invert(string str) (string) {
    let result = str as list(string);
    loop(i, result:size / 2)
        result[i], result[-(i + 1)] = result[-(i + 1)], result[i];
    return result as string;
}
//Fibonacci
event fib() {
    assert(
        function(int n) (int) {
            if(n < 2) return n;
            return self(n - 1) + self(n - 2);
        }(10) == 55);
}

Install

Use dub to include grimoire in your project (or just dump the files in your project if you want). Open the "test" folder to see how to add Grimoire to your program or copy/paste it.

Grimoire is in 2 parts:

  • The compiler
  • The runtime

Compilation

To bind functions defined in D and add other types, you can create a GrLibrary which will store primitives and type information. The GrLibrary object can be shared between multiple compilations.

To compile, you need a compiler GrCompiler which will turn your scripts into bytecode with compileFile.

You must add the GrLibrary objects to the compiler before calling compileFile witch addLibrary. If the compilation fails, you can fetch the error with getError().

If it's successful, the compileFile function will returns a GrBytecode that stores the bytecode generated by the compiler, which can be saved into a file or run by the VM.

// Some basic functions are provided by the default library.
GrLibrary stdlib = grLoadStdLibrary(); 

GrCompiler compiler = new GrCompiler;

// We add the default library.
compiler.addLibrary(stdlib);

// We compile the file.
GrBytecode bytecode = compiler.compileFile("test.gr");

if(bytecode) {
    // Compilation successful
}
else {
    // Error while compiling
    import std.stdio: writeln;
    writeln(compiler.getError().prettify());
}

Debug & Profiling

You can see the generated bytecode with

grDump(bytecode);

Which formats the bytecode in a printable way.

Grimoire also provide a basic profiling tool, to use it, to need to specify a flag during compilation to activate debug informations.

compiler.compileFile("test.gr", GrCompiler.Flags.profile);

The profiling information are accessible on the GrEngine with:

engine.dumpProfiling();

An already formatted version is accessible with:

engine.prettifyProfiling();

Processing

Then, create the runtime's virtual machine GrEngine, you'll first need to add the same libraries as the compiler and in the same order. Then, load the bytecode.

GrEngine engine = new GrEngine;
engine.addLibrary(stdlib);
engine.load(bytecode);

You can then spawn any event like this:

auto mangledName = grMangleComposite("myEvent", [grString]);
if(engine.hasEvent(mangledName)) {
    GrTask task = engine.callEvent(mangledName);
    task.setString("Hello World!");
}

But be aware that every function/task/event are mangled with their signature, so use grMangleComposite to generate the correct function's name.

If the event has parameters, you must push them into the context with the setXX functions.

To run the virtual machine, just call the process function (and check if there's any task(Coroutine) currently running):

while(engine.hasTasks)
    engine.process();

The program will run until all tasks are finished, if you want them to run only for one step, replace the while with if.

You can then check if there are any unhandled errors that went through the VM (Caught exceptions won't trigger that).

if(engine.isPanicking)
    writeln("unhandled exception: " ~ engine.panicMessage);

Documentation

You can find the language documentation > here ! <

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].