1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/01_daba.htm

87 lines
4.9 KiB
HTML
Raw Normal View History

2024-04-01 10:24:07 +02:00
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Section 1.4.1.2.1</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="01_dab.htm">
<LINK REL=UP HREF="01_dab.htm">
<LINK REL=NEXT HREF="01_dabb.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="01_dab.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="01_dab.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="01_dabb.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
1.4.1.2.1 Splicing in Modified BNF Syntax</H2> <P>
The primary extension used is the following: <P>
<P> [[O]]<P> <P>
An expression of this form appears whenever a list of elements is to be spliced into a larger structure and the elements can appear in any order. The symbol O represents a description of the syntax of some number of syntactic elements to be spliced; that description must be of the form <P>
<P> O1 | ... | Ol<P> <P>
where each Oi can be of the form S or of the form S* or of the form {S}1 . The expression [[O]] means that a list of the form <P>
<P> (Oi1...Oij) 1&lt;=j<P> <P>
is spliced into the enclosing expression, such that if n /=m and 1&lt;=n,m&lt;=j, then either Oin/=Oim or Oin = Oim = Qk, where for some 1&lt;=k &lt;=n, Ok is of the form Qk*. Furthermore, for each Oin that is of the form {Qk}1 , that element is required to appear somewhere in the list to be spliced. <P>
For example, the expression <P>
<TT>(x </TT>[[<TT>A </TT>|<TT> B</TT>*<TT> </TT>|<TT> C</TT>]]<TT> y)</TT> <P>
means that at most one <TT>A</TT>, any number of <TT>B</TT>'s, and at most one <TT>C</TT> can occur in any order. It is a description of any of these: <P>
<PRE>
(x y)
(x B A C y)
(x A B B B B B C y)
(x C B A B B B y)
</PRE>
</TT> <P>
but not any of these: <P>
<PRE>
(x B B A A C C y)
(x C B C y)
</PRE>
</TT> <P>
In the first case, both <TT>A</TT> and <TT>C</TT> appear too often, and in the second case <TT>C</TT> appears too often. <P>
<P>
The notation [[O1 | O2 | ...]]+ adds the additional restriction that at least one item from among the possible choices must be used. For example: <P>
<TT>(x </TT>[[<TT>A </TT>|<TT> B</TT>*<TT> </TT>|<TT> C</TT>]]<TT></TT>+<TT> y)</TT> <P>
means that at most one <TT>A</TT>, any number of <TT>B</TT>'s, and at most one <TT>C</TT> can occur in any order, but that in any case at least one of these options must be selected. It is a description of any of these: <P>
<PRE>
(x B y)
(x B A C y)
(x A B B B B B C y)
(x C B A B B B y)
</PRE>
</TT> <P>
but not any of these: <P>
<PRE>
(x y)
(x B B A A C C y)
(x C B C y)
</PRE>
</TT> <P>
In the first case, no item was used; in the second case, both <TT>A</TT> and <TT>C</TT> appear too often; and in the third case <TT>C</TT> appears too often. <P>
Also, the expression: <P>
<TT>(x </TT>[[<TT></TT>{<TT>A</TT>}1 <TT> </TT>|<TT> </TT>{<TT>B</TT>}1 <TT> </TT>|<TT> C</TT>]]<TT> y)</TT> <P>
can generate exactly these and no others: <P>
<PRE>
(x A B C y)
(x A C B y)
(x A B y)
(x B A C y)
(x B C A y)
(x B A y)
(x C A B y)
(x C B A y)
</PRE>
</TT> <P>
<P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issue</A>, <I>not part of the specification</I>, applies to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss223.htm">LOOP-MISCELLANEOUS-REPAIRS:FIX</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>