Google Groups Home
Help | Sign in
Message from discussion simple lisp interpreter
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Rob Warnock  
View profile
 More options Sep 6 2007, 9:45 pm
Newsgroups: comp.lang.lisp
From: r...@rpw3.org (Rob Warnock)
Date: Thu, 06 Sep 2007 20:45:13 -0500
Local: Thurs, Sep 6 2007 9:45 pm
Subject: Re: simple lisp interpreter
George Neuner  <gneune...@comcast.net> wrote:
+---------------
| Kent M Pitman <pit...@nhplace.com> wrote:
| >George Neuner <gneune...@comcast.net> 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]:

    lispobj
    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.

-Rob

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                     <r...@rpw3.org>
627 26th Avenue                 <URL:http://rpw3.org/>
San Mateo, CA 94403             (650)572-2607


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google