1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@ examples/shave/
|
||||
examples/petIntersection/
|
||||
transcript.hlog
|
||||
validating.hlog
|
||||
js/hank.js
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
language: haxe
|
||||
haxe:
|
||||
- "4.0.0-preview.5"
|
||||
- "3.4.7"
|
||||
hxml:
|
||||
- test.hxml
|
||||
- hxml/all-platforms.hxml
|
||||
|
||||
@@ -6,6 +6,11 @@ Portable narrative scripting language based on Ink.
|
||||
Hank is a more portable answer to Inkle's open-source [Ink](http://github.com/inkle/ink)
|
||||
engine. It is currently just a proof of concept, but you may use it at your own risk.
|
||||
|
||||
Supported targets:
|
||||
|
||||
* JavaScript
|
||||
* C++
|
||||
|
||||
## Comparison with Ink and Inkjs
|
||||
|
||||
|Feature|Ink|Inkjs|Hank|
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
-lib hscript
|
||||
-lib utest
|
||||
-main tests.AllTestsMain
|
||||
--interp
|
||||
@@ -1,5 +0,0 @@
|
||||
-lib hscript
|
||||
-lib utest
|
||||
-debug
|
||||
-main tests.ExamplesTestMain
|
||||
-js index.js
|
||||
@@ -1,4 +0,0 @@
|
||||
-lib hscript
|
||||
-lib utest
|
||||
-main tests.ExamplesTestMain
|
||||
--interp
|
||||
12
functions.sh
Normal file
12
functions.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
t() {
|
||||
haxe hxml/$1.hxml --interp
|
||||
}
|
||||
|
||||
ta() {
|
||||
haxe hxml/all-platforms.hxml
|
||||
}
|
||||
|
||||
debug() {
|
||||
haxe -js js/hank.js hxml/all.hxml
|
||||
chromium-browser js/index.html
|
||||
}
|
||||
@@ -16,7 +16,12 @@ class FileLoadingMacro {
|
||||
if (file.endsWith("/")) {
|
||||
files.remove(file);
|
||||
|
||||
files = files.concat(recursiveLoop(file));
|
||||
var dirFiles = recursiveLoop(file);
|
||||
if (dirFiles.length == 0) {
|
||||
throw 'No files found in directory "$file"';
|
||||
}
|
||||
|
||||
files = files.concat(dirFiles);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
@@ -51,21 +56,21 @@ class FileLoadingMacro {
|
||||
static function recursiveLoop(directory:String, ?files: Array<String>): Array<String> {
|
||||
if (files == null) files = [];
|
||||
if (sys.FileSystem.exists(directory)) {
|
||||
trace("directory found: " + directory);
|
||||
//trace("directory found: " + directory);
|
||||
for (file in sys.FileSystem.readDirectory(directory)) {
|
||||
var path = haxe.io.Path.join([directory, file]);
|
||||
if (!sys.FileSystem.isDirectory(path)) {
|
||||
trace("file found: " + path);
|
||||
//trace("file found: " + path);
|
||||
// do something with file
|
||||
files.push(path.toString());
|
||||
} else {
|
||||
var directory = haxe.io.Path.addTrailingSlash(path);
|
||||
trace("directory found: " + directory);
|
||||
//trace("directory found: " + directory);
|
||||
files = recursiveLoop(directory, files);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
trace('"$directory" does not exists');
|
||||
//trace('"$directory" does not exists');
|
||||
}
|
||||
|
||||
return files;
|
||||
|
||||
@@ -90,7 +90,9 @@ class HankBuffer {
|
||||
#if sys
|
||||
var rawBuffer = sys.io.File.getContent(path);
|
||||
#else
|
||||
if (files == null || !files.exists(path)) {
|
||||
if (files == null) {
|
||||
throw 'Tried to open file $path on a non-sys platform without passing in preloaded files';
|
||||
} else if (!files.exists(path)) {
|
||||
throw 'Tried to open file $path that was not pre-loaded';
|
||||
}
|
||||
var rawBuffer = files[path];
|
||||
|
||||
12
hxml/all-platforms.hxml
Normal file
12
hxml/all-platforms.hxml
Normal file
@@ -0,0 +1,12 @@
|
||||
-js out.js
|
||||
-cmd node out.js
|
||||
hxml/all.hxml
|
||||
--next
|
||||
|
||||
--interp
|
||||
hxml/all.hxml
|
||||
--next
|
||||
|
||||
-cpp
|
||||
hxml/all.hxml
|
||||
--next
|
||||
7
hxml/all.hxml
Normal file
7
hxml/all.hxml
Normal file
@@ -0,0 +1,7 @@
|
||||
-cp hank
|
||||
-lib hscript
|
||||
-lib utest
|
||||
--each
|
||||
hxml/examples.hxml
|
||||
--next
|
||||
hxml/internals.hxml
|
||||
1
hxml/examples.hxml
Normal file
1
hxml/examples.hxml
Normal file
@@ -0,0 +1 @@
|
||||
-main tests.main.Examples
|
||||
1
hxml/internals.hxml
Normal file
1
hxml/internals.hxml
Normal file
@@ -0,0 +1 @@
|
||||
-main tests.main.Internals
|
||||
@@ -1,4 +0,0 @@
|
||||
-lib hscript
|
||||
-lib utest
|
||||
-main tests.InternalsTestMain
|
||||
--interp
|
||||
5
js/index.html
Normal file
5
js/index.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="hank.js"></script>
|
||||
</head>
|
||||
</html>
|
||||
@@ -1,9 +0,0 @@
|
||||
package tests;
|
||||
import utest.Test;
|
||||
|
||||
class AllTestsMain extends Test {
|
||||
public static function main() {
|
||||
InternalsTestMain.main();
|
||||
ExamplesTestMain.main();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class TestObject {
|
||||
|
||||
}
|
||||
|
||||
@:build(hank.FileLoadingMacro.build(["examples/diverts/"]))
|
||||
class HInterfaceTest extends utest.Test {
|
||||
|
||||
var hInterface: HInterface;
|
||||
@@ -26,7 +27,7 @@ class HInterfaceTest extends utest.Test {
|
||||
var root: Array<StoryNode>;
|
||||
|
||||
public function setup() {
|
||||
storyTree = StoryNode.FromAST(new Parser().parseFile("examples/diverts/main.hank"));
|
||||
storyTree = StoryNode.FromAST(new Parser().parseFile("examples/diverts/main.hank", files));
|
||||
var viewCounts = storyTree.createViewCounts();
|
||||
root = [storyTree];
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import hank.HankBuffer;
|
||||
import hank.HankBuffer.Position;
|
||||
import hank.HankAssert;
|
||||
|
||||
@:build(hank.FileLoadingMacro.build(["examples/parsing/"]))
|
||||
class HankBufferTest extends utest.Test {
|
||||
var file: HankBuffer;
|
||||
var path: String;
|
||||
@@ -14,7 +15,7 @@ class HankBufferTest extends utest.Test {
|
||||
|
||||
function setup() {
|
||||
path = 'examples/parsing/file.txt';
|
||||
file = HankBuffer.FromFile(path);
|
||||
file = HankBuffer.FromFile(path, files);
|
||||
expectedPosition = new Position(path, 1, 1);
|
||||
}
|
||||
|
||||
@@ -103,7 +104,7 @@ class HankBufferTest extends utest.Test {
|
||||
}
|
||||
|
||||
function testGetLineTrimming() {
|
||||
file = HankBuffer.FromFile('examples/parsing/whitespace.txt');
|
||||
file = HankBuffer.FromFile('examples/parsing/whitespace.txt', files);
|
||||
|
||||
HankAssert.equals(Some("Just give me this output."), file.peekLine("lr"));
|
||||
HankAssert.equals(Some(" Just give me this output."), file.peekLine("r"));
|
||||
@@ -116,14 +117,14 @@ class HankBufferTest extends utest.Test {
|
||||
}
|
||||
|
||||
function testSkipWhitespace() {
|
||||
file = HankBuffer.FromFile('examples/parsing/whitespace.txt');
|
||||
file = HankBuffer.FromFile('examples/parsing/whitespace.txt', files);
|
||||
|
||||
file.skipWhitespace();
|
||||
HankAssert.equals("Just", file.take(4));
|
||||
}
|
||||
|
||||
function testFindNestedExpression() {
|
||||
file = HankBuffer.FromFile('examples/parsing/nesting.txt');
|
||||
file = HankBuffer.FromFile('examples/parsing/nesting.txt', files);
|
||||
var slice1 = file.findNestedExpression('{', '}', 0);
|
||||
HankAssert.contains("doesn't contain what comes first", slice1.unwrap().checkValue());
|
||||
HankAssert.contains("Ends before here", slice1.unwrap().checkValue());
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package tests;
|
||||
package tests.main;
|
||||
import utest.Test;
|
||||
import hank.StoryTestCase;
|
||||
|
||||
@:build(hank.FileLoadingMacro.build(["examples/"]))
|
||||
class ExamplesTestMain extends Test {
|
||||
class Examples extends Test {
|
||||
public static function main() {
|
||||
utest.UTest.run([new StoryTestCase("examples"
|
||||
#if !sys
|
||||
@@ -1,8 +1,8 @@
|
||||
package tests;
|
||||
package tests.main;
|
||||
import utest.Test;
|
||||
import hank.StoryTestCase;
|
||||
|
||||
class InternalsTestMain extends Test {
|
||||
class Internals extends Test {
|
||||
public static function main() {
|
||||
utest.UTest.run([new HInterfaceTest(), new HankBufferTest(), new ParserTest(), new StoryTreeTest(), new FileLoadingMacroTest()]);
|
||||
}
|
||||
Reference in New Issue
Block a user