[add] Added the test for sjscript.

This commit is contained in:
falsycat 2019-10-04 00:00:00 +00:00
parent f5df2c9aab
commit efc5dbb038
3 changed files with 37 additions and 1 deletions

View File

@ -1,7 +1,8 @@
/// License: MIT /// License: MIT
module sjscript; module sjscript;
import std.algorithm; import std.algorithm,
std.range;
import dast.tokenize : Tokenize; import dast.tokenize : Tokenize;
@ -21,6 +22,7 @@ ParametersBlock[] CreateScriptAst(string src) {
Tokenize!TokenType(). Tokenize!TokenType().
filter!(x => x.type != TokenType.Whitespace). filter!(x => x.type != TokenType.Whitespace).
filter!(x => x.type != TokenType.Comment). filter!(x => x.type != TokenType.Comment).
chain([Token("", TokenType.End)]).
Preprocess(). Preprocess().
Parse(); Parse();
} }

18
sjscript/test/parse.d Executable file
View 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
View 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
}