chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Add support for R7RS named characters and stri


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Add support for R7RS named characters and string escapes (except hex escapes)
Date: Sun, 26 May 2013 23:09:30 +0200
User-agent: Mutt/1.4.2.3i

Hi all,

Here are two patches for adding R7RS named character and string escapes
sequences.  Turns out the r7rs-tasks wiki page is incorrect; we already
had "\a" and #\alarm support.  The only two standard named characters
that needed to be added was #\null (where we had #\nul) and #\escape
where we had #\esc, and the strings only need hex escapes and "escaped
indentation" support.

The new character names are now the preferred way to print #\x00 and
#\x1b for WRITE and friends.  This means that CHICKEN's s-expression
output can be READ by R7RS Schemes.  Only, older CHICKENs can't read
s-expressions output by newer ones.  IMHO this does not require a
Change Request because it does not strictly break backwards
compatibility: newer chickens can still read s-expressions output by
older chickens, and any program will continue working as it has before.

For the backslash escapes inside strings, we already had everything
that R7RS dictates, except for two things: hex escapes and 
\<intraline whitespace>*<newline><intraline whitespace>* syntax.
I think the former is useful, but it's rather tricky so I want to
take my time implementing it.  The latter is silly and rather pointless,
but I've implemented it for completeness.

Note that Chibi's behavior seems to be incorrect wrt to the spec.
The string: "\    
   
 
x" should be read like "\n\nx", I think.  Chibi drops all the
whitespace and newlines, instead of just the whitespace surrounding
the *first* newline.  I've made Chicken follow what I think is what
the spec says.

There's also escaped strings without newlines like "\    foo".
It's unspecified what an implementation should do with that, like
any other escaped character (like, for example, "\p").  Chibi also
simply collapses the whitespace away, and I've decided to follow
this behaviour, but to make our handling of this more consistent with
how we handle other undefined escape sequences, it also shows a
read-warning.  I did not add tests for this because it's unspecified
and nobody should be relying on this.

Cheers,
Peter
-- 
http://www.more-magic.net

Attachment: 0001-Added-null-and-escape-character-literal-names-for-R7.patch
Description: Text document

Attachment: 0002-Add-support-for-R7RS-s-indented-string-escape-syntax.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]