Subject: Re: simple lisp interpreter
From: (Rob Warnock)
Date: Thu, 06 Sep 2007 20:45:13 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
George Neuner  <gneuner2/> wrote:
| Kent M Pitman <> wrote:
| >George Neuner <gneuner2/> writes:
| >> If you confine the problem to Lisp syntax then the answer is yes.
| >
| >Terminology: You mean to say "pre-defined Lisp syntax".  The stuff written
| >by users is _still_ Lisp syntax.
| Sort of.  What I mean exactly is any sexpr syntax that conforms to
| Lisp's prefix notation.

I think you've missed Kent's point entirely. When coding a CL READ in C
[and ignoring READ's &OPTIONAL parameters for the nonce], the top level
"parsing" routine looks like this [or something closely equivalent]:

    reader(lispobj stream)
        for (;;) {         /* Needed for reader macros that do nothing. */
          lispobj obj;
          int c = flush_whitespace(stream);
          if (EOF == c)
            return type_EOF;
          obj = (*read_macro_table[c])(stream, c);
          if (obj != type_ZeroValues)  /* Comments, #+/-, and the like. */
            return obj;
	  /* else keep reading... */

The key is that *ALL* "parsing" starts with that crucial indirection
through the current readtable. There *is* no such thing as a
"[conforming] s-expr syntax" unless the readmacro currently in
force for #\( just happens to be one which gives you the "usual"
s-expr syntax.


p.s. And, no, that's not the way you'd really do it [except for an
inflexible toy CL subset], since that makes it too hard to switch
readtables. You need to add a level of indirection:

          obj = (*(*read_macro_table)[c])(stream, c);

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607