124 lines
67 KiB
HTML
124 lines
67 KiB
HTML
|
<!doctype html>
|
|||
|
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-chap-2/c-b-character-syntax" data-has-hydrated="false">
|
|||
|
<head>
|
|||
|
<meta charset="UTF-8">
|
|||
|
<meta name="generator" content="Docusaurus v3.0.1">
|
|||
|
<title data-rh="true">2.1 Character Syntax | Common Lisp (New) Language Reference</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://lisp-docs.github.io/cl-language-reference/img/1024px-Lisp_logo.svg.png"><meta data-rh="true" name="twitter:image" content="https://lisp-docs.github.io/cl-language-reference/img/1024px-Lisp_logo.svg.png"><meta data-rh="true" property="og:url" content="https://lisp-docs.github.io/cl-language-reference/chap-2/c-b-character-syntax"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="google-site-verification" content="Vzaw013_bfdKeUVG89Ch3W1zC9_vH9ID2dPB9Dz0vr0"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="2.1 Character Syntax | Common Lisp (New) Language Reference"><meta data-rh="true" name="description" content="2.1.1 Readtables"><meta data-rh="true" property="og:description" content="2.1.1 Readtables"><link data-rh="true" rel="icon" href="../img/favicon.ico"><link data-rh="true" rel="canonical" href="c-b-character-syntax.html"><link data-rh="true" rel="alternate" href="c-b-character-syntax.html" hreflang="en"><link data-rh="true" rel="alternate" href="c-b-character-syntax.html" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://C1F2Q5VM6X-dsn.algolia.net" crossorigin="anonymous"><link rel="preconnect" href="https://www.google-analytics.com">
|
|||
|
<link rel="preconnect" href="https://www.googletagmanager.com">
|
|||
|
<script async src="https://www.googletagmanager.com/gtag/js?id=G-8TJCE4NSF8"></script>
|
|||
|
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-8TJCE4NSF8",{})</script>
|
|||
|
|
|||
|
|
|||
|
<link rel="search" type="application/opensearchdescription+xml" title="Common Lisp (New) Language Reference" href="../opensearch.xml"><link rel="stylesheet" href="../assets/css/styles.f13b59fe.css">
|
|||
|
<script src="../assets/js/runtime~main.02699c25.js" defer="defer"></script>
|
|||
|
<script src="../assets/js/main.4f0a7a76.js" defer="defer"></script>
|
|||
|
</head>
|
|||
|
<body class="navigation-with-keyboard">
|
|||
|
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"light")}(),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="c-b-character-syntax.html#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a href="../../index.html" target="_blank" rel="noopener noreferrer" class="navbar__brand"><div class="navbar__logo"><img src="../img/logo.svg" alt="Lisp Logo" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="../img/logo.svg" alt="Lisp Logo" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div><b class="navbar__title text--truncate">Common Lisp Docs</b></a><a href="../../docs/tutorial/index.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Tutorial</a><a href="../index.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Technical Reference</a><a href="../../docs/whylisp.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Why Lisp?</a><a href="../../docs/howto.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Guides</a></div><div class="navbar__items navbar__items--right"><a href="../../docs/contribute.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Contribute!</a><a href="../../docs/help.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Getting Help</a><a href="../../docs/about.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">About</a><a href="../../blog.html" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Blog</a><a href="https://github.com/lisp-docs" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><div class="toggle_vylO colorModeToggle_DEke"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type="button" disabled="" title="Switch between dark and light mode (currently light mode)" aria-label="Switch between dark and light mode (currently light mode)" aria-live="polite"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_pyhR"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.9
|
|||
|
<!-- -->
|
|||
|
<p>The <em>Lisp reader</em> takes <span><i>characters</i></span> from a <span><i>stream</i></span>, interprets them as a printed representation of an <span><i>object</i></span>, constructs that <span><i>object</i></span>, and returns it.</p>
|
|||
|
<p>The syntax described by this chapter is called the <span><i>standard syntax</i></span>. Operations are provided by Common Lisp so that various aspects of the syntax information represented by a <span><i>readtable</i></span> can be modified under program control; see Chapter 23 (Reader). Except as explicitly stated otherwise, the syntax used throughout this document is <span><i>standard syntax</i></span> .</p>
|
|||
|
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="211-readtables">2.1.1 Readtables<a href="c-b-character-syntax.html#211-readtables" class="hash-link" aria-label="Direct link to 2.1.1 Readtables" title="Direct link to 2.1.1 Readtables"></a></h2>
|
|||
|
<!-- -->
|
|||
|
<p>Syntax information for use by the <em>Lisp reader</em> is embodied in an <span><i>object</i></span> called a <span><i>readtable</i></span>. Among other things, the <span><i>readtable</i></span> contains the association between <span><i>characters</i></span> and <span><i>syntax types</i></span>.</p>
|
|||
|
<p>Figure 2–1 lists some <span><i>defined names</i></span> that are applicable to <span><i>readtables</i></span>.</p>
|
|||
|
<p>|</p><p><strong>*readtable* readtable-case</strong> </p><p><strong>copy-readtable readtablep</strong> </p><p><strong>get-dispatch-macro-character set-dispatch-macro-character get-macro-character set-macro-character</strong> </p><p><strong>make-dispatch-macro-character set-syntax-from-char</strong></p>|<p></p>
|
|||
|
<p>| :- |</p>
|
|||
|
<p><strong>Figure 2–1. Readtable defined names</strong></p>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2111-the-current-readtable">2.1.1.1 The Current Readtable<a href="c-b-character-syntax.html#2111-the-current-readtable" class="hash-link" aria-label="Direct link to 2.1.1.1 The Current Readtable" title="Direct link to 2.1.1.1 The Current Readtable"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p>Several <span><i>readtables</i></span> describing different syntaxes can exist, but at any given time only one, called the <span><i>current readtable</i></span>, affects the way in which <span><i>expressions</i></span><sub>2</sub> are parsed into <span><i>objects</i></span> by the <em>Lisp reader</em> . The <span><i>current readtable</i></span> in a given <span><i>dynamic environment</i></span> is the <span><i>value</i></span> of <span><b>*readtable*</b></span> in that <span><i>environment</i></span>. To make a different <span><i>readtable</i></span> become the <span><i>current readtable</i></span>, <span><b>*readtable*</b></span> can be <em>assigned</em> or <span><i>bound</i></span>.</p>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2112-the-standard-readtable">2.1.1.2 The Standard Readtable<a href="c-b-character-syntax.html#2112-the-standard-readtable" class="hash-link" aria-label="Direct link to 2.1.1.2 The Standard Readtable" title="Direct link to 2.1.1.2 The Standard Readtable"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p>The <span><i>standard readtable</i></span> conforms to <span><i>standard syntax</i></span> . The consequences are undefined if an attempt is made to modify the <span><i>standard readtable</i></span>. To achieve the effect of altering or extending <span><i>standard syntax</i></span> , a copy of the <span><i>standard readtable</i></span> can be created; see the <span><i>function</i></span> <span><b>copy-readtable</b></span>.</p>
|
|||
|
<p>The <span><i>readtable case</i></span> of the <span><i>standard readtable</i></span> is <!-- -->:upcase<!-- -->.</p>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2113-the-initial-readtable">2.1.1.3 The Initial Readtable<a href="c-b-character-syntax.html#2113-the-initial-readtable" class="hash-link" aria-label="Direct link to 2.1.1.3 The Initial Readtable" title="Direct link to 2.1.1.3 The Initial Readtable"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p>The <span><i>initial readtable</i></span> is the <span><i>readtable</i></span> that is the <span><i>current readtable</i></span> at the time when the <em>Lisp image</em> starts. At that time, it conforms to <span><i>standard syntax</i></span> . The <span><i>initial readtable</i></span> is <span><i>distinct</i></span> from the <span><i>standard readtable</i></span>. It is permissible for a <span><i>conforming program</i></span> to modify the <span><i>initial readtable</i></span>.</p>
|
|||
|
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="212-variables-that-affect-the-lisp-reader">2.1.2 Variables that affect the Lisp Reader<a href="c-b-character-syntax.html#212-variables-that-affect-the-lisp-reader" class="hash-link" aria-label="Direct link to 2.1.2 Variables that affect the Lisp Reader" title="Direct link to 2.1.2 Variables that affect the Lisp Reader"></a></h2>
|
|||
|
<!-- -->
|
|||
|
<p>The <em>Lisp reader</em> is influenced not only by the <span><i>current readtable</i></span>, but also by various <span><i>dynamic variables</i></span>. Figure 2–2 lists the <span><i>variables</i></span> that influence the behavior of the <em>Lisp reader</em> .</p>
|
|||
|
<p>|<strong>*package* *read-default-float-format* *readtable* *read-base* *read-suppress*</strong>|</p>
|
|||
|
<p>| :- |</p>
|
|||
|
<p><strong>Figure 2–2. Variables that influence the Lisp reader.</strong></p>
|
|||
|
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="213-standard-characters">2.1.3 Standard Characters<a href="c-b-character-syntax.html#213-standard-characters" class="hash-link" aria-label="Direct link to 2.1.3 Standard Characters" title="Direct link to 2.1.3 Standard Characters"></a></h2>
|
|||
|
<!-- -->
|
|||
|
<p>All <span><i>implementations</i></span> must support a <em>character repertoire</em> called <span><b>standard-char</b></span>; <span><i>characters</i></span> that are members of that <span><i>repertoire</i></span> are called <span><i>standard characters</i></span>.</p>
|
|||
|
<p>The <span><b>standard-char</b></span> <span><i>repertoire</i></span> consists of the <em>non-graphic character newline</em>, the <em>graphic character space</em>, and the following additional ninety-four <em>graphic characters</em> or their equivalents:</p>
|
|||
|
<p>|<strong>Graphic ID Glyph Description Graphic ID Glyph Description</strong>|</p>
|
|||
|
<p>| -: |</p>
|
|||
|
<p>|LA01 a small a LN01 n small n LA02 A capital A LN02 N capital N LB01 b small b LO01 o small o LB02 B capital B LO02 O capital O LC01 c small c LP01 p small p LC02 C capital C LP02 P capital P LD01 d small d LQ01 q small q LD02 D capital D LQ02 Q capital Q LE01 e small e LR01 r small r LE02 E capital E LR02 R capital R LF01 f small f LS01 s small s LF02 F capital F LS02 S capital S LG01 g small g LT01 t small t LG02 G capital G LT02 T capital T LH01 h small h LU01 u small u LH02 H capital H LU02 U capital U LI01 i small i LV01 v small v LI02 I capital I LV02 V capital V LJ01 j small j LW01 w small w LJ02 J capital J LW02 W capital W LK01 k small k LX01 x small x LK02 K capital K LX02 X capital X LL01 l small l LY01 y small y LL02 L capital L LY02 Y capital Y LM01 m small m LZ01 z small z LM02 M capital M LZ02 Z capital Z|</p>
|
|||
|
<p><strong>Figure 2–3. Standard Character Subrepertoire (Part 1 of 3: Latin Characters)</strong></p>
|
|||
|
<p>|<strong>Graphic ID Glyph Description Graphic ID Glyph Description</strong>|</p>
|
|||
|
<p>| -: |</p>
|
|||
|
<p>|ND01 1 digit 1 ND06 6 digit 6 ND02 2 digit 2 ND07 7 digit 7 ND03 3 digit 3 ND08 8 digit 8 ND04 4 digit 4 ND09 9 digit 9 ND05 5 digit 5 ND10 0 digit 0|</p>
|
|||
|
<p><strong>Figure 2–4. Standard Character Subrepertoire (Part 2 of 3: Numeric Characters)</strong></p>
|
|||
|
<p>|<strong>Graphic ID Glyph Description</strong>|</p>
|
|||
|
<p>| :- |</p>
|
|||
|
<p>|</p><p>SP02 ! exclamation mark </p><p>SC03 $ dollar sign </p><p>SP04 " quotation mark, or double quote SP05 ’ apostrophe, or [single] quote </p><p>SP06 ( left parenthesis, or open parenthesis SP07 ) right parenthesis, or close parenthesis SP08 , comma </p><p>SP09 low line, or underscore </p><p>SP10 - hyphen, or minus [sign] </p><p>SP11 . full stop, period, or dot </p><p>SP12 / solidus, or slash </p><p>SP13 : colon </p><p>SP14 ; semicolon </p><p>SP15 ? question mark </p><p>SA01 + plus [sign] </p><p>SA03 < less-than [sign] </p><p>SA04 = equals [sign] </p><p>SA05 > greater-than [sign] </p><p>SM01 # number sign, or sharp[sign] </p><p>SM02 % percent [sign] </p><p>SM03 & ampersand </p><p>SM04 * asterisk, or star </p><p>SM05 @ commercial at, or at-sign </p><p>SM06 [ left [square] bracket </p><p>SM07 \ reverse solidus, or backslash </p><p>SM08 ] right [square] bracket </p><p>SM11 { left curly bracket, or left brace </p><p>SM13 | vertical bar </p><p>SM14 } right curly bracket, or right brace SD13 ‘ grave accent, or backquote </p><p>SD15 <i><sup>∧</sup></i> circumflex accent </p><p>SD19 ~ tilde</p>|<p></p>
|
|||
|
<p><strong>Figure 2–5. Standard Character Subrepertoire (Part 3 of 3: Special Characters)</strong></p>
|
|||
|
<p>The graphic IDs are not used within Common Lisp, but are provided for cross reference purposes with ISO 6937/2. Note that the first letter of the graphic ID categorizes the character as follows: L—Latin, N—Numeric, S—Special.</p>
|
|||
|
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="214-character-syntax-types">2.1.4 Character Syntax Types<a href="c-b-character-syntax.html#214-character-syntax-types" class="hash-link" aria-label="Direct link to 2.1.4 Character Syntax Types" title="Direct link to 2.1.4 Character Syntax Types"></a></h2>
|
|||
|
<!-- -->
|
|||
|
<p>The <em>Lisp reader</em> constructs an <span><i>object</i></span> from the input text by interpreting each <span><i>character</i></span> according to its <span><i>syntax type</i></span>. The <em>Lisp reader</em> cannot accept as input everything that the <em>Lisp printer</em></p>
|
|||
|
<p>produces, and the <em>Lisp reader</em> has features that are not used by the <em>Lisp printer</em> . The <em>Lisp reader</em> can be used as a lexical analyzer for a more general user-written parser.</p>
|
|||
|
<p>When the <em>Lisp reader</em> is invoked, it reads a single character from the <em>input stream</em> and dispatches according to the <span><i>syntax type</i></span> of that <span><i>character</i></span> . Every <span><i>character</i></span> that can appear in the <em>input stream</em> is of one of the <span><i>syntax types</i></span> shown in Figure 2–6.</p>
|
|||
|
<p>|</p><p><em>constituent macro character single escape</em> </p><p><em>invalid multiple escape whitespace</em><sub>2</sub></p>|<p></p>
|
|||
|
<p>| :- |</p>
|
|||
|
<p><strong>Figure 2–6. Possible Character Syntax Types</strong></p>
|
|||
|
<p>The <span><i>syntax type</i></span> of a <span><i>character</i></span> in a <span><i>readtable</i></span> determines how that character is interpreted by the <em>Lisp reader</em> while that <span><i>readtable</i></span> is the <span><i>current readtable</i></span>. At any given time, every character has exactly one <span><i>syntax type</i></span>.</p>
|
|||
|
<p>Figure 2–7 lists the <span><i>syntax type</i></span> of each <span><i>character</i></span> in <span><i>standard syntax</i></span> .</p>
|
|||
|
<p>|<strong>character syntax type character syntax type</strong>|</p>
|
|||
|
<p>| :- |</p>
|
|||
|
<p>|Backspace <i>constituent</i> 0–9 <i>constituent</i> Tab <i>whitespace</i><sub>2</sub> : <i>constituent</i> Newline <i>whitespace</i><sub>2</sub> ; <i>terminating macro char</i> Linefeed <i>whitespace</i><sub>2</sub> < <i>constituent</i> Page <i>whitespace</i><sub>2</sub> = <i>constituent</i> Return <i>whitespace</i><sub>2</sub> > <i>constituent</i> Space <i>whitespace</i><sub>2</sub> ? <i>constituent</i>* ! <i>constituent</i>* @ <i>constituent</i> " <i>terminating macro char</i> A–Z <i>constituent</i> # <i>non-terminating macro char</i> [ <i>constituent</i>* $ <i>constituent</i> \ <i>single escape</i> % <i>constituent</i> ] <i>constituent</i>* & <i>constituent <sup>∧</sup> constituent</i> ’ <i>terminating macro char constituent</i> ( <i>terminating macro char</i> ‘ <i>terminating macro char</i> ) <i>terminating macro char</i> a–z <i>constituent</i> * <i>constituent</i> { <i>constituent</i>* + <i>constituent</i> | <i>multiple escape</i> , <i>terminating macro char</i> } <i>constituent</i>* - <i>constituent</i> ~ <i>constituent</i> . <i>constituent</i> Rubout <i>constituent</i> / <i>constituent</i>|</p>
|
|||
|
<p><strong>Figure 2–7. Character Syntax Types in Standard Syntax</strong></p>
|
|||
|
<p>The characters marked with an asterisk (*) are initially <span><i>constituents</i></span>, but they are not used in any standard Common Lisp notations. These characters are explicitly reserved to the <span><i>programmer</i></span> . ~ is not used in Common Lisp, and reserved to implementors. $ and % are <span><i>alphabetic</i></span><sub>2</sub> <span><i>characters</i></span>, but are not used in the names of any standard Common Lisp <span><i>defined names</i></span>.</p>
|
|||
|
<p><span><i>Whitespace</i></span><sub>2</sub> characters serve as separators but are otherwise ignored. <span><i>Constituent</i></span> and <em>escape characters</em> are accumulated to make a <span><i>token</i></span>, which is then interpreted as a <span><i>number</i></span> or <span><i>symbol</i></span>. <span><i>Macro characters</i></span> trigger the invocation of <span><i>functions</i></span> (possibly user-supplied) that can perform arbitrary parsing actions. <span><i>Macro characters</i></span> are divided into two kinds, <span><i>terminating</i></span> and <em>non</em></p>
|
|||
|
<p><span><i>terminating</i></span>, depending on whether or not they terminate a <span><i>token</i></span>. The following are descriptions of each kind of <span><i>syntax type</i></span>.</p>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2141-constituent-characters">2.1.4.1 Constituent Characters<a href="c-b-character-syntax.html#2141-constituent-characters" class="hash-link" aria-label="Direct link to 2.1.4.1 Constituent Characters" title="Direct link to 2.1.4.1 Constituent Characters"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p><em>Constituent characters</em> are used in <span><i>tokens</i></span>. A <span><i>token</i></span> is a representation of a <span><i>number</i></span> or a <span><i>symbol</i></span>. Examples of <em>constituent characters</em> are letters and digits.</p>
|
|||
|
<p>Letters in symbol names are sometimes converted to letters in the opposite <span><i>case</i></span> when the name is read; see Section 23.1.2 (Effect of Readtable Case on the Lisp Reader). <span><i>Case</i></span> conversion can be suppressed by the use of <span><i>single escape</i></span> or <span><i>multiple escape</i></span> characters.</p>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2142-constituent-traits">2.1.4.2 Constituent Traits<a href="c-b-character-syntax.html#2142-constituent-traits" class="hash-link" aria-label="Direct link to 2.1.4.2 Constituent Traits" title="Direct link to 2.1.4.2 Constituent Traits"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p>Every <span><i>character</i></span> has one or more <span><i>constituent traits</i></span> that define how the <span><i>character</i></span> is to be interpreted by the <em>Lisp reader</em> when the <span><i>character</i></span> is a <em>constituent character</em> . These <span><i>constituent traits</i></span> are <span><i>alphabetic</i></span><sub>2</sub>, digit, <span><i>package marker</i></span> , plus sign, minus sign, dot, decimal point, <span><i>ratio marker</i></span> , <span><i>exponent marker</i></span> , and <span><i>invalid</i></span>. Figure 2–8 shows the <span><i>constituent traits</i></span> of the <span><i>standard characters</i></span> and of certain <em>semi-standard characters</em>; no mechanism is provided for changing the <span><i>constituent trait</i></span> of a <span><i>character</i></span> . Any <span><i>character</i></span> with the alphadigit <span><i>constituent trait</i></span> in that figure is a digit if the <span><i>current input base</i></span> is greater than that character’s digit value, otherwise the <span><i>character</i></span> is <span><i>alphabetic</i></span><sub>2</sub>. Any <span><i>character</i></span> quoted by a <span><i>single escape</i></span> is treated as an <span><i>alphabetic</i></span><sub>2</sub> constituent, regardless of its normal syntax.</p>
|
|||
|
<p>|</p><p><strong>constituent traits constituent traits</strong> </p><p><strong>character character</strong></p>|<p></p>
|
|||
|
<p>| :- |</p>
|
|||
|
<p>|</p><p>Backspace <span><i>invalid</i></span> { <span><i>alphabetic</i></span><sub>2</sub> </p><p>Tab <span><i>invalid</i></span>* } <span><i>alphabetic</i></span><sub>2</sub> </p><p>Newline <span><i>invalid</i></span>* + <span><i>alphabetic</i></span><sub>2</sub>, plus sign Linefeed <span><i>invalid</i></span>* - <span><i>alphabetic</i></span><sub>2</sub>, minus sign Page <span><i>invalid</i></span>* . <span><i>alphabetic</i></span><sub>2</sub>, dot, decimal point Return <span><i>invalid</i></span>* / <span><i>alphabetic</i></span><sub>2</sub>, <span><i>ratio marker</i></span> Space <span><i>invalid</i></span>* A, a alphadigit </p><p>! <span><i>alphabetic</i></span><sub>2</sub> B, b alphadigit </p><p>" <span><i>alphabetic</i></span><sub>2</sub>* C, c alphadigit </p><p># <span><i>alphabetic</i></span><sub>2</sub>* D, d alphadigit, double-float <span><i>exponent marker</i></span> $ <span><i>alphabetic</i></span><sub>2</sub> E, e alphadigit, float <span><i>exponent marker</i></span> % <span><i>alphabetic</i></span><sub>2</sub> F, f alphadigit, single-float <span><i>exponent marker</i></span> & <span><i>alphabetic</i></span><sub>2</sub> G, g alphadigit </p><p>’ <span><i>alphabetic</i></span><sub>2</sub>* H, h alphadigit </p><p>( <span><i>alphabetic</i></span><sub>2</sub>* I, i alphadigit </p><p>) <span><i>alphabetic</i></span><sub>2</sub>* J, j alphadigit </p><p>* <span><i>alphabetic</i></span><sub>2</sub> K, k alphadigit </p><p>, <span><i>alphabetic</i></span><sub>2</sub>* L, l alphadigit, long-float <span><i>exponent marker</i></span> 0-9 alphadigit M, m alphadigit </p><p>: <span><i>package marker</i></span> N, n alphadigit </p><p>; <span><i>alphabetic</i></span><sub>2</sub>* O, o alphadigit </p><p>< <span><i>alphabetic</i></span><sub>2</sub> P, p alphadigit </p><p>= <span><i>alphabetic</i></span><sub>2</sub> Q, q alphadigit </p><p>> <span><i>alphabetic</i></span><sub>2</sub> R, r alphadigit </p><p>? <span><i>alphabetic</i></span><sub>2</sub> S, s alphadigit, short-float <span><i>exponent marker</i></span> @ <span><i>alphabetic</i></span><sub>2</sub> T, t alphadigit </p><p>[ <span><i>alphabetic</i></span><sub>2</sub> U, u alphadigit </p><p>\ <span><i>alphabetic</i></span><sub>2</sub>* V, v alphadigit </p><p>] <span><i>alphabetic</i></span><sub>2</sub> W, w alphadigit </p><p><i><sup>∧</sup> alphabetic</i><sub>2</sub> X, x alphadigit </p><p><span><i>alphabetic</i></span><sub>2</sub> Y, y alphadigit </p><p>‘ <span><i>alphabetic</i></span><sub>2</sub>* Z, z alphadigit </p><p>| <span><i>alphabetic</i></span><sub>2</sub>* Rubout <span><i>invalid</i></span> </p><p>~ <span><i>alphabetic</i></span><sub>2</sub></p>|<p></p>
|
|||
|
<p><strong>Figure 2–8. Constituent Traits of Standard Characters and Semi-Standard Characters</strong></p>
|
|||
|
<p>The interpretations in this table apply only to <span><i>characters</i></span> whose <span><i>syntax type</i></span> is <span><i>constituent</i></span>. Entries marked with an asterisk (*) are normally <em>shadowed</em> <sub>2</sub> because the indicated <span><i>characters</i></span> are of <em>syntax type whitespace</em><sub>2</sub>, <span><i>macro character</i></span> , <span><i>single escape</i></span>, or <span><i>multiple escape</i></span>; these <span><i>constituent traits</i></span> apply to them only if their <span><i>syntax types</i></span> are changed to <span><i>constituent</i></span>.</p>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2143-invalid-characters">2.1.4.3 Invalid Characters<a href="c-b-character-syntax.html#2143-invalid-characters" class="hash-link" aria-label="Direct link to 2.1.4.3 Invalid Characters" title="Direct link to 2.1.4.3 Invalid Characters"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p><span><i>Characters</i></span> with the <em>constituent trait invalid</em> cannot ever appear in a <span><i>token</i></span> except under the control of a <em>single escape character</em> . If an <em>invalid character</em> is encountered while an <span><i>object</i></span> is being read, an error of <span><i>type</i></span> <span><b>reader-error</b></span> is signaled. If an <em>invalid character</em> is preceded by a <em>single escape character</em> , it is treated as an <span><i>alphabetic</i></span><sub>2</sub> <span><i>constituent</i></span> instead.</p>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2144-macro-characters">2.1.4.4 Macro Characters<a href="c-b-character-syntax.html#2144-macro-characters" class="hash-link" aria-label="Direct link to 2.1.4.4 Macro Characters" title="Direct link to 2.1.4.4 Macro Characters"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p>When the <em>Lisp reader</em> encounters a <span><i>macro character</i></span> on an <em>input stream</em>, special parsing of subsequent <span><i>characters</i></span> on the <em>input stream</em> is performed.</p>
|
|||
|
<p>A <span><i>macro character</i></span> has an associated <span><i>function</i></span> called a <span><i>reader macro function</i></span> that implements its specialized parsing behavior. An association of this kind can be established or modified under control of a <span><i>conforming program</i></span> by using the <span><i>functions</i></span> <span><b>set-macro-character</b></span> and <strong>set-dispatch-macro-character</strong>.</p>
|
|||
|
<p>Upon encountering a <span><i>macro character</i></span> , the <em>Lisp reader</em> calls its <span><i>reader macro function</i></span>, which parses one specially formatted object from the <em>input stream</em>. The <span><i>function</i></span> either returns the parsed <span><i>object</i></span>, or else it returns no <span><i>values</i></span> to indicate that the characters scanned by the <span><i>function</i></span> are being ignored (<em>e.g.</em>, in the case of a comment). Examples of <span><i>macro characters</i></span> are <span><i>backquote</i></span>, <span><i>single-quote</i></span>, <span><i>left-parenthesis</i></span>, and <span><i>right-parenthesis</i></span>.</p>
|
|||
|
<p>A <span><i>macro character</i></span> is either <span><i>terminating</i></span> or <span><i>non-terminating</i></span>. The difference between <span><i>terminating</i></span> and <em>non-terminating macro characters</em> lies in what happens when such characters occur in the middle of a <span><i>token</i></span>. If a <em>non-terminating macro character</em> occurs in the middle of a <span><i>token</i></span>, the <span><i>function</i></span> associated with the <em>non-terminating macro character</em> is not called, and the <em>non terminating macro character</em> does not terminate the <span><i>token</i></span>’s name; it becomes part of the name as if the <span><i>macro character</i></span> were really a constituent character. A <em>terminating macro character</em> terminates any <span><i>token</i></span>, and its associated <span><i>reader macro function</i></span> is called no matter where the <span><i>character</i></span> appears. The only <em>non-terminating macro character</em> in <span><i>standard syntax</i></span> is <span><i>sharpsign</i></span>.</p>
|
|||
|
<p>If a <span><i>character</i></span> is a <em>dispatching macro character C</em><sub>1</sub>, its <span><i>reader macro function</i></span> is a <span><i>function</i></span> supplied by the <span><i>implementation</i></span>. This <span><i>function</i></span> reads decimal <em>digit characters</em> until a non-<em>digit C</em><sub>2</sub> is read. If any <span><i>digits</i></span> were read, they are converted into a corresponding <em>integer</em> infix parameter <em>P</em>; otherwise, the infix parameter <em>P</em> is <span><b>nil</b></span>. The terminating non-<em>digit C</em><sub>2</sub> is a <span><i>character</i></span> (sometimes called a “sub-character” to emphasize its subordinate role in the dispatching) that is looked up in the dispatch table associated with the <em>dispatching macro character C</em><sub>1</sub>. The <span><i>reader macro function</i></span> associated with the sub-character <em>C</em><sub>2</sub> is invoked with three arguments: the <span><i>stream</i></span>, the sub-character <em>C</em><sub>2</sub>, and the infix parameter <em>P</em>. For more information about dispatch characters, see the <span><i>function</i></span> <strong>set-dispatch-macro-character</strong>.</p>
|
|||
|
<p>For information about the <span><i>macro characters</i></span> that are available in <span><i>standard syntax</i></span> , see Section 2.4 (Standard Macro Characters).</p>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2145-multiple-escape-characters">2.1.4.5 Multiple Escape Characters<a href="c-b-character-syntax.html#2145-multiple-escape-characters" class="hash-link" aria-label="Direct link to 2.1.4.5 Multiple Escape Characters" title="Direct link to 2.1.4.5 Multiple Escape Characters"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p>A pair of <em>multiple escape characters</em> is used to indicate that an enclosed sequence of characters, including possible <span><i>macro characters</i></span> and <span><i>whitespace</i></span><sub>2</sub> <span><i>characters</i></span>, are to be treated as <span><i>alphabetic</i></span><sub>2</sub> <span><i>characters</i></span> with <span><i>case</i></span> preserved. Any <span><i>single escape</i></span> and <em>multiple escape characters</em> that are to appear in the sequence must be preceded by a <em>single escape character</em> .</p>
|
|||
|
<p><span><i>Vertical-bar</i></span> is a <em>multiple escape character</em> in <span><i>standard syntax</i></span> .</p>
|
|||
|
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="21451-examples-of-multiple-escape-characters">2.1.4.5.1 Examples of Multiple Escape Characters<a href="c-b-character-syntax.html#21451-examples-of-multiple-escape-characters" class="hash-link" aria-label="Direct link to 2.1.4.5.1 Examples of Multiple Escape Characters" title="Direct link to 2.1.4.5.1 Examples of Multiple Escape Characters"></a></h4>
|
|||
|
<!-- -->
|
|||
|
<div class="language-lisp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-lisp codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token comment" style="color:#999988;font-style:italic">;; The following examples assume the readtable case of \*readtable\* </span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">;; and \*print-case\* are both :upcase. </span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">eq</span><span class="token plain"> ’abc ’ABC</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → true </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">eq</span><span class="token plain"> ’abc ’|ABC|</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → true </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">eq</span><span class="token plain"> ’abc ’a|B|c</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → true </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">eq</span><span class="token plain"> ’abc ’|abc|</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → false </span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2146-single-escape-character">2.1.4.6 Single Escape Character<a href="c-b-character-syntax.html#2146-single-escape-character" class="hash-link" aria-label="Direct link to 2.1.4.6 Single Escape Character" title="Direct link to 2.1.4.6 Single Escape Character"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p>A <span><i>single escape</i></span> is used to indicate that the next <span><i>character</i></span> is to be treated as an <span><i>alphabetic</i></span><sub>2</sub> <span><i>character</i></span> with its <span><i>case</i></span> preserved, no matter what the <span><i>character</i></span> is or which <span><i>constituent traits</i></span> it has.</p>
|
|||
|
<p><span><i>Backslash</i></span> is a <em>single escape character</em> in <span><i>standard syntax</i></span> .</p>
|
|||
|
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="21461-examples-of-single-escape-characters">2.1.4.6.1 Examples of Single Escape Characters<a href="c-b-character-syntax.html#21461-examples-of-single-escape-characters" class="hash-link" aria-label="Direct link to 2.1.4.6.1 Examples of Single Escape Characters" title="Direct link to 2.1.4.6.1 Examples of Single Escape Characters"></a></h4>
|
|||
|
<!-- -->
|
|||
|
<div class="language-lisp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-lisp codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token comment" style="color:#999988;font-style:italic">;; The following examples assume the readtable case of \*readtable\* </span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">;; and \*print-case\* are both :upcase. </span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">eq</span><span class="token plain"> ’abc ’\A\B\C</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → true </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">eq</span><span class="token plain"> ’abc ’a\Bc</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → true </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">eq</span><span class="token plain"> ’abc ’\ABC</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → true </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">eq</span><span class="token plain"> ’abc ’\abc</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → false </span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
|
|||
|
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2147-whitespace-characters">2.1.4.7 Whitespace Characters<a href="c-b-character-syntax.html#2147-whitespace-characters" class="hash-link" aria-label="Direct link to 2.1.4.7 Whitespace Characters" title="Direct link to 2.1.4.7 Whitespace Characters"></a></h3>
|
|||
|
<!-- -->
|
|||
|
<p><span><i>Whitespace</i></span><sub>2</sub> <span><i>characters</i></span> are used to separate <span><i>tokens</i></span>.</p>
|
|||
|
<p><span><i>Space</i></span> and <span><i>newline</i></span> are <span><i>whitespace</i></span><sub>2</sub> <span><i>characters</i></span> in <span><i>standard syntax</i></span> .</p>
|
|||
|
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="21471-examples-of-whitespace-characters">2.1.4.7.1 Examples of Whitespace Characters<a href="c-b-character-syntax.html#21471-examples-of-whitespace-characters" class="hash-link" aria-label="Direct link to 2.1.4.7.1 Examples of Whitespace Characters" title="Direct link to 2.1.4.7.1 Examples of Whitespace Characters"></a></h4>
|
|||
|
<!-- -->
|
|||
|
<!-- -->
|
|||
|
<div class="language-lisp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-lisp codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">(</span><span class="token car">length</span><span class="token plain"> ’</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">this-that</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → </span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">length</span><span class="token plain"> ’</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">this</span><span class="token plain"> - that</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → </span><span class="token number" style="color:#36acaa">3</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">length</span><span class="token plain"> ’</span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">a</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> b</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → </span><span class="token number" style="color:#36acaa">2</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">+</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">34</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → </span><span class="token number" style="color:#36acaa">34</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">(</span><span class="token car">+</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">3</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">4</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> → </span><span class="token number" style="color:#36acaa">7</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/lis
|
|||
|
</body>
|
|||
|
</html>
|