1 (in-package :parenscript
)
3 (defun compile-script (script-form &key
(output-stream nil
))
4 "Compiles the Parenscript form SCRIPT-FORM into Javascript.
5 Non-null PRETTY-PRINT values result in a pretty-printed output code.
6 If OUTPUT-STREAM is NIL, then the result is a string; otherwise code
7 is output to the OUTPUT-STREAM stream."
8 (parenscript-print (compile-parenscript-form script-form
:expecting
:statement
) output-stream
))
10 (defmacro ps
(&body body
)
11 "Given Parenscript forms (an implicit progn), expands to code which
12 compiles those forms to a JavaScript string."
13 `(ps* '(progn ,@body
)))
15 (defun ps* (&rest body
)
16 "Compiles BODY to a JavaScript string.
18 (compile-script `(progn ,@body
)))
20 (defvar *js-inline-string-delimiter
* #\"
21 "Controls the string delimiter char used when compiling Parenscript in ps-inline.")
23 (defun ps-inline* (form &optional
(*js-string-delimiter
* *js-inline-string-delimiter
*))
26 (parenscript-print (compile-parenscript-form form
:expecting
:statement
))))
28 (defmacro ps-inline
(form &optional
(string-delimiter '*js-inline-string-delimiter
*))
29 `(ps-inline* ',form
,string-delimiter
))