[bese-devel] parenscript regexps

Lou Vanek vanek at acd.net
Tue Jun 13 14:53:18 UTC 2006


Marijn Haverbeke wrote:

> It seems that the UCW version of parenscript adds slashes to it's 
> argument when printing it. This is contrary to what the parenscript 
> manual says ("The regex
> form actually does nothing at all to its argument, and prints it as 
> is."), and makes it impossible to do things like "/bla/i" 
> (case-insensitive compare). I can't download the latest non-ucw 
> parenscript because that site (the one linked from CLiki) has been down 
> forever, but the ASDF-install version of parenscript does not add these 
> slashes.
> 
> So think the UCW version shouldn't do that either. Simply a matter of 
> changing
> 
> (defmethod js-to-strings ((regex regex) start-pos)
>   (declare (ignore start-pos))
>   (list (format nil "/~A/" (value regex))))
> 
> in src/js.lisp and removing the slashes in the string.
> 
> Regards,
> Marijn Haverbeke
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> bese-devel mailing list
> bese-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel

;; Maybe this makes more sense?

(defun first-slash-p (string)
   (and (> (length string) 0)
        (eq (char string 0) '#\/)))

(defmethod js-to-strings ((regex regex) start-pos)
   (declare (ignore start-pos))
   (let ((slash (if (first-slash-p (value regex)) nil "/")))
     (list (format nil (concatenate 'string slash "~A" slash) (value regex)))))

Lou Vanek
--
Civilization had too many rules for me, so I did my best to rewrite them.
Bill Cosby





More information about the bese-devel mailing list