hiss-read more ergonomic

This commit is contained in:
2020-10-04 13:50:11 -06:00
parent b575f8da0a
commit 96628d74c2
2 changed files with 7 additions and 2 deletions

View File

@@ -14,6 +14,10 @@ class Story {
// Separate reader for Hiss expressions:
var reader: HissReader;
function hissRead(str: String) {
return reader.read("", HStream.FromString(str));
}
public function new(storyScript: String, storyTeller: StoryTeller) {
StaticFiles.compileWith("reader-macros.hiss");
StaticFiles.compileWith("hanklib.hiss");
@@ -26,7 +30,8 @@ class Story {
interp.importFunction(storyTeller, storyTeller.handleOutput, "*handle-output*");
interp.importFunction(storyTeller, storyTeller.handleChoices, "*handle-choices*");
interp.importFunction(reader, reader.read, "hiss-read");
interp.importFunction(this, hissRead, "hiss-read");
interp.importFunction(reader, reader.readDelimitedList, "hiss-read-delimited-list", List([Int(3)]) /* keep blankELements wrapped */, ["terminator", "delimiters", "start", "stream"]);
interp.load("hanklib.hiss");
}

View File

@@ -38,7 +38,7 @@
(HStream:drop-whitespace stream)
(HStream:peek stream 1))
("{"
(hiss-read "" (HStream:from-string (trim (substring (first (HStream:take-until stream ["}"])) 1)))))
(hiss-read (trim (substring (first (HStream:take-until stream ["}"])) 1))))
(default t))
output
(read-output "" stream t)