Skip to content

Hscript addon featuring script classes, imports, usings, properties, string interpolation and more.

License

Notifications You must be signed in to change notification settings

Kriptel/RuleScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

01e0c00 · Sep 7, 2024

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RuleScript

Hscript addon with imports, usings, string interpolation and more.

Features:

Package

package keyword (optional).

package scripts.hello.world;

Import

import haxe.ds.StringMap;

var map = new StringMap();
map.set("Hello","World");
trace(map.get("Hello")); // World

Import with alias

you can use as or in keywords alias.

import haxe.ds.StringMap as StrMap;

var map = new StrMap();
map.set("Hello","World");
trace(map.get("Hello")); // World
import haxe.ds.StringMap in StrMap;

var map = new StrMap();
map.set("Hello","World");
trace(map.get("Hello")); // World

Using

using Reflect;

var a = {
  "Hello":"World"
};
trace(a.getProperty("Hello")); // World

String interpolation (Experimental)

RuleScript supports String Interpolation, but you can only use identifiers, double quotes string, calls without arguments and + operator.

var a = 'Hello';
trace('RuleScript: $a World'); // RuleScript: Hello World
var a = {
    a:'RuleScript',
    b: () -> 'Hello',
    c:'World'
};
        
trace('${a.a}: ${a.b() + " " + a.c}'); // RuleScript: Hello World

Abstracts in script

RuleScriptAbstracts.txt in any classpath :

test.HelloWorldAbstract

test/HelloWorldAbstract.hx :

abstract HelloWorldAbstract(String) from String to String
{
	public static function rulescriptPrint():HelloWorldAbstract
		return 'Hello World';
}

Script :

import test.HelloWorldAbstract;

trace(HelloWorldAbstract.rulescriptPrint()); // 'Hello World'

More templates in test/src/Main.hx.

Limitations

To Do

  • Lua Parser
  • Improve String Interpolation
  • Improve hscript module parser

Install

  1. Installing lib:

    Haxelib : haxelib git rulescript https://github.com/Kriptel/RuleScript.git

    Hmm : hmm git rulescript https://github.com/Kriptel/RuleScript.git

  2. Adding lib to your project:

    Hxml :

    -lib rulescript

    Lime/OpenFL :

    <haxelib name="rulescript"/>