Skip to content

Add R7RS character names as extensions #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions LOG
Original file line number Diff line number Diff line change
Expand Up @@ -2336,3 +2336,7 @@
c/foreign.c
- Propagate immutable versions of "", #(), #vu8() and #vfx() in cp0.
s/cp0.ss s/cpnanopass.ss
- add #\null and #\escape as aliases for #\nul and #\esc (R7RS compatibility)
mats/6.ms s/read.ss
- allow \| escape inside strings (R7RS compatibility)
mats/6.ms s/read.ss
7 changes: 5 additions & 2 deletions csug/objects.stex
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ Second, it recognizes several nonstandard named characters:
\scheme{#\rubout} (which is the same as \scheme{#\delete}),
\scheme{#\bel} (which is the same as \scheme{#\alarm}),
\scheme{#\vt} (which is the same as \scheme{#\vtab}),
\scheme{#\escape} (which is the same as \scheme{#\esc}),
\scheme{#\null} (which is the same as \scheme{#\nul}),
\scheme{#\nel} (the Unicode NEL character), and
\scheme{#\ls} (the Unicode LS character).
The set of nonstandard character names may be changed via the procedure
Expand Down Expand Up @@ -418,8 +420,9 @@ ASCII code for the character.

\section{Strings}

{\ChezScheme} extends the standard string syntax with two character
escapes: \scheme{\'}, which produces the single quote character, and
{\ChezScheme} extends the standard string syntax with three character
escapes: \scheme{\'}, which produces the single quote character,
\scheme{\|}, which produces the vertical bar character, and
\scheme{\\var{nnn}}, i.e., backslash followed by 3 octal digits,
which produces the character equivalent of the octal value of
the 3 digits.
Expand Down
7 changes: 7 additions & 0 deletions mats/6.ms
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,9 @@
(eqv? (char-name 'rubout) #\rubout)
(eqv? (char-name #\nul) 'nul)
(eqv? (char-name 'nul) #\nul)
(eqv? (char-name #\null) 'nul)
(eqv? (char-name 'null) #\nul)
(eqv? #\nul #\null)
(eqv? (char-name 'foo) #f)
(eqv? (char-name 'delete) #\delete)
(eqv? (char-name #\delete) 'delete)
Expand All @@ -1567,6 +1570,9 @@
(eqv? (char-name #\alarm) 'alarm)
(eqv? (char-name 'esc) #\esc)
(eqv? (char-name #\esc) 'esc)
(eqv? (char-name 'escape) #\esc)
(eqv? (char-name #\escape) 'esc)
(eqv? #\esc #\escape)
(error? (read (open-input-string "#\\foo")))
(and (eqv? (char-name 'foo #\003) (void))
(eqv? (char-name 'foo) #\003)
Expand Down Expand Up @@ -1595,6 +1601,7 @@
(eqv? (string-ref "\\\"\'" 0) #\\)
(eqv? (string-ref "\\\"\'" 1) #\")
(eqv? (string-ref "\\\"\'" 2) #\')
(eqv? (string-ref "\|\v" 0) #\|)
(= (char->integer (string-ref "a\012" 1)) #o12 10)
(= (char->integer (string-ref "a\015" 1)) #o15 13)
(= (char->integer (string-ref "a\177" 1)) #o177 127)
Expand Down
7 changes: 7 additions & 0 deletions release_notes/release_notes.stex
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ Online versions of both books can be found at
%-----------------------------------------------------------------------------
\section{Functionality Changes}\label{section:functionality}

\subsection{R7RS compatibility extensions (9.6.0)}

The reader now accepts \scheme{#\null} and \scheme{#\escape} as alternative
spellings of the characters \scheme{#\nul} and \scheme{#\esc}, respectively.

The reader now accepts \scheme{\|} inside strings.

\subsection{Unicode 14.0 Support (9.6.0)}

The character sets, character classes, and word-breaking algorithms for character, string,
Expand Down
6 changes: 6 additions & 0 deletions s/read.ss
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,10 @@
(nonstandard "\\' string character")
(with-stretch-buffer i c
(*state rd-token-string (fx+ i 1)))]
[(#\|)
(nonstandard "\\| string character")
(with-stretch-buffer i c
(*state rd-token-string (fx+ i 1)))]
[else (let ([bfp char-bfp])
(xcall rd-error #f #t "invalid string character \\~c" c))]))]
[(#\newline #\nel #\ls)
Expand Down Expand Up @@ -1892,9 +1896,11 @@
(char-name 'newline #\newline) ; must come after linefeed entry
(char-name 'backspace #\backspace)
(char-name 'rubout #\rubout)
(char-name 'null #\nul)
(char-name 'nul #\nul)
(char-name 'bel #\bel)
(char-name 'vt #\vt)
(char-name 'escape #\esc)
(char-name 'esc #\esc)
(char-name 'vtab #\vtab)
(char-name 'delete #\rubout)
Expand Down