Skip to content

Commit d5afb79

Browse files
committed
Upload lib
1 parent 6100afc commit d5afb79

12 files changed

Lines changed: 917 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
/.vscode
3+
/test/export
4+
hxformat.json

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# RuleScript
2+
3+
Hscript addon with imports, usings, string interpolation and more.
4+
5+
## Features:
6+
7+
### Package :
8+
package keyword (optional).
9+
```haxe
10+
package scripts.hello.world;
11+
```
12+
### Import :
13+
```haxe
14+
import haxe.ds.StringMap;
15+
16+
var map = new StringMap();
17+
map.set("Hello","World");
18+
trace(map.get("Hello")); // World
19+
```
20+
### Import with alias:
21+
you can use `as` or `in` keywords alias.
22+
```haxe
23+
import haxe.ds.StringMap as StrMap;
24+
25+
var map = new StrMap();
26+
map.set("Hello","World");
27+
trace(map.get("Hello")); // World
28+
```
29+
You also can use `in` keyword.
30+
```haxe
31+
import haxe.ds.StringMap in StrMap;
32+
33+
var a = {
34+
"Hello":"World"
35+
};
36+
trace(a.getProperty("Hello")); // World
37+
```
38+
### Using:
39+
```haxe
40+
using Reflect;
41+
42+
var map = new StrMap();
43+
map.set("Hello","World");
44+
trace(map.get("Hello")); // World
45+
```
46+
47+
### String interpolation (Experimental)
48+
RuleScript supports [String Interpolation](https://haxe.org/manual/lf-string-interpolation.html), but you can only use identifiers, double quotes string, calls without arguments and `+` operator.
49+
```haxe
50+
var a = 'Hello';
51+
return 'RuleScript: $a World'; // RuleScript: Hello World
52+
```
53+
54+
More templates in `test/src/Main.hx`.
55+
# Limitations
56+
57+
- String interpolations don't support many functions.
58+
- Script `using` callback supports max number of arguments is 8.
59+
- [Wildcard imports](https://haxe.org/manual/type-system-import.html#wildcard-import) don't support.
60+
61+
# To Do:
62+
- Lua Parser
63+
- Importing abstract classes in scripts
64+
- Improve String Interpolation
65+
- Improve hscript module parser
66+
67+
# Install
68+
69+
1. Installing lib :
70+
- Haxelib : `haxelib git rulescript https://github.com/Kriptel/RuleScript.git`
71+
- Hmm : `hmm git rulescript https://github.com/Kriptel/RuleScript.git`
72+
2. Adding lib to your project :
73+
- Hxml :
74+
```hxml
75+
-lib rulescript
76+
```
77+
- Lime/OpenFL :
78+
```xml
79+
<haxelib name="rulescript"/>
80+
```

extraParams.hxml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-lib hscript
2+
3+
--macro addMetadata('#if hscriptPos @:build(rulescript.macro.ExprMacro.build()) #end', 'hscript.ExprDef')
4+
--macro addMetadata('#if !hscriptPos @:build(rulescript.macro.ExprMacro.build()) #end', 'hscript.Expr')
5+
6+
--macro addMetadata('@:build(rulescript.macro.ExprMacro.buildInterpDefaults())', 'hscript.Interp')
7+
8+
--macro addMetadata('@:build(rulescript.macro.ExprMacro.buildToolsDefaults())', 'hscript.Tools')
9+
10+
--macro addMetadata('@:build(rulescript.macro.ExprMacro.buildPrinterDefaults())', 'hscript.Printer')
11+
12+
--macro addMetadata('@:build(rulescript.macro.ExprMacro.buildBytesDefaults())', 'hscript.Bytes')
13+
14+
--macro addMetadata('@:build(rulescript.macro.ExprMacro.buildCheckerDefaults())', 'hscript.Checker')
15+
16+
--macro addMetadata('@:build(rulescript.macro.ExprMacro.buildMacroDefaults())', 'hscript.Macro')

haxelib.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "rulescript",
3+
"url" : "https://github.com/Kriptel/RuleScript",
4+
"license": "MIT",
5+
"description": "Hscript addon with imports, string interpolation and more",
6+
"version": "0.0.1",
7+
"releasenote": "Initial Release",
8+
"dependencies": {
9+
"hscript":""
10+
},
11+
"contributors": ["Kriptel"]
12+
}

0 commit comments

Comments
 (0)