3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
examples/shave/
|
examples/shave/
|
||||||
examples/petIntersection/
|
examples/petIntersection/
|
||||||
transcript.hlog
|
transcript.hlog
|
||||||
validating.hlog
|
validating.hlog
|
||||||
|
js/hank.js
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
language: haxe
|
language: haxe
|
||||||
haxe:
|
haxe:
|
||||||
- "4.0.0-preview.5"
|
- "3.4.7"
|
||||||
hxml:
|
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)
|
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.
|
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
|
## Comparison with Ink and Inkjs
|
||||||
|
|
||||||
|Feature|Ink|Inkjs|Hank|
|
|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("/")) {
|
if (file.endsWith("/")) {
|
||||||
files.remove(file);
|
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 {
|
} else {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@@ -51,21 +56,21 @@ class FileLoadingMacro {
|
|||||||
static function recursiveLoop(directory:String, ?files: Array<String>): Array<String> {
|
static function recursiveLoop(directory:String, ?files: Array<String>): Array<String> {
|
||||||
if (files == null) files = [];
|
if (files == null) files = [];
|
||||||
if (sys.FileSystem.exists(directory)) {
|
if (sys.FileSystem.exists(directory)) {
|
||||||
trace("directory found: " + directory);
|
//trace("directory found: " + directory);
|
||||||
for (file in sys.FileSystem.readDirectory(directory)) {
|
for (file in sys.FileSystem.readDirectory(directory)) {
|
||||||
var path = haxe.io.Path.join([directory, file]);
|
var path = haxe.io.Path.join([directory, file]);
|
||||||
if (!sys.FileSystem.isDirectory(path)) {
|
if (!sys.FileSystem.isDirectory(path)) {
|
||||||
trace("file found: " + path);
|
//trace("file found: " + path);
|
||||||
// do something with file
|
// do something with file
|
||||||
files.push(path.toString());
|
files.push(path.toString());
|
||||||
} else {
|
} else {
|
||||||
var directory = haxe.io.Path.addTrailingSlash(path);
|
var directory = haxe.io.Path.addTrailingSlash(path);
|
||||||
trace("directory found: " + directory);
|
//trace("directory found: " + directory);
|
||||||
files = recursiveLoop(directory, files);
|
files = recursiveLoop(directory, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
trace('"$directory" does not exists');
|
//trace('"$directory" does not exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
|
|||||||
@@ -90,7 +90,9 @@ class HankBuffer {
|
|||||||
#if sys
|
#if sys
|
||||||
var rawBuffer = sys.io.File.getContent(path);
|
var rawBuffer = sys.io.File.getContent(path);
|
||||||
#else
|
#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';
|
throw 'Tried to open file $path that was not pre-loaded';
|
||||||
}
|
}
|
||||||
var rawBuffer = files[path];
|
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 {
|
class HInterfaceTest extends utest.Test {
|
||||||
|
|
||||||
var hInterface: HInterface;
|
var hInterface: HInterface;
|
||||||
@@ -26,7 +27,7 @@ class HInterfaceTest extends utest.Test {
|
|||||||
var root: Array<StoryNode>;
|
var root: Array<StoryNode>;
|
||||||
|
|
||||||
public function setup() {
|
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();
|
var viewCounts = storyTree.createViewCounts();
|
||||||
root = [storyTree];
|
root = [storyTree];
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import hank.HankBuffer;
|
|||||||
import hank.HankBuffer.Position;
|
import hank.HankBuffer.Position;
|
||||||
import hank.HankAssert;
|
import hank.HankAssert;
|
||||||
|
|
||||||
|
@:build(hank.FileLoadingMacro.build(["examples/parsing/"]))
|
||||||
class HankBufferTest extends utest.Test {
|
class HankBufferTest extends utest.Test {
|
||||||
var file: HankBuffer;
|
var file: HankBuffer;
|
||||||
var path: String;
|
var path: String;
|
||||||
@@ -14,7 +15,7 @@ class HankBufferTest extends utest.Test {
|
|||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
path = 'examples/parsing/file.txt';
|
path = 'examples/parsing/file.txt';
|
||||||
file = HankBuffer.FromFile(path);
|
file = HankBuffer.FromFile(path, files);
|
||||||
expectedPosition = new Position(path, 1, 1);
|
expectedPosition = new Position(path, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ class HankBufferTest extends utest.Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testGetLineTrimming() {
|
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("lr"));
|
||||||
HankAssert.equals(Some(" Just give me this output."), file.peekLine("r"));
|
HankAssert.equals(Some(" Just give me this output."), file.peekLine("r"));
|
||||||
@@ -116,14 +117,14 @@ class HankBufferTest extends utest.Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testSkipWhitespace() {
|
function testSkipWhitespace() {
|
||||||
file = HankBuffer.FromFile('examples/parsing/whitespace.txt');
|
file = HankBuffer.FromFile('examples/parsing/whitespace.txt', files);
|
||||||
|
|
||||||
file.skipWhitespace();
|
file.skipWhitespace();
|
||||||
HankAssert.equals("Just", file.take(4));
|
HankAssert.equals("Just", file.take(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFindNestedExpression() {
|
function testFindNestedExpression() {
|
||||||
file = HankBuffer.FromFile('examples/parsing/nesting.txt');
|
file = HankBuffer.FromFile('examples/parsing/nesting.txt', files);
|
||||||
var slice1 = file.findNestedExpression('{', '}', 0);
|
var slice1 = file.findNestedExpression('{', '}', 0);
|
||||||
HankAssert.contains("doesn't contain what comes first", slice1.unwrap().checkValue());
|
HankAssert.contains("doesn't contain what comes first", slice1.unwrap().checkValue());
|
||||||
HankAssert.contains("Ends before here", slice1.unwrap().checkValue());
|
HankAssert.contains("Ends before here", slice1.unwrap().checkValue());
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package tests;
|
package tests.main;
|
||||||
import utest.Test;
|
import utest.Test;
|
||||||
import hank.StoryTestCase;
|
import hank.StoryTestCase;
|
||||||
|
|
||||||
@:build(hank.FileLoadingMacro.build(["examples/"]))
|
@:build(hank.FileLoadingMacro.build(["examples/"]))
|
||||||
class ExamplesTestMain extends Test {
|
class Examples extends Test {
|
||||||
public static function main() {
|
public static function main() {
|
||||||
utest.UTest.run([new StoryTestCase("examples"
|
utest.UTest.run([new StoryTestCase("examples"
|
||||||
#if !sys
|
#if !sys
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package tests;
|
package tests.main;
|
||||||
import utest.Test;
|
import utest.Test;
|
||||||
import hank.StoryTestCase;
|
import hank.StoryTestCase;
|
||||||
|
|
||||||
class InternalsTestMain extends Test {
|
class Internals extends Test {
|
||||||
public static function main() {
|
public static function main() {
|
||||||
utest.UTest.run([new HInterfaceTest(), new HankBufferTest(), new ParserTest(), new StoryTreeTest(), new FileLoadingMacroTest()]);
|
utest.UTest.run([new HInterfaceTest(), new HankBufferTest(), new ParserTest(), new StoryTreeTest(), new FileLoadingMacroTest()]);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user