Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site aquila.UUCP Path: utzoo!dciem!aquila!chris From: chris@aquila.UUCP (chris) Newsgroups: net.lang.lisp Subject: Re: A BNF for Lisp Message-ID: <63@aquila.UUCP> Date: Mon, 18-Nov-85 11:28:49 EST Article-I.D.: aquila.63 Posted: Mon Nov 18 11:28:49 1985 Date-Received: Mon, 18-Nov-85 16:10:30 EST References: <60@aquila.UUCP> <68@nbs-amrf.UUCP> Reply-To: chris@aquila.UUCP () Lines: 36 Summary: I never though a BNF for Lisp would generate so much Net traffic! As some people have commented, the grammar I posted cannot handle S-expressions of the form ( a . b . c ) -- changes were posted to do this. Remember that what I posted was a BNF description of a grammar! A BNF deals with tokens and productions; it is not concerned with lexical analysis, or even Lisp read macros! An ATOM is any non-list Lisp object; it can be an integer, a string, even an escaped symbol name (which may contain suitably quoted parantheses, like |this (is an) atom|. Non-lisp programmers would certainly find this last example confusing (imagine a C variable named 'if (x > 0) exit(1)'), but the intent is clear to Lisp programmers. hopp@nbs-amrf.UUCP (Ted Hopp) has been chasing a red herring when he expects a grammar description to deal with issues of scanning as well as parsing; he further confuses himself with premature concern for evaluation of the read form. The BNF is not concerned with EVALUATION -- if you don't understand this, then go away and read a compiler book. Read macros can safely be ignored by the BNF because they ARE macros; the Lisp reader still gets (after macro processing) a valid sequence of tokens that is handled by the BNF. That is, 'A ==> (quote A). (Q.E.D.) (And don't tell me about back-quote; `(a b ,c ,@d ...) is an EVALUATION mechanism. The Reader produces something like (back-quote (a b (comma a) (comma-at d) ...)), which is a valid form for later EVALUATION). Note that just because Lisp places the read macro handling in the reader does not mean it has to be there; as C programmers know, macro scanning can be done in another program entirely so long as valid code is produced. Of course, the Lisp macros are more powerful because they ARE in the language; however, this greater power is rarely used. An example would be a read macro that generates different code depending on the value of some other Lisp symbol; such a macro would be confusing to debug and dangerous to use in most cases. You can write one if you want to try convince me of its utility. Chris Retterath ( ..!dciem!aquila!chris ) Consensys Corporation.