[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reader hacks



	
    Date: Mon, 23 Dec 85 16:47 EST
    From: Guy Steele <gls@THINK-AQUINAS.ARPA>
    To: common-lisp@SU-AI.ARPA
    Subject: Reader hacks
    Message-ID: <851223164735.3.GLS@THINK-JEHOSEPHAT.ARPA>
    
    I am writing code for reader macros and find I need the following
    things:
    (1) A predicate that is true of whitespace characters and false
	of all others.  The problem is that
	    (member foo '(#\Space #\Newline))
	doesn't cover tabs, etc., and
	    (member foo '(#\Space #\Newline #\Tab #\Form))
	is not completely portable because of the semi-standard
	character names.

How about?:

(defun whitespace-p (char)
  (with-input-from-string (input-string (string char))
    (null (peek-char t input-string nil nil nil))))

If char is a whitespace char., PEEK-CHAR will hit EOF and return NIL;
otherwise PEEK-CHAR will return the char.  Inefficient, but the only
portable solution I know.

I think there should be a function

SYNTAX-TYPE char  => {ILLEGAL | WHITESPACE | CONSTITUENT |
                      SINGLE-ESCAPE | MULTIPLE-ESCAPE | MACRO}


	-- Nick