WIP RC Bank Heist demo

This commit is contained in:
2020-05-11 14:35:57 -06:00
parent ead7e5202f
commit f89250fde1
4 changed files with 33 additions and 6 deletions

View File

@@ -10,7 +10,7 @@ class Demo implements StoryTeller {
StaticFiles.compileWithAll("examples");
// TODO ask the user to choose an example
new Story("examples/hello.hank", new Demo()).run();
new Story("examples/rc-bank-heist.hank", new Demo()).run();
}
public function new() {

View File

@@ -25,11 +25,19 @@ class Story {
}, "*handle-output*")));
hissRepl.load("hanklib.hiss");
hissRepl.load("reader-macros.hiss");
}
public function run() {
hissRepl.load(storyScript);
hissRepl.load("reader-macros.hiss");
hissRepl.interp.print(Atom(String("For debug purposes, it reads as:")));
hissRepl.interp.print(hissRepl.readAll(StaticFiles.getContent(storyScript)));
hissRepl.interp.print(Atom(String("")));
switch (hissRepl.load(storyScript)) {
case Signal(Error(s)):
throw s;
default:
}
}
}

View File

@@ -0,0 +1,8 @@
(defun output (&rest parts)
(*handle-output* (funcall + (map parts eval-output-part))))
(defun eval-output-part (part)
(cond
((string? part) part)))
(defun divert (target) (print (+ "Diverting to " target)))

View File

@@ -20,6 +20,9 @@
// ( ) at the start of an output is a label
(defmacro expect (stream function &rest args)
`(get (call ,stream ,function ,@args) output))
(setq *hank-inline-terminators* '(
"->"
"["
@@ -28,12 +31,20 @@
"<"))
(defun read-output (_ stream _)
(list 'print (get (call stream take-until (list "\n") t) output)))
;(print "reading output")
;(print "RIGHT BELOW:")
;(print (call stream peek-all))
(list 'output (expect stream take-until (list "\n") t)))
(defun read-divert (_ stream _)
;(print "reading divert")
(call stream drop-whitespace)
(list 'divert (expect stream take-until-whitespace)))
(defun hank-read-mode ()
(setq *hiss-readtable* (copy-readtable))
; TODO set other read macros
(set-macro-string "->" read-divert)
(set-default-read-function read-output))