[uim-commit] r2345 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Sat Dec 3 14:39:41 PST 2005
Author: yamaken
Date: 2005-12-03 14:39:35 -0800 (Sat, 03 Dec 2005)
New Revision: 2345
Modified:
branches/r5rs/sigscheme/read.c
Log:
* sigscheme/read.c
- Reorder functions. No actual code is changed
Modified: branches/r5rs/sigscheme/read.c
===================================================================
--- branches/r5rs/sigscheme/read.c 2005-12-03 22:18:34 UTC (rev 2344)
+++ branches/r5rs/sigscheme/read.c 2005-12-03 22:39:35 UTC (rev 2345)
@@ -85,20 +85,20 @@
static void read_sequence(ScmObj port, char *buf, int len);
static size_t read_token(ScmObj port, int *err,
char *buf, size_t buf_size, const char *delim);
+
+static ScmObj read_sexpression(ScmObj port);
+static ScmObj read_list(ScmObj port, int closeParen);
#if SCM_USE_SRFI75
static int parse_unicode_sequence(const char *seq, int len);
static int read_unicode_sequence(ScmObj port, char prefix);
#endif
-
-static ScmObj read_sexpression(ScmObj port);
-static ScmObj read_list(ScmObj port, int closeParen);
static ScmObj read_char(ScmObj port);
static ScmObj read_string(ScmObj port);
static ScmObj read_symbol(ScmObj port);
+static ScmObj read_number_or_symbol(ScmObj port);
static ScmObj parse_number(ScmObj port,
char *buf, size_t buf_size, char prefix);
static ScmObj read_number(ScmObj port, char prefix);
-static ScmObj read_number_or_symbol(ScmObj port);
static ScmObj read_quote(ScmObj port, ScmObj quoter);
/*=======================================
@@ -176,6 +176,54 @@
buf[len] = '\0';
}
+static size_t read_token(ScmObj port, int *err,
+ char *buf, size_t buf_size, const char *delim)
+{
+ int c;
+ size_t len;
+ char *p;
+
+ for (p = buf;;) {
+ c = SCM_PORT_PEEK_CHAR(port);
+ CDBG((SCM_DBG_PARSER, "c = %c", c));
+
+ if (p == buf) {
+ if (c == EOF)
+ ERR("unexpected EOF at a token");
+ } else {
+ if (strchr(delim, c) || c == EOF) {
+ *err = OK;
+ break;
+ }
+ }
+
+ if (isascii(c)) {
+ if (p == &buf[buf_size - sizeof((char)'\0')]) {
+ *err = TOKEN_BUF_EXCEEDED;
+ break;
+ }
+ *p++ = c;
+ } else {
+#if SCM_USE_SRFI75
+ if (&buf[buf_size] <= p + SCM_MB_MAX_LEN) {
+ *err = TOKEN_BUF_EXCEEDED;
+ break;
+ }
+ /* FIXME: check Unicode capability of Scm_current_char_codec */
+ p = SCM_CHARCODEC_INT2STR(Scm_current_char_codec,
+ p, c, SCM_MB_STATELESS);
+#else
+ ERR("non-ASCII char in token: 0x%x", c);
+#endif
+ }
+ DISCARD_LOOKAHEAD(port);
+ }
+
+ *p = '\0';
+ len = p - buf;
+ return len;
+}
+
static ScmObj read_sexpression(ScmObj port)
{
int c;
@@ -576,72 +624,6 @@
return read_symbol(port);
}
-static size_t read_token(ScmObj port, int *err,
- char *buf, size_t buf_size, const char *delim)
-{
- int c;
- size_t len;
- char *p;
-
- for (p = buf;;) {
- c = SCM_PORT_PEEK_CHAR(port);
- CDBG((SCM_DBG_PARSER, "c = %c", c));
-
- if (p == buf) {
- if (c == EOF)
- ERR("unexpected EOF at a token");
- } else {
- if (strchr(delim, c) || c == EOF) {
- *err = OK;
- break;
- }
- }
-
- if (isascii(c)) {
- if (p == &buf[buf_size - sizeof((char)'\0')]) {
- *err = TOKEN_BUF_EXCEEDED;
- break;
- }
- *p++ = c;
- } else {
-#if SCM_USE_SRFI75
- if (&buf[buf_size] <= p + SCM_MB_MAX_LEN) {
- *err = TOKEN_BUF_EXCEEDED;
- break;
- }
- /* FIXME: check Unicode capability of Scm_current_char_codec */
- p = SCM_CHARCODEC_INT2STR(Scm_current_char_codec,
- p, c, SCM_MB_STATELESS);
-#else
- ERR("non-ASCII char in token: 0x%x", c);
-#endif
- }
- DISCARD_LOOKAHEAD(port);
- }
-
- *p = '\0';
- len = p - buf;
- return len;
-}
-
-static ScmObj read_quote(ScmObj port, ScmObj quoter)
-{
- return SCM_LIST_2(quoter, read_sexpression(port));
-}
-
-static ScmObj read_number(ScmObj port, char prefix)
-{
- int err;
- size_t len;
- char buf[INT_LITERAL_LEN_MAX + sizeof((char)'\0')];
-
- len = read_token(port, &err, buf, sizeof(buf), DELIMITER_CHARS);
- if (err == TOKEN_BUF_EXCEEDED)
- ERR("invalid number literal");
-
- return parse_number(port, buf, sizeof(buf), prefix);
-}
-
/* reads 'b123' part of #b123 */
static ScmObj parse_number(ScmObj port,
char *buf, size_t buf_size, char prefix)
@@ -667,3 +649,21 @@
err:
ERR("ill-formatted number: #%c%s", prefix, buf);
}
+
+static ScmObj read_number(ScmObj port, char prefix)
+{
+ int err;
+ size_t len;
+ char buf[INT_LITERAL_LEN_MAX + sizeof((char)'\0')];
+
+ len = read_token(port, &err, buf, sizeof(buf), DELIMITER_CHARS);
+ if (err == TOKEN_BUF_EXCEEDED)
+ ERR("invalid number literal");
+
+ return parse_number(port, buf, sizeof(buf), prefix);
+}
+
+static ScmObj read_quote(ScmObj port, ScmObj quoter)
+{
+ return SCM_LIST_2(quoter, read_sexpression(port));
+}
More information about the uim-commit
mailing list