On 08/20/2010 10:32 PM, Bastian Müller wrote:

Hi,

Sorry if this has been asked already earlier here on the list. I looked
into the reference documentation, but couldn't find anything. Is it
possible to generate JavaScript comments, or even more generalized,
inline any JavaScript inside parenscript code?

I'm new to parenscript's internals, so maybe that's not the correct way, but here's a small patch that allows something like:

(ps (comment #?"Foo\nbar"))
;; =>
;; "/* Foo
;; bar */;"

Cheers
diff --git a/src/package.lisp b/src/package.lisp
index d9e2222..84c1c53 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -210,6 +210,7 @@
 
    ;; lisp eval
    #:lisp
+   #:comment
 
    ;; v v v STUFF WE SHOULD PROBABLY MOVE TO OTHER LIBS v v v
 
@@ -392,4 +393,6 @@
    #:funcall
    #:escape
    #:regex
+
+   #:comment
    ))
diff --git a/src/printer.lisp b/src/printer.lisp
index 28c878d..070ee88 100644
--- a/src/printer.lisp
+++ b/src/printer.lisp
@@ -312,3 +312,6 @@ vice-versa.")
   ;; literal-js should be a form that evaluates to a string containing
   ;; valid JavaScript
   (psw literal-js))
+
+(defprinter js:comment (string)
+  "/* " (psw string) " */")
\ No newline at end of file
diff --git a/src/special-forms.lisp b/src/special-forms.lisp
index f39a563..eaea5bc 100644
--- a/src/special-forms.lisp
+++ b/src/special-forms.lisp
@@ -681,3 +681,6 @@ code in :execute."
   (if (member :execute situation-list)
       (ps-compile `(progn ,@body))
       (ps-compile `(progn))))
+
+(define-ps-special-form comment (string)
+  `(js:comment ,string))
\ No newline at end of file
_______________________________________________
parenscript-devel mailing list
[email protected]
http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel

Reply via email to