[uim-commit] r2301 - in branches/r5rs/sigscheme: . test

yamaken at freedesktop.org yamaken at freedesktop.org
Thu Dec 1 01:00:14 PST 2005


Author: yamaken
Date: 2005-12-01 00:59:54 -0800 (Thu, 01 Dec 2005)
New Revision: 2301

Modified:
   branches/r5rs/sigscheme/read.c
   branches/r5rs/sigscheme/test/test-syntax.scm
Log:
* sigscheme/read.c
  - (read_sexpression): Simplify

* sigscheme/test/test-syntax.scm
  - Add comment about test result


Modified: branches/r5rs/sigscheme/read.c
===================================================================
--- branches/r5rs/sigscheme/read.c	2005-12-01 08:39:37 UTC (rev 2300)
+++ branches/r5rs/sigscheme/read.c	2005-12-01 08:59:54 UTC (rev 2301)
@@ -48,11 +48,6 @@
  * SigScheme.  -- YamaKen 2005-09-05
  */
 
-/*
- * FIXME: Parse properly as defined in "7.1.1 Lexical structure" of R5RS, and
- * use the popular words for parser as used in R5RS, such as 'token'.
- */
-
 /*=======================================
   System Include
 =======================================*/
@@ -201,12 +196,11 @@
 
 static ScmObj read_sexpression(ScmObj port)
 {
-    int c  = 0;
-    int c1 = 0;
+    int c;
 
     CDBG((SCM_DBG_PARSER, "read_sexpression"));
 
-    while (1) {
+    for (;;) {
         c = skip_comment_and_space(port);
 
         CDBG((SCM_DBG_PARSER, "read_sexpression c = %c", c));
@@ -215,37 +209,44 @@
         case '(':
             DISCARD_LOOKAHEAD(port);
             return read_list(port, ')');
+
         case '\"':
             DISCARD_LOOKAHEAD(port);
             return read_string(port);
+
         case '0': case '1': case '2': case '3': case '4':
         case '5': case '6': case '7': case '8': case '9':
         case '+': case '-': case '.': case '@':
-            SCM_PORT_UNGETC(port, c);
             return read_number_or_symbol(port);
+
         case '\'':
             DISCARD_LOOKAHEAD(port);
             return read_quote(port, SYM_QUOTE);
+
         case '`':
             DISCARD_LOOKAHEAD(port);
             return read_quote(port, SYM_QUASIQUOTE);
+
         case ',':
             DISCARD_LOOKAHEAD(port);
-            c1 = SCM_PORT_PEEK_CHAR(port);
-            if (c1 == EOF) {
-                SigScm_Error("EOF in unquote");
-            } else if (c1 == '@') {
+            c = SCM_PORT_PEEK_CHAR(port);
+            switch (c) {
+            case EOF:
+                ERR("EOF in unquote");
+                /* NOTREACHED */
+
+            case '@':
                 DISCARD_LOOKAHEAD(port);
                 return read_quote(port, SYM_UNQUOTE_SPLICING);
-            } else {
-                SCM_PORT_UNGETC(port, c1);
+
+            default:
                 return read_quote(port, SYM_UNQUOTE);
             }
-            break;
+
         case '#':
             DISCARD_LOOKAHEAD(port);
-            c1 = SCM_PORT_GET_CHAR(port);
-            switch (c1) {
+            c = SCM_PORT_GET_CHAR(port);
+            switch (c) {
             case 't':
                 return SCM_TRUE;
             case 'f':
@@ -255,21 +256,22 @@
             case '\\':
                 return read_char(port);
             case 'b': case 'o': case 'd': case 'x':
-                return read_number(port, c1);
+                return read_number(port, c);
             case EOF:
-                SigScm_Error("end in #");
+                ERR("EOF in #");
             default:
-                SigScm_Error("Unsupported # : %c", c1);
+                ERR("Unsupported # notation: %c", c);
             }
             break;
-        /* Error sequence */
+
         case ')':
-            SigScm_Error("invalid close parenthesis");
-            break;
+            ERR("invalid close parenthesis");
+            /* NOTREACHED */
+
         case EOF:
             return SCM_EOF;
+
         default:
-            SCM_PORT_UNGETC(port, c);
             return read_symbol(port);
         }
     }
@@ -534,11 +536,6 @@
     return sym;
 }
 
-/*
- * FIXME: Parse properly as defined in "7.1.1 Lexical structure" of R5RS. For
- * example, 1+ is not a valid identifier and should be rejected to prevent
- * introducing unintended R5RS-incompatibility.
- */
 static ScmObj read_number_or_symbol(ScmObj port)
 {
     int c, str_len;

Modified: branches/r5rs/sigscheme/test/test-syntax.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-syntax.scm	2005-12-01 08:39:37 UTC (rev 2300)
+++ branches/r5rs/sigscheme/test/test-syntax.scm	2005-12-01 08:59:54 UTC (rev 2301)
@@ -35,6 +35,8 @@
 
 (load "./test/unittest.scm")
 
+;; All tests in this file are passed against r2300 (new repository)
+
 ;; See "7.1 Formal syntax" of R5RS
 
 (assert-parse-error "invalid boolean" "#F")



More information about the uim-commit mailing list