From ... From: Erik Naggum Subject: Re: porting from a dialect with a different keyword style Date: 1998/07/29 Message-ID: <3110692693739750@naggum.no>#1/1 X-Deja-AN: 375938002 References: <35BE2422.47BE@totient.demon.co.uk> mail-copies-to: never Organization: Naggum Software; +47 8800 8879; http://www.naggum.no Newsgroups: comp.lang.lisp * Jon Dyte | However talk has symbols which end in ':' and behave like a | keyword -> evaluate to themeselves. ouch. been there, suffered that. | Can anyone suggest a quick method of allowing this to be read in? CL | thinks the lhs of the colon refers to a package.... quick? maybe. dirty? oh, yes. :) first, you make #\: a terminating macro character that returns a unique symbol, instead of being a constituent character that causes the symbol reader to attempt to absorb it only to barf on you. second, you advise READ to hack a returned list to convert a symbol followed by the special colon marker into a keyword and then skip the colon marker. (I forget why we have to advise EXCL::READ1 instead of CL:READ.) (defvar *ilog-readtable* (copy-readtable nil) "Readtable modified to read keywords that _end_ in colon.") (defvar *colon* (list #\:) "Special colon marker to replace final colon in symbols read.") (defun colon-reader (stream character) "Replace all read colons with the special colon marker. Undone later." (declare (ignore stream character)) *colon*) (set-macro-character #\: 'colon-reader nil *ilog-readtable*) (defadvice excl::read1 (ilog-fixup :after) "Undo the damage done by COLON-READER and intern keywords properly." (when (and (eq *readtable* *ilog-readtable*) (listp (first values))) (loop for tail on (first values) when (and (symbolp (first tail)) (eq *colon* (second tail))) do (setf (first tail) (intern (symbol-name (first tail)) *keyword-package*) (second tail) nil (cdr tail) (cddr tail)) when (eq *colon* (first tail)) do (error "Colon reader needs more work.")))) you can now do stuff like (let ((*readtable* *ilog-readtable*)) (read-from-string "(define-cpp-function whatever super: t fumble: yes)")) => (define-cpp-function whatever :super t :fumble yes) voilĂ , as the Ilog Talk people would probably say. CAVEAT: this was sufficient for reading DSSSL, and may not be sufficient for anything else. use at your own risk. #:Erik -- http://www.naggum.no/spam.html is about my spam protection scheme and how to guarantee that you reach me. in brief: if you reply to a news article of mine, be sure to include an In-Reply-To or References header with the message-ID of that message in it. otherwise, you need to read that page.