Removed js and ps-inline as special forms; added ps-inline and ps-inline*.
[clinton/parenscript.git] / src / compilation-interface.lisp
CommitLineData
9da682ca
RD
1(in-package :parenscript)
2
839600e9
VS
3(defun compile-script (script-form &key (output-stream nil))
4 "Compiles the Parenscript form SCRIPT-FORM into Javascript.
5Non-null PRETTY-PRINT values result in a pretty-printed output code.
6If OUTPUT-STREAM is NIL, then the result is a string; otherwise code
7is output to the OUTPUT-STREAM stream."
8 (parenscript-print (compile-parenscript-form script-form) output-stream))
b5be3f57 9
4a987e2b 10(defmacro ps (&body body)
a9fce0a7 11 "A macro that returns a Javascript string of the supplied Parenscript forms."
4a987e2b 12 `(ps* '(progn ,@body)))
a9fce0a7 13
4a987e2b 14(defun ps* (&rest body)
a9fce0a7 15 "Return the javascript string representing BODY.
a9fce0a7 16Body is evaluated."
4b5d1808 17 (compile-script `(progn ,@body)))
33c100f0
VS
18
19(defun ps-inline* (form)
20 (concatenate 'string
21 "javascript:"
22 (remove #\Newline
23 (parenscript-print (compile-parenscript-form form :expecting :statement))
24 :from-end t)))
25
26(defmacro ps-inline (&body body)
27 `(ps-inline* '(progn ,@body)))