From: David Vazquez Date: Mon, 24 Dec 2012 02:52:32 +0000 (+0000) Subject: Printer X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=d3174299bd6152f0b96e5961c15921a89fd5adfd;p=jscl.git Printer --- diff --git a/lispstrack.html b/lispstrack.html index d37c17a..1500a7e 100644 --- a/lispstrack.html +++ b/lispstrack.html @@ -73,12 +73,12 @@ // 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(); diff --git a/lispstrack.lisp b/lispstrack.lisp index 326030b..7f7d99d 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -405,7 +405,6 @@ digits) "")))) - ;;;; Reader ;;; The Lisp reader, parse strings and return Lisp objects. The main @@ -1027,6 +1026,17 @@ ;;; 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) @@ -1059,6 +1069,7 @@ (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*