1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/02_ce.htm
2024-04-01 10:24:07 +02:00

55 lines
9.1 KiB
HTML

<!-- 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 2.3.5</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="02_cd.htm">
<LINK REL=UP HREF="02_c.htm">
<LINK REL=NEXT HREF="02_cf.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="02_cd.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="02_c.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="02_cf.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
2.3.5 Valid Patterns for Tokens</H2> <P>
The valid patterns for <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>tokens</I></A> are summarized in the next figure. <P>
<PRE>
nnnnn a <A REL=DEFINITION HREF="26_glo_n.htm#number">number</A>
xxxxx a <A REL=DEFINITION HREF="26_glo_s.htm#symbol">symbol</A> in the <A REL=DEFINITION HREF="26_glo_c.htm#current_package">current package</A>
:xxxxx a <A REL=DEFINITION HREF="26_glo_s.htm#symbol">symbol</A> in the the KEYWORD package
ppppp:xxxxx an <A REL=DEFINITION HREF="26_glo_e.htm#external_symbol">external symbol</A> in the ppppp <A REL=DEFINITION HREF="26_glo_p.htm#package">package</A>
ppppp::xxxxx a (possibly internal) <A REL=DEFINITION HREF="26_glo_s.htm#symbol">symbol</A> in the ppppp <A REL=DEFINITION HREF="26_glo_p.htm#package">package</A>
:nnnnn undefined
ppppp:nnnnn undefined
ppppp::nnnnn undefined
::aaaaa undefined
aaaaa: undefined
aaaaa:aaaaa:aaaaa undefined
</PRE>
<P><B>Figure 2-17. Valid patterns for tokens</B> <P>
Note that <I>nnnnn</I> has number syntax, neither <I>xxxxx</I> nor <I>ppppp</I> has number syntax, and <I>aaaaa</I> has any syntax. <P>
A summary of rules concerning <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package markers</I></A> follows. In each case, examples are offered to illustrate the case; for presentational simplicity, the examples assume that the <A REL=DEFINITION HREF="26_glo_r.htm#readtable_case"><I>readtable case</I></A> of the <A REL=DEFINITION HREF="26_glo_c.htm#current_readtable"><I>current readtable</I></A> is <TT>:upcase</TT>. <P>
<P><DL><DT>1. If there is a single <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package marker</I></A>, and it occurs at the beginning of the <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A>, then the <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> is interpreted as a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> in the <TT>KEYWORD</TT> package. It also sets the <A REL=DEFINITION HREF="f_symb_5.htm#symbol-value"><B>symbol-value</B></A> of the newly-created <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> to that same <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> so that the <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> will self-evaluate. <P><DD>
For example, <TT>:bar</TT>, when read, interns <TT>BAR</TT> as an <A REL=DEFINITION HREF="26_glo_e.htm#external_symbol"><I>external symbol</I></A> in the <TT>KEYWORD</TT> package. <P>
<DT>2. If there is a single <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package marker</I></A> not at the beginning or end of the <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A>, then it divides the <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> into two parts. The first part specifies a <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A>; the second part is the name of an <A REL=DEFINITION HREF="26_glo_e.htm#external_symbol"><I>external symbol</I></A> available in that package. <P><DD>
For example, <TT>foo:bar</TT>, when read, looks up <TT>BAR</TT> among the <A REL=DEFINITION HREF="26_glo_e.htm#external_symbol"><I>external symbols</I></A> of the <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> named <TT>FOO</TT>. <P>
<DT>3. If there are two adjacent <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package markers</I></A> not at the beginning or end of the <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A>, then they divide the <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> into two parts. The first part specifies a <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A>; the second part is the name of a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> within that <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> (possibly an <A REL=DEFINITION HREF="26_glo_i.htm#internal_symbol"><I>internal symbol</I></A>). <P><DD>
For example, <TT>foo::bar</TT>, when read, interns <TT>BAR</TT> in the <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> named <TT>FOO</TT>. <P>
<DT>4. If the <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> contains no <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package markers</I></A>, and does not have <A REL=DEFINITION HREF="26_glo_p.htm#potential_number"><I>potential number</I></A> syntax, then the entire <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> is the name of the <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. The <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> is looked up in the <A REL=DEFINITION HREF="26_glo_c.htm#current_package"><I>current package</I></A>. <P><DD>
For example, <TT>bar</TT>, when read, interns <TT>BAR</TT> in the <A REL=DEFINITION HREF="26_glo_c.htm#current_package"><I>current package</I></A>. <P>
<DT>5. The consequences are unspecified if any other pattern of <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package markers</I></A> in a <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> is used. All other uses of <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package markers</I></A> within names of <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbols</I></A> are not defined by this standard but are reserved for <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A> use. <P><DD></DL><P>
For example, assuming the <A REL=DEFINITION HREF="26_glo_r.htm#readtable_case"><I>readtable case</I></A> of the <A REL=DEFINITION HREF="26_glo_c.htm#current_readtable"><I>current readtable</I></A> is <TT>:upcase</TT>, <TT>editor:buffer</TT> refers to the <A REL=DEFINITION HREF="26_glo_e.htm#external_symbol"><I>external symbol</I></A> named <TT>BUFFER</TT> present in the <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> named <TT>editor</TT>, regardless of whether there is a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> named <TT>BUFFER</TT> in the <A REL=DEFINITION HREF="26_glo_c.htm#current_package"><I>current package</I></A>. If there is no <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> named <TT>editor</TT>, or if no <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> named <TT>BUFFER</TT> is present in <TT>editor</TT>, or if <TT>BUFFER</TT> is not exported by <TT>editor</TT>, the reader signals a correctable error. If <TT>editor::buffer</TT> is seen, the effect is exactly the same as reading <TT>buffer</TT> with the <TT>EDITOR</TT> package being the <A REL=DEFINITION HREF="26_glo_c.htm#current_package"><I>current package</I></A>. <P>
<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>