From: Hovig Heghinian
Subject: Lisp BNF available?
Date: 
Message-ID: <CLp2rM.828@sparc0a.cs.uiuc.edu>
   I would like a BNF grammar for Lisp.  It need not be complete; it
is only for the cursory lexical analysis, but then again it mustn't
be overly simple, either, like those sometimes in educational sources.

-- 
Hovig Heghinian                             | `To associate the word
Department of Computer Science              |  fuzzy with the word
University of Illinois at Urbana-Champaign  |  logic is shocking.'
·····@cs.uiuc.edu                           |   -- Arnold Kaufman, 1975  

From: Barry Margolin
Subject: Re: Lisp BNF available?
Date: 
Message-ID: <2kiqv6INNboq@early-bird.think.com>
In article <··········@sparc0a.cs.uiuc.edu> ·····@cs.uiuc.edu writes:
>   I would like a BNF grammar for Lisp.  It need not be complete; it
>is only for the cursory lexical analysis, but then again it mustn't
>be overly simple, either, like those sometimes in educational sources.

Here's a grammar for a Lisp subset that we used in a project here; this is
yacc source with the actions omitted.

start		:
		| s_exp
		;

s_exp		: atom
		| list
		| ERROR error
		;

atom		: NUMBER
		| SYMBOL
		| STRING
		;

list		: '(' ')'
		| '(' s_exp_list ')'
		| '(' s_exp_list '.' s_exp ')'
    		| '\'' s_exp
		| SHARP_QUOTE s_exp
		;

s_exp_list	: s_exp
		| s_exp_list s_exp
		;

Here are some comments by the author:

Hope it helps.  With yacc, the difficulty typically isn't in coming up
with the grammar, it's in coming up with the actions that accompany it;
and the appropriate actions are very problem dependent.

For many languages the lexer is very simple; for lisp it's a bit more
compilicated.  For my parser much of the "magic" was in the lexer; the
actions were very simple.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar
From: Hovig Heghinian
Subject: Re: Lisp BNF available?
Date: 
Message-ID: <CLr7Eu.1AA@sparc0a.cs.uiuc.edu>
······@think.com (Barry Margolin) writes:
>Here's a grammar for a Lisp subset that we used in a project here; this is
>yacc source with the actions omitted.

   [ ... ]

>Hope it helps.  With yacc, the difficulty typically isn't in coming up
>with the grammar, it's in coming up with the actions that accompany it;
>and the appropriate actions are very problem dependent.
>
>For many languages the lexer is very simple; for lisp it's a bit more
>compilicated.  For my parser much of the "magic" was in the lexer; the
>actions were very simple.

   Hmm.  Just the opposite of what I thought.  I was actually
looking for just the lex part here....  I posted before specifying
as much, sorry.
-- 
Hovig Heghinian                             | `To associate the word
Department of Computer Science              |  fuzzy with the word
University of Illinois at Urbana-Champaign  |  logic is shocking.'
·····@cs.uiuc.edu                           |   -- Arnold Kaufman, 1975  
From: Barry Margolin
Subject: Re: Lisp BNF available?
Date: 
Message-ID: <2l0h84INN3t3@early-bird.think.com>
In article <··········@sparc0a.cs.uiuc.edu> ·····@cs.uiuc.edu writes:
>······@think.com (Barry Margolin) writes:
>>For many languages the lexer is very simple; for lisp it's a bit more
>>compilicated.  For my parser much of the "magic" was in the lexer; the
>>actions were very simple.
>
>   Hmm.  Just the opposite of what I thought.  I was actually
>looking for just the lex part here....  I posted before specifying
>as much, sorry.

Our lexer is written in C.

The author of the grammar I sent earlier has put his entire Lisp-parsing
package in our anonymous FTP area.  It's on ftp.think.com in
users/taylor/lisp-parser.tar.gz (compressed with gzip).  The lexer is
written in C, not with a lexer generator.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar