[add] Added the test for sjscript.
This commit is contained in:
parent
f5df2c9aab
commit
efc5dbb038
@ -1,7 +1,8 @@
|
||||
/// License: MIT
|
||||
module sjscript;
|
||||
|
||||
import std.algorithm;
|
||||
import std.algorithm,
|
||||
std.range;
|
||||
|
||||
import dast.tokenize : Tokenize;
|
||||
|
||||
@ -21,6 +22,7 @@ ParametersBlock[] CreateScriptAst(string src) {
|
||||
Tokenize!TokenType().
|
||||
filter!(x => x.type != TokenType.Whitespace).
|
||||
filter!(x => x.type != TokenType.Comment).
|
||||
chain([Token("", TokenType.End)]).
|
||||
Preprocess().
|
||||
Parse();
|
||||
}
|
||||
|
18
sjscript/test/parse.d
Executable file
18
sjscript/test/parse.d
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env dub
|
||||
/+ dub.json:
|
||||
{
|
||||
"name": "parse",
|
||||
"dependencies": {
|
||||
"sjscript": {"path": "../"}
|
||||
}
|
||||
} +/
|
||||
|
||||
import std;
|
||||
|
||||
import sjscript;
|
||||
|
||||
int main(string[] args) {
|
||||
enforce(args.length >= 2);
|
||||
args[1].readText.CreateScriptAst().writeln;
|
||||
return 0;
|
||||
}
|
16
sjscript/test/test01.sj
Normal file
16
sjscript/test/test01.sj
Normal file
@ -0,0 +1,16 @@
|
||||
// this is comment
|
||||
|
||||
$define horming {
|
||||
translate_x += cos(atan(player_y, player_x)) * $horming_speed;
|
||||
translate_y += sin(atan(player_y, player_x)) * $horming_speed;
|
||||
}
|
||||
|
||||
A [0..10] {
|
||||
translate_x = 0.5 + sin(rtime)*0.5;
|
||||
translate_y = 0.5 + cos(rtime)*0.5;
|
||||
}
|
||||
|
||||
B [5..15] {
|
||||
$define horming_speed {0.1}
|
||||
$horming
|
||||
}
|
Reference in New Issue
Block a user