1 (in-package :parenscript
)
3 (defun compile-script (ps-form &key
(output-stream nil
))
4 "Compiles the Parenscript form PS-FORM into Javascript.
5 If OUTPUT-STREAM is NIL, then the result is a string; otherwise code
6 is output to the OUTPUT-STREAM stream."
7 (parenscript-print (compile-parenscript-form ps-form
:expecting
:statement
) output-stream
))
9 (defmacro ps
(&body body
)
10 "Given Parenscript forms (an implicit progn), expands to code which
11 compiles those forms to a JavaScript string."
12 `(ps* '(progn ,@body
)))
14 (defmacro ps-doc
(&body body
)
15 "Expands Parenscript forms in a clean environment."
16 `(let ((*ps-gensym-counter
* 0)
17 (*ps-special-variables
* nil
))
20 (defun ps* (&rest body
)
21 "Compiles BODY to a JavaScript string.
23 (compile-script `(progn ,@body
)))
25 (defvar *js-inline-string-delimiter
* #\"
26 "Controls the string delimiter char used when compiling Parenscript in ps-inline.")
28 (defun ps-inline* (form &optional
(*js-string-delimiter
* *js-inline-string-delimiter
*))
31 (parenscript-print (compile-parenscript-form form
:expecting
:statement
))))
33 (defmacro ps-inline
(form &optional
(string-delimiter '*js-inline-string-delimiter
*))
34 `(ps-inline* ',form
,string-delimiter
))