// Output input with the class jqconsole-output.
if (input[0] != ','){
try {
- jqconsole.Write(JSON.stringify(lisp.evalString(input)) + '\n', 'jqconsole-output');
+ jqconsole.Write(lisp.print(lisp.evalString(input)) + '\n', 'jqconsole-output');
} catch(error) {
jqconsole.Write('ERROR: ' + error + '\n', 'jqconsole-error');
}
} else {
- jqconsole.Write(JSON.stringify(lisp.compileString(input.slice(1))) + '\n', 'jqconsole-output');
+ jqconsole.Write(lisp.compileString(input.slice(1)) + '\n', 'jqconsole-output');
}
// Restart the prompt.
startPrompt();
digits)
""))))
-
;;;; Reader
;;; The Lisp reader, parse strings and return Lisp objects. The main
;;; interactive development (eval), which works calling the compiler
;;; and evaluating the Javascript result globally.
+(defun print-to-string (form)
+ (cond
+ ((symbolp form) (symbol-name form))
+ ((integerp form) (integer-to-string form))
+ ((stringp form) (concat "\"" (escape-string form) "\""))
+ ((listp form)
+ (concat "("
+ (join (mapcar #'print-to-string form)
+ " ")
+ ")"))))
+
#+lispstrack
(progn
(defmacro with-compilation-unit (&rest body)
(js-eval
(concat "var lisp = {};"
"lisp.read = " (lookup-function-translation 'ls-read-from-string nil) ";" *newline*
+ "lisp.print = " (lookup-function-translation 'print-to-string nil) ";" *newline*
"lisp.eval = " (lookup-function-translation 'eval nil) ";" *newline*
"lisp.compile = " (lookup-function-translation 'ls-compile-toplevel nil) ";" *newline*
"lisp.evalString = function(str){" *newline*