WIP RC Bank Heist demo
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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:
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)))
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user