1 (in-package "PARENSCRIPT")
3 (defparameter *js-target-version
* 1.3)
5 (defmacro ps
(&body body
)
6 "Given Parenscript forms (an implicit progn), compiles those forms
7 to a JavaScript string at macro-expansion time."
8 `(concatenate 'string
,@(parenscript-print (compile-parenscript-form `(progn ,@body
) :expecting
:statement
))))
10 (defmacro ps-doc
(&body body
)
11 "Expands Parenscript forms in a clean environment."
12 (let ((*ps-gensym-counter
* 0)
13 (*ps-special-variables
* nil
))
14 (macroexpand-1 `(ps ,@body
))))
16 (defun ps-doc* (ps-form)
17 (let ((*ps-gensym-counter
* 0)
18 (*ps-special-variables
* nil
))
22 (with-output-to-string (s)
24 (princ (if (stringp x
)
28 (parenscript-print (compile-parenscript-form ps-form
:expecting
:statement
)))))
30 (defun ps* (&rest body
)
31 "Compiles BODY to a JavaScript string.
33 (ps1* `(progn ,@body
)))
35 (defvar *js-inline-string-delimiter
* #\"
36 "Controls the string delimiter char used when compiling Parenscript in ps-inline.")
38 (defun ps-inline* (form &optional
(*js-string-delimiter
* *js-inline-string-delimiter
*))
39 (concatenate 'string
"javascript:" (ps1* form
)))
41 (defmacro/ps ps-inline
(form &optional
(string-delimiter *js-inline-string-delimiter
*))
42 `(concatenate 'string
"javascript:"
43 ,@(let ((*js-string-delimiter
* string-delimiter
))
44 (parenscript-print (compile-parenscript-form form
:expecting
:statement
)))))