Changed ps-inline to take a form instead of an implicit progn as a parameter; gave...
[clinton/parenscript.git] / src / compilation-interface.lisp
1 (in-package :parenscript)
2
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))
9
10 (defmacro ps (&body body)
11 "A macro that returns a Javascript string of the supplied Parenscript forms."
12 `(ps* '(progn ,@body)))
13
14 (defun ps* (&rest body)
15 "Compiles BODY to a JavaScript string.
16 Body is evaluated."
17 (compile-script `(progn ,@body)))
18
19 (defun ps-inline* (form &optional (quote-char #\"))
20 (let ((*js-quote-char* quote-char))
21 (concatenate 'string
22 "javascript:"
23 (remove #\Newline
24 (parenscript-print (compile-parenscript-form form :expecting :statement))
25 :from-end t))))
26
27 (defmacro ps-inline (form &optional (quote-char #\"))
28 `(ps-inline* ',form ,quote-char))