From: Julian Graham <joolean@gmail.com>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: r6rs incompatibilities
Date: Sun, 23 May 2010 11:35:29 -0400 [thread overview]
Message-ID: <AANLkTilDJKm0H8zlT2GAKLyUrIplWrQt86G5eWMImddW@mail.gmail.com> (raw)
In-Reply-To: <m3ljbd1swt.fsf@pobox.com>
[-- Attachment #1: Type: text/plain, Size: 483 bytes --]
Hello again!
> * I'm sure there are other points -- please test and reply :)
Indeed!
One thing I noticed while look at Andreas' `wak' project is that the
use of `#!r6rs' seems to be pretty common, which conflicts with
Guile's support for SCSH-style block comments. Find attached a
(somewhat inelegant) patch that adds support for the `#!r6rs' lexeme
in the default reader. (What do people think about this? Is there a
better way to do it?)
Regards,
Julian
[-- Attachment #2: 0001-Support-for-the-r6rs-lexeme.patch --]
[-- Type: text/x-diff, Size: 2729 bytes --]
From f1af40142b47232e726cbe9f7bdc35d5fbf45602 Mon Sep 17 00:00:00 2001
From: Julian Graham <julian.graham@aya.yale.edu>
Date: Sun, 23 May 2010 11:24:59 -0400
Subject: [PATCH] Support for the #!r6rs lexeme.
* libguile/read.c (scm_read_shebang): New function;
(scm_read_sharp): Call scm_read_shebang on '!', which delegates to
scm_read_scsh_block_comment as necessary.
---
libguile/read.c | 39 +++++++++++++++++++++++++++++++++++++--
1 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/libguile/read.c b/libguile/read.c
index c54fbb6..d169167 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -189,6 +189,7 @@ static SCM *scm_read_hash_procedures;
static inline SCM scm_read_scsh_block_comment (scm_t_wchar, SCM);
static SCM scm_read_r6rs_block_comment (scm_t_wchar, SCM);
static SCM scm_read_commented_expression (scm_t_wchar, SCM);
+static SCM scm_read_shebang (scm_t_wchar, SCM);
static SCM scm_get_hash_procedure (int);
/* Read from PORT until a delimiter (e.g., a whitespace) is read. Put the
@@ -309,7 +310,7 @@ flush_ws (SCM port, const char *eoferr)
eoferr = "read_sharp";
goto goteof;
case '!':
- scm_read_scsh_block_comment (c, port);
+ scm_read_shebang (c, port);
break;
case ';':
scm_read_commented_expression (c, port);
@@ -1109,6 +1110,40 @@ scm_read_scsh_block_comment (scm_t_wchar chr, SCM port)
return SCM_UNSPECIFIED;
}
+static inline SCM
+scm_read_shebang (scm_t_wchar chr, SCM port)
+{
+ int c = 0;
+ if ((c = scm_get_byte_or_eof (port)) != 'r')
+ {
+ scm_ungetc (c, port);
+ return scm_read_scsh_block_comment (chr, port);
+ }
+ if ((c = scm_get_byte_or_eof (port)) != '6')
+ {
+ scm_ungetc (c, port);
+ scm_ungetc ('r', port);
+ return scm_read_scsh_block_comment (chr, port);
+ }
+ if ((c = scm_get_byte_or_eof (port)) != 'r')
+ {
+ scm_ungetc (c, port);
+ scm_ungetc ('6', port);
+ scm_ungetc ('r', port);
+ return scm_read_scsh_block_comment (chr, port);
+ }
+ if ((c = scm_get_byte_or_eof (port)) != 's')
+ {
+ scm_ungetc (c, port);
+ scm_ungetc ('r', port);
+ scm_ungetc ('6', port);
+ scm_ungetc ('r', port);
+ return scm_read_scsh_block_comment (chr, port);
+ }
+
+ return SCM_UNSPECIFIED;
+}
+
static SCM
scm_read_r6rs_block_comment (scm_t_wchar chr, SCM port)
{
@@ -1323,7 +1358,7 @@ scm_read_sharp (scm_t_wchar chr, SCM port)
case '{':
return (scm_read_extended_symbol (chr, port));
case '!':
- return (scm_read_scsh_block_comment (chr, port));
+ return (scm_read_shebang (chr, port));
case ';':
return (scm_read_commented_expression (chr, port));
case '`':
--
1.7.0.4
next prev parent reply other threads:[~2010-05-23 15:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-21 9:54 r6rs incompatibilities Andy Wingo
2010-05-21 12:47 ` Julian Graham
2010-05-21 17:15 ` Andy Wingo
2010-05-23 15:35 ` Julian Graham [this message]
2010-05-23 16:02 ` Mike Gran
2010-05-23 17:24 ` Julian Graham
2010-05-23 20:52 ` Andy Wingo
2010-05-23 21:26 ` Andy Wingo
2010-05-26 13:02 ` Julian Graham
2010-05-26 13:21 ` Andy Wingo
2010-05-26 16:43 ` Ludovic Courtès
2010-05-27 8:06 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTilDJKm0H8zlT2GAKLyUrIplWrQt86G5eWMImddW@mail.gmail.com \
--to=joolean@gmail.com \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).