Coverage report: /Users/mohacker/src/yurrriq/land-of-lisp/src/wizard6.lisp
Kind | Covered | All | % |
expression | 0 | 106 | 0.0 |
branch | 0 | 10 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
2
(in-package :lol.wizard5)
5
(defparameter *allowed-commands* '(look walk pickup inventory))
9
(let ((cmd (game-read)))
10
(unless (eq (car cmd) 'quit)
11
(game-print (game-eval cmd))
14
(export (find-symbol "GAME-REPL"))
18
(let ((cmd (read-from-string (concatenate 'string "(" (read-line) ")"))))
19
(flet ((quote-it (x) (list 'quote x)))
20
(cons (car cmd) (mapcar #'quote-it (cdr cmd))))))
23
(defun game-eval (sexp)
24
(if (member (car sexp) *allowed-commands*)
26
'(i do not know that command.)))
29
(defun tweak-text (lst caps lit)
31
(let ((item (car lst))
33
(cond ((eql item #\space) (cons item (tweak-text rest caps lit)))
34
((member item '(#\! #\? #\.)) (cons item (tweak-text rest t lit)))
35
((eql item #\") (tweak-text rest caps (not lit)))
36
(lit (cons item (tweak-text rest nil lit)))
37
(caps (cons (char-upcase item) (tweak-text rest nil lit)))
38
(t (cons (char-downcase item) (tweak-text rest nil nil)))))))
41
(defun game-print (lst)
42
(princ (coerce (tweak-text (coerce (string-trim "() "
43
(prin1-to-string lst))