Commit | Line | Data |
---|---|---|
4525e3cd VS |
1 | (in-package "PARENSCRIPT") |
2 | ||
62ddca23 | 3 | (defparameter *js-target-version* 1.3) |
9da682ca | 4 | |
4a987e2b | 5 | (defmacro ps (&body body) |
cb8f8e58 VS |
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)))) | |
a9fce0a7 | 9 | |
c11d6a09 TC |
10 | (defmacro ps-doc (&body body) |
11 | "Expands Parenscript forms in a clean environment." | |
cb8f8e58 VS |
12 | (let ((*ps-gensym-counter* 0) |
13 | (*ps-special-variables* nil)) | |
14 | (macroexpand-1 `(ps ,@body)))) | |
15 | ||
157cb2d6 VS |
16 | (defun ps-doc* (ps-form) |
17 | (let ((*ps-gensym-counter* 0) | |
18 | (*ps-special-variables* nil)) | |
19 | (ps1* ps-form))) | |
20 | ||
cb8f8e58 | 21 | (defun ps1* (ps-form) |
84338ee6 DG |
22 | (with-output-to-string (s) |
23 | (mapc (lambda (x) | |
24 | (princ (if (stringp x) | |
cb8f8e58 | 25 | x |
84338ee6 DG |
26 | (eval x)) |
27 | s)) | |
28 | (parenscript-print (compile-parenscript-form ps-form :expecting :statement))))) | |
c11d6a09 | 29 | |
4a987e2b | 30 | (defun ps* (&rest body) |
ecc3218c | 31 | "Compiles BODY to a JavaScript string. |
a9fce0a7 | 32 | Body is evaluated." |
cb8f8e58 | 33 | (ps1* `(progn ,@body))) |
33c100f0 | 34 | |
c639fe7f VS |
35 | (defvar *js-inline-string-delimiter* #\" |
36 | "Controls the string delimiter char used when compiling Parenscript in ps-inline.") | |
33c100f0 | 37 | |
c639fe7f | 38 | (defun ps-inline* (form &optional (*js-string-delimiter* *js-inline-string-delimiter*)) |
cb8f8e58 | 39 | (concatenate 'string "javascript:" (ps1* form))) |
c639fe7f | 40 | |
e69d0a12 VS |
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))))) |