83 lines
12 KiB
HTML
83 lines
12 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.1.4</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_ac.htm">
|
|
<LINK REL=UP HREF="02_a.htm">
|
|
<LINK REL=NEXT HREF="02_ada.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_ac.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="02_a.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="02_ada.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<H2>
|
|
2.1.4 Character Syntax Types</H2> <P>
|
|
The <A REL=DEFINITION HREF="26_glo_l.htm#lisp_reader"><I>Lisp reader</I></A> constructs an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> from the input text by interpreting each <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>character</I></A> according to its <A REL=DEFINITION HREF="26_glo_s.htm#syntax_type"><I>syntax type</I></A>. The <A REL=DEFINITION HREF="26_glo_l.htm#lisp_reader"><I>Lisp reader</I></A> cannot accept as input everything that the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_printer"><I>Lisp printer</I></A> produces, and the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_reader"><I>Lisp reader</I></A> has features that are not used by the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_printer"><I>Lisp printer</I></A>. The <A REL=DEFINITION HREF="26_glo_l.htm#lisp_reader"><I>Lisp reader</I></A> can be used as a lexical analyzer for a more general user-written parser. <P>
|
|
When the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_reader"><I>Lisp reader</I></A> is invoked, it reads a single character from the <A REL=DEFINITION HREF="26_glo_i.htm#input"><I>input</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> and dispatches according to the <A REL=DEFINITION HREF="26_glo_s.htm#syntax_type"><I>syntax type</I></A> of that <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>character</I></A>. Every <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>character</I></A> that can appear in the <A REL=DEFINITION HREF="26_glo_i.htm#input"><I>input</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> is of one of the <A REL=DEFINITION HREF="26_glo_s.htm#syntax_type"><I>syntax types</I></A> shown in <A REL=DEFINITION HREF="#possiblesyntaxtypes">Figure 2-6</A>. <P>
|
|
<A NAME="possiblesyntaxtypes"> <PRE>
|
|
<A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro_character">macro character</A> <A REL=DEFINITION HREF="26_glo_s.htm#single_escape">single escape</A>
|
|
<A REL=DEFINITION HREF="26_glo_i.htm#invalid">invalid</A> <A REL=DEFINITION HREF="26_glo_m.htm#multiple_escape">multiple escape</A> <A REL=DEFINITION HREF="26_glo_w.htm#whitespace">whitespace</A>[2]
|
|
</PRE>
|
|
<P><B>Figure 2-6. Possible Character Syntax Types</B></A> <P>
|
|
The <A REL=DEFINITION HREF="26_glo_s.htm#syntax_type"><I>syntax type</I></A> of a <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>character</I></A> in a <A REL=DEFINITION HREF="26_glo_r.htm#readtable"><I>readtable</I></A> determines how that character is interpreted by the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_reader"><I>Lisp reader</I></A> while that <A REL=DEFINITION HREF="26_glo_r.htm#readtable"><I>readtable</I></A> is the <A REL=DEFINITION HREF="26_glo_c.htm#current_readtable"><I>current readtable</I></A>. At any given time, every character has exactly one <A REL=DEFINITION HREF="26_glo_s.htm#syntax_type"><I>syntax type</I></A>. <P>
|
|
<A REL=DEFINITION HREF="#charsyntaxtypesinstdsyntax">Figure 2-7</A> lists the <A REL=DEFINITION HREF="26_glo_s.htm#syntax_type"><I>syntax type</I></A> of each <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>character</I></A> in <A REL=DEFINITION HREF="26_glo_s.htm#standard_syntax"><I>standard syntax</I></A>. <P>
|
|
<A NAME="charsyntaxtypesinstdsyntax"> <PRE>
|
|
character syntax type character syntax type
|
|
Backspace <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> 0--9 <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
Tab <A REL=DEFINITION HREF="26_glo_w.htm#whitespace">whitespace</A>[2] : <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
Newline <A REL=DEFINITION HREF="26_glo_w.htm#whitespace">whitespace</A>[2] ; <A REL=DEFINITION HREF="26_glo_t.htm#terminating">terminating</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro">macro</A> <A REL=DEFINITION HREF="f_char_.htm#char">char</A>
|
|
Linefeed <A REL=DEFINITION HREF="26_glo_w.htm#whitespace">whitespace</A>[2] < <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
Page <A REL=DEFINITION HREF="26_glo_w.htm#whitespace">whitespace</A>[2] = <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
Return <A REL=DEFINITION HREF="26_glo_w.htm#whitespace">whitespace</A>[2] > <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
Space <A REL=DEFINITION HREF="26_glo_w.htm#whitespace">whitespace</A>[2] ? <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>*
|
|
! <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>* @ <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
" <A REL=DEFINITION HREF="26_glo_t.htm#terminating">terminating</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro">macro</A> <A REL=DEFINITION HREF="f_char_.htm#char">char</A> A--Z <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
# <A REL=DEFINITION HREF="26_glo_n.htm#non-terminating">non-terminating</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro">macro</A> <A REL=DEFINITION HREF="f_char_.htm#char">char</A> [ <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>*
|
|
$ <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> \ <A REL=DEFINITION HREF="26_glo_s.htm#single_escape">single escape</A>
|
|
% <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> ] <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>*
|
|
& <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> ^ <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
' <A REL=DEFINITION HREF="26_glo_t.htm#terminating">terminating</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro">macro</A> <A REL=DEFINITION HREF="f_char_.htm#char">char</A> _ <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
( <A REL=DEFINITION HREF="26_glo_t.htm#terminating">terminating</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro">macro</A> <A REL=DEFINITION HREF="f_char_.htm#char">char</A> ` <A REL=DEFINITION HREF="26_glo_t.htm#terminating">terminating</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro">macro</A> <A REL=DEFINITION HREF="f_char_.htm#char">char</A>
|
|
) <A REL=DEFINITION HREF="26_glo_t.htm#terminating">terminating</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro">macro</A> <A REL=DEFINITION HREF="f_char_.htm#char">char</A> a--z <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
* <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> { <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>*
|
|
+ <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> | <A REL=DEFINITION HREF="26_glo_m.htm#multiple_escape">multiple escape</A>
|
|
, <A REL=DEFINITION HREF="26_glo_t.htm#terminating">terminating</A> <A REL=DEFINITION HREF="26_glo_m.htm#macro">macro</A> <A REL=DEFINITION HREF="f_char_.htm#char">char</A> } <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>*
|
|
- <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> ~ <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
. <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A> Rubout <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
/ <A REL=DEFINITION HREF="26_glo_c.htm#constituent">constituent</A>
|
|
</PRE>
|
|
<P><B>Figure 2-7. Character Syntax Types in Standard Syntax</B></A> <P>
|
|
The characters marked with an asterisk (*) are initially <A REL=DEFINITION HREF="26_glo_c.htm#constituent"><I>constituents</I></A>, but they are not used in any standard Common Lisp notations. These characters are explicitly reserved to the <A REL=DEFINITION HREF="26_glo_p.htm#programmer"><I>programmer</I></A>. <TT>~</TT> is not used in Common Lisp, and reserved to implementors. <TT>$</TT> and <TT>%</TT> are <A REL=DEFINITION HREF="26_glo_a.htm#alphabetic"><I>alphabetic</I></A>[2] <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A>, but are not used in the names of any standard Common Lisp <A REL=DEFINITION HREF="26_glo_d.htm#defined_name"><I>defined names</I></A>. <P>
|
|
<A REL=DEFINITION HREF="26_glo_w.htm#whitespace"><I>Whitespace</I></A>[2] characters serve as separators but are otherwise ignored. <A REL=DEFINITION HREF="26_glo_c.htm#constituent"><I>Constituent</I></A> and <A REL=DEFINITION HREF="26_glo_e.htm#escape"><I>escape</I></A> <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A> are accumulated to make a <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A>, which is then interpreted as a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A> or <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>. <A REL=DEFINITION HREF="26_glo_m.htm#macro_character"><I>Macro characters</I></A> trigger the invocation of <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>functions</I></A> (possibly user-supplied) that can perform arbitrary parsing actions. <A REL=DEFINITION HREF="26_glo_m.htm#macro_character"><I>Macro characters</I></A> are divided into two kinds, <A REL=DEFINITION HREF="26_glo_t.htm#terminating"><I>terminating</I></A> and <A REL=DEFINITION HREF="26_glo_n.htm#non-terminating"><I>non-terminating</I></A>, depending on whether or not they terminate a <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A>. The following are descriptions of each kind of <A REL=DEFINITION HREF="26_glo_s.htm#syntax_type"><I>syntax type</I></A>. <P>
|
|
|
|
|
|
<A REL=CHILD HREF="02_ada.htm"><H2>
|
|
2.1.4.1 Constituent Characters</H2></A><P>
|
|
|
|
<A REL=CHILD HREF="02_adc.htm"><H2>
|
|
2.1.4.3 Invalid Characters</H2></A><P>
|
|
|
|
<A REL=CHILD HREF="02_add.htm"><H2>
|
|
2.1.4.4 Macro Characters</H2></A><P>
|
|
|
|
<A REL=CHILD HREF="02_ade.htm"><H2>
|
|
2.1.4.5 Multiple Escape Characters</H2></A><P>
|
|
|
|
<A REL=CHILD HREF="02_adf.htm"><H2>
|
|
2.1.4.6 Single Escape Character</H2></A><P>
|
|
|
|
<A REL=CHILD HREF="02_adg.htm"><H2>
|
|
2.1.4.7 Whitespace Characters</H2></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>
|