Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

BNF for Common Lisp Grammar.

瀏覽次數:2,606 次
跳到第一則未讀訊息

clio

未讀,
2001年11月6日 晚上8:39:482001/11/6
收件者:
Hi,

Is there any documents about BNF(EBNF) of the Common Lisp Grammar? Does
somebody know where I can find them.

Thanks!

clio

Kent M Pitman

未讀,
2001年11月7日 清晨5:48:502001/11/7
收件者:
clio <wan...@auburn.edu> writes:

> Is there any documents about BNF(EBNF) of the Common Lisp Grammar? Does
> somebody know where I can find them.

CLHS 1.4.1 Notation Conventions

Tim Bradshaw

未讀,
2001年11月7日 清晨7:48:082001/11/7
收件者:
clio <wan...@auburn.edu> wrote in message news:<3BE890E4...@auburn.edu>...

> Hi,
>
> Is there any documents about BNF(EBNF) of the Common Lisp Grammar? Does
> somebody know where I can find them.
>

I don't think such a thing can exist, or be useful if it does. CL is
both `lexically' and `grammatically' extensible, so a static BNF for
it is not really viable.

For instance, consider this:

(foo (((crun . 4))) (5 crun) (2 4) (otherwise 10))

Is this legal CL? Well, it's not a function call, that's for sure,
but whether it is legal depends on whether FOO has some macro
definition which makes this syntax legal, and that depends on the
context.

You might want to restrict yourself to what READ accepts, and not
worry about whether it is actually legal CL or not. But even here you
run into problems. Is this legal CL?

<def :name foo
:arguments (&body forms)
:strip-grut :both
:attributes ((bgcolor "white"))
:result (expand-foo-body forms bgcolor)
<def :name title-string
:result "Title of my foo">>

It certainly isn't in a `cold' CL but it may well be with a suitable
readtable.

So I think that CL is just too flexible and user-programmable to be
described by something as rigid as a BNF grammar.

--tim

Erik Naggum

未讀,
2001年11月7日 上午8:59:322001/11/7
收件者:
* clio <wan...@auburn.edu>

| Is there any documents about BNF(EBNF) of the Common Lisp Grammar?

No. There is no such thing. Common Lisp has a programmable syntax.
E.g., <foo bar> would be two symbols named "<FOO" and "BAR>" in the
standard readtable, but a Common Lisp program could easily implement a
reader macro that turned it into the equivalent of XML <foo>bar</foo> or
whatever that has caused to be represented in memory. If you want to
read Common Lisp code or data, it takes you less time to write code in
Common Lisp that reads it and spits it out in some dreadfully inferior
syntax that you can hack in, say, Perl, than writing the reader in Perl.

///
--
Norway is now run by a priest from the fundamentalist Christian People's
Party, the fifth largest party representing one eighth of the electorate.
--
Carrying a Swiss Army pocket knife in Oslo, Norway, is a criminal offense.

0 則新訊息