Fixed define-symbol-macro.
[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."
a589bb43 8 (parenscript-print (compile-parenscript-form script-form :expecting :statement) output-stream))
b5be3f57 9
4a987e2b 10(defmacro ps (&body body)
c639fe7f
VS
11 "Given Parenscript forms (an implicit progn), expands to code which
12compiles those forms to a JavaScript string."
4a987e2b 13 `(ps* '(progn ,@body)))
a9fce0a7 14
4a987e2b 15(defun ps* (&rest body)
ecc3218c 16 "Compiles BODY to a JavaScript string.
a9fce0a7 17Body is evaluated."
4b5d1808 18 (compile-script `(progn ,@body)))
33c100f0 19
c639fe7f
VS
20(defvar *js-inline-string-delimiter* #\"
21 "Controls the string delimiter char used when compiling Parenscript in ps-inline.")
33c100f0 22
c639fe7f
VS
23(defun ps-inline* (form &optional (*js-string-delimiter* *js-inline-string-delimiter*))
24 (concatenate 'string
25 "javascript:"
26 (parenscript-print (compile-parenscript-form form :expecting :statement))))
27
28(defmacro ps-inline (form &optional (string-delimiter '*js-inline-string-delimiter*))
29 `(ps-inline* ',form ,string-delimiter))