romero@mind.UUCP (Antonio Romero) (08/01/88)
I'm currently porting a production system from FranzLisp to Lucid CommonLisp 2.1.1 running on a Sun. I've run into a problem which I can't find a good answer for, myself. What i need to be able to do is end certain keywords in the productions with colons -- e.g. "action:" or "belief:". My first thought was to try just making ":" into a macro character whose associated function would return no values, so that colons effectively disappear from the input stream. This worked for most purposes, but broke things like "(member 'someatom somelist :test 'equal)" because ":test" was no longer recognized as a keyword-- all lisp ever saw was "(member 'someatom somelist test 'equal)." My solution also made it impossible to reference symbols in other packages. So I need a solution which would allow tokens to end in colons, without breaking the other special interpretations associated with colons. Ideally this would be possible within the CommonLisp standard, so as to be portable, but I'll settle for a non-portable solution if I have to. Has anyone out there solved this one already? -Antonio Romero romero@confidence.princeton.edu
barmar@think.COM (Barry Margolin) (08/02/88)
In article <2694@mind.UUCP> romero@mind.UUCP (Antonio Romero) writes: >So I need a solution which would allow tokens to end in colons, without >breaking the other special interpretations associated with colons. >Ideally this would be possible within the CommonLisp standard, so as to be >portable, but I'll settle for a non-portable solution if I have to. >Has anyone out there solved this one already? It will have to be non-portable, as there is no way to write what colon does within Common Lisp. The problem is that the handler for the colon character needs to back up the parser, and the Common Lisp reader macro facility doesn't provide that functionality; reader macros can only look ahead. Colon has to be built in to the reader so that it can do this. Couldn't you write an editor macro or sed script to go through your production source files and put a backslash before the colons? If you don't use colons for their Common Lisp meaning in the same files as your productions then you could bind *READTABLE* to a readtable that has colon defined as a constituent character while you load the productions. When you are loading Lisp source files you would use the regular readtable. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar