OSDN Git Service

first commit
authorJunSuzuki <randy@mvd.biglobe.ne.jp>
Thu, 18 Apr 2013 01:32:19 +0000 (10:32 +0900)
committerJunSuzuki <randy@mvd.biglobe.ne.jp>
Thu, 18 Apr 2013 01:32:19 +0000 (10:32 +0900)
106 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new symlink]
ChangeLog [new file with mode: 0644]
INSTALL [new symlink]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
doc/tutorial/index.txt [new file with mode: 0644]
doc/tutorial/tutorial.txt [new file with mode: 0644]
src/Array.cpp [new file with mode: 0644]
src/Assign.cpp [new file with mode: 0644]
src/Base64.cpp [new file with mode: 0644]
src/Bool.cpp [new file with mode: 0644]
src/Byte.cpp [new file with mode: 0644]
src/CR_LF.cpp [new file with mode: 0644]
src/Char.cpp [new file with mode: 0644]
src/Closure.cpp [new file with mode: 0644]
src/DBBase.cpp [new file with mode: 0644]
src/Database.cpp [new file with mode: 0644]
src/Datatype.cpp [new file with mode: 0644]
src/Date.cpp [new file with mode: 0644]
src/DateTime.cpp [new file with mode: 0644]
src/Dir.cpp [new file with mode: 0644]
src/EucJPRW.cpp [new file with mode: 0644]
src/Except.cpp [new file with mode: 0644]
src/Expr.cpp [new file with mode: 0644]
src/File.cpp [new file with mode: 0644]
src/Func.cpp [new file with mode: 0644]
src/Handler.cpp [new file with mode: 0644]
src/ISO2022JP.cpp [new file with mode: 0644]
src/If.cpp [new file with mode: 0644]
src/Int.cpp [new file with mode: 0644]
src/Japanese.cpp [new file with mode: 0644]
src/Lexer.cpp [new file with mode: 0644]
src/List.cpp [new file with mode: 0644]
src/Load.cpp [new file with mode: 0644]
src/Loop.cpp [new file with mode: 0644]
src/Makefile [new file with mode: 0644]
src/Makefile.in [new file with mode: 0644]
src/Makefile.linux [new file with mode: 0644]
src/Makefile.osx [new file with mode: 0644]
src/Mutex.cpp [new file with mode: 0644]
src/NameSpace.cpp [new file with mode: 0644]
src/Nil.cpp [new file with mode: 0644]
src/Object.cpp [new file with mode: 0644]
src/Prim.cpp [new file with mode: 0644]
src/RAW.cpp [new file with mode: 0644]
src/RW.cpp [new file with mode: 0644]
src/Real.cpp [new file with mode: 0644]
src/SendMsg.cpp [new file with mode: 0644]
src/SjisRW.cpp [new file with mode: 0644]
src/Socket.cpp [new file with mode: 0644]
src/String.cpp [new file with mode: 0644]
src/Symbol.cpp [new file with mode: 0644]
src/Thread.cpp [new file with mode: 0644]
src/Time.cpp [new file with mode: 0644]
src/Tuple.cpp [new file with mode: 0644]
src/URLEncode.cpp [new file with mode: 0644]
src/Word.cpp [new file with mode: 0644]
src/configure [new file with mode: 0755]
src/configure.in [new file with mode: 0644]
src/pack.sp [new file with mode: 0644]
src/parser.ypp [new file with mode: 0644]
src/soopy.cpp [new file with mode: 0644]
src/soopy.h [new file with mode: 0644]
src/test.txt [new file with mode: 0644]
src/test/array.sp [new file with mode: 0644]
src/test/array2.sp [new file with mode: 0644]
src/test/bank.sp [new file with mode: 0644]
src/test/byte.sp [new file with mode: 0644]
src/test/cat.sp [new file with mode: 0644]
src/test/cat2.sp [new file with mode: 0644]
src/test/cat3.sp [new file with mode: 0644]
src/test/clike.sp [new file with mode: 0644]
src/test/cp.sp [new file with mode: 0644]
src/test/cp2.sp [new file with mode: 0644]
src/test/cp3.sp [new file with mode: 0644]
src/test/crlf.sp [new file with mode: 0644]
src/test/csock.sp [new file with mode: 0644]
src/test/csock2.sp [new file with mode: 0644]
src/test/datatype.sp [new file with mode: 0644]
src/test/dtype2.sp [new file with mode: 0644]
src/test/each.sp [new file with mode: 0644]
src/test/fact.sp [new file with mode: 0644]
src/test/fib.sp [new file with mode: 0644]
src/test/filter.sp [new file with mode: 0644]
src/test/format.sp [new file with mode: 0644]
src/test/func.sp [new file with mode: 0644]
src/test/gcd.sp [new file with mode: 0644]
src/test/hello.sp [new file with mode: 0644]
src/test/http.sp [new file with mode: 0644]
src/test/if.sp [new file with mode: 0644]
src/test/japan.sp [new file with mode: 0644]
src/test/keys.sp [new file with mode: 0644]
src/test/list.sp [new file with mode: 0644]
src/test/local.sp [new file with mode: 0644]
src/test/loop.sp [new file with mode: 0644]
src/test/map.sp [new file with mode: 0644]
src/test/mix2.sp [new file with mode: 0644]
src/test/mixin.sp [new file with mode: 0644]
src/test/mutex.sp [new file with mode: 0644]
src/test/prop.sp [new file with mode: 0644]
src/test/queen.sp [new file with mode: 0644]
src/test/ssock.sp [new file with mode: 0644]
src/test/ssock2.sp [new file with mode: 0644]
src/test/thread.sp [new file with mode: 0644]
src/test/wiki.cgi [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/COPYING b/COPYING
new file mode 120000 (symlink)
index 0000000..a3462e8
--- /dev/null
+++ b/COPYING
@@ -0,0 +1 @@
+/Developer/usr/bin/../share/automake-1.10/COPYING
\ No newline at end of file
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/INSTALL b/INSTALL
new file mode 120000 (symlink)
index 0000000..81326e6
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1 @@
+/Developer/usr/bin/../share/automake-1.10/INSTALL
\ No newline at end of file
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/doc/tutorial/index.txt b/doc/tutorial/index.txt
new file mode 100644 (file)
index 0000000..36a3379
--- /dev/null
@@ -0,0 +1,1488 @@
+
+.soopy
+
+soopy¤ÏLENS¤äEiffel,StandardMLÅù¤ò»²¹Í¤Ë¡¢¤Ê¤ë¤Ù¤¯Ã±½ã¤Êʸˡ¤ò
+¤á¤¶¤·¤Æºî¤é¤ì¤¿¥×¥í¥°¥é¥à¸À¸ì¤Ç¤¹¡£
+
+Æÿ§¡§¡Ê²¼¤Ë¤¤¤¯¤Ë¤·¤¿¤¬¤Ã¤Æ¤À¤ó¤À¤ó²ø¤·¤¯¤Ê¤ê¤Þ¤¹¡£¡Ë
+
+¡¡¡¡¡¦¥·¥ó¥×¥ë¤Êʸˡ
+¡¡¡¡¡¦Lisp¤ÈSmalltalk¤ÈML¤ò­¤·¤Æ3¤Ç³ä¤Ã¤¿¤è¤¦¤ÊÊ·°Ïµ¤
+¡¡¡¡¡¦Ë­ÉÙ¤ÊÁȤ߹þ¤ß·¿
+¡¡¡¡¡¦¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á
+¡¡¡¡¡¦¥¯¥é¥¹¤È¤¤¤¦³µÇ°¤¬¤Ê¤¤¤Î¤Ë¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ
+¡¡¡¡¡¦´Ø¿ô·¿¸À¸ì¤È¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¸À¸ì¤¬Èù̯¤Ëº®¤¶¤Ã¤¿¸À¸ì»ÅÍÍ
+
+
+
+¤Ê¤ª¡¢¤³¤Î¥É¥­¥å¥á¥ó¥È¤Ïµ×ÊÝ͵°ìϺ»á¤Î¡ÚtxtCompile¡Û¤ò
+»ÈÍѤ·¤Æºî¤é¤ì¤Æ¤¤¤Þ¤¹¡£´¶¼Õ¡£
+
+
+..¥¤¥ó¥¹¥È¡¼¥ë
+
+¼Â¹Ô¥Õ¥¡¥¤¥ësoopy(.exe)¤ò¥Ñ¥¹¤Î¤È¤ª¤Ã¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ËÃÖ¤­¤Þ¤¹¡£
+¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¾ì¹ç¡¢¸¡º÷¥Ñ¥¹¤ò´Ä¶­ÊÑ¿ôSOOPY_LIB¤ò»ØÄꤷ¤Æ¤ª¤­¤Þ¤¹¡£
+°Ê¾å¡£
+
+
+..³µÍ×
+
+ʸ¤Î¼ïÎà
+¡¡Ã±½ã¤Ê¼°
+¡¡ÂåÆþʸ
+¡¡¥á¥Ã¥»¡¼¥¸¼°
+¡¡¥³¥á¥ó¥È
+
+¤µ¤Þ¤¶¤Þ¤ÊÁȤ߹þ¤ß·¿
+
+
+...ʸ¤Î¼ïÎà
+
+¡¡¡¡soopy¤Î¹½Ê¸¤ÏÈó¾ï¤Ëñ½ã¤Ç¤¹¡£Â礭¤¯¤ï¤±¤ë¤È¼¡¤Î£µ¼ïÎà¤À¤±¤Ç¤¹¡£
+
+¡¡¡¡¡¡£±¡¥»»½Ñ¼°¡Ê¡Ü¡¢¡Ý¡¢¡ö¡¢¡¿¡¢¡ó¡Ë¡¢ÏÀÍý¼°¡Êand¡¢or¡Ë¤Ê¤É¤Îñ½ã¤Ê¼°
+¡¡¡¡¡¡£²¡¥ÂåÆþʸ
+¡¡¡¡¡¡£³¡¥¥á¥Ã¥»¡¼¥¸¼°
+¡¡¡¡¡¡£´¡¥À©¸æ¹½Â¤ -- ¾ò·ïʬ´ô(match)¤È·«¤êÊÖ¤·(loop)¡£
+¡¡¡¡¡¡£µ¡¥Äê¿ô¤ä´Ø¿ô¤ÎÀë¸À¡£
+
+¡¡¡¡¤½¤ì¤¾¤ì¤Îʸ¤Ë¤Ä¤¤¤Æ´Êñ¤ËÀâÌÀ¤·¤Þ¤¹¡£
+
+....ñ½ã¤Ê¼°
+
+¡¡¡¡¡¡¡¡Ã±½ã¤Ê¼°¤Ë¤Ï¡¢Ã±¹à±é»»»Ò¤È£²¹à±é»»»Ò¤¬¤¢¤ê¤Þ¤¹¡£
+
+¡¡¡¡¡¡¡¡¡¡»»½Ñ¼°¤Î
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡²Ã»»¡Ê¡Ü¡Ë¡¢¸º»»¡Ê¡Ý¡Ë¡¢³Ý¤±»»¡Ê¡ö¡Ë¡¢³ä¤ê»»¡Ê¡¿¡Ë¡¢¾ê;¡Ê¡ó¡Ë
+¡¡¡¡¡¡¡¡¡¡ÏÀÍý¼°¤Î
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥¢¥ó¥É¡Êand¡Ë¡¢¥ª¥¢¡Êor¡Ë¡¢ÈÝÄê¡Ê¡ª¡Ë
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÅùÃÍ¡Ê¡á¡á¡Ë¡¢Åù¤·¤¯¤Ê¤¤¡Ê¡ª¡á¡Ë¡¢
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡Â礭¤¤¡Ê¡ä¡Ë¡¢°Ê¾å¡Ê¡ä¡á¡Ë¡¢¾®¤µ¤¤¡Ê¡ã¡Ë¡¢°Ê²¼¡Ê¡ã¡á¡Ë
+¡¡¡¡¡¡¡¡¡¡¤½¤Î¤Û¤«¤Ë¡¢Lisp¤Ë¤ª¤±¤ëCons¤ËÃͤ¹¤ë¡Ê¡§¡§¡Ë±é»»»Ò¤ä¡¢¡÷±é»»»Ò¤Ê¤É¤¬¤¢¤ê¤Þ¤¹¡£
+
+¡¡¡¡¡¡±é»»»Ò¤ÎÍ¥Àè½ç°Ì¤Ï°Ê²¼¤Î¤È¤ª¤ê¤Ç¤¹¡£¡Ê¤¿¤À¤·¡¢¾­ÍèŪ¤Ë¤ÏÍ¥Àè½ç°Ì¤Ï
+¡¡¡¡¡¡ÊѤï¤ë²ÄǽÀ­¤â¤¢¤ë¡£¡Ê¸½»þÅÀ¤Ç¤Ï¿¼¤¯¹Í¤¨¤Æ¤Ê¤¤¤â¤ó¤Ç¡£¡£¡£^_^;¡Ë¡Ë
+
+¡¡¡¡¡¡¡¡Í¥Àè½ç°Ì
+
+<pre>
+¡¡¡¡¡¡¡¡¡¡Ä㤤¡¡¡¡or
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡and
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ª
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡==, !=
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡>, >=, <, <=
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡+, -
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡*, /, %
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ý¡Êñ¹à¡Ë
+¡¡¡¡¡¡¡¡¡¡¹â¤¤¡¡¡¡.., ::, //, @
+</pre>
+
+
+
+....ÂåÆþʸ
+
+.....ÉáÄ̤ÎÂåÆþ
+
+¡¡¡¡¡¡¡¡ÂåÆþʸ¤Ï¡¢¥¤¥³¡¼¥ë¡Ê¡á¡Ë¤Ç·ë¤Ð¤ì¤¿º¸Êդλؤ·¼¨¤¹¾ì½ê¤Ë
+¡¡¡¡¡¡±¦ÊÕ¤ÎÃͤò·ë¤ÓÉÕ¤±¤Þ¤¹¡£
+¡¡¡¡¡¡¡¡¤Þ¡£¼ê³¤­·¿¤Î¸À¸ì¤Ë¤Ï¤è¤¯¤¢¤ë¤ä¤Ä¤Ç¤¹¡£
+
+¡¡¡¡¡¡¡¡Îã¡£
+<pre>
+              pi = 3.14;
+
+              msg = "Hello, world!";
+
+              anArray(2,3) = 'c';
+
+              square = {arg:[x]; do:[x * x];};
+
+              anObject aFeature = "Hummm?";
+
+</pre>
+¡¡¡¡¡¡¡¡¡¡¡¡¤Ê¤É¤Ê¤É¡£
+
+.....¿½ÅÂåÆþ
+
+¡¡¡¡¡¡¡¡Â¿½ÅÂåÆþ¤Ï°ìÅÙ¤ËÊ£¿ô¤Î¾ì½ê¤ËÃͤò·ë¤Ó¤Ä¤±¤Þ¤¹¡£
+
+¡¡¡¡¡¡¡¡Îã¡£
+<pre>
+              let (x,y,z) = (2, 'a', "hello");
+              let [x,y,z] = [2, 'a', "hello"];
+              let x::xs   = [2, 'a', "hello"];  # x = 2; xs =['a', "hello"];
+</pre>
+
+
+....¥á¥Ã¥»¡¼¥¸¼°
+
+¡¡¡¡¡¡¡¡¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¸À¸ì¤Ë¤È¤Ã¤Æ¡¢¤â¤Ã¤È¤â½ÅÍפÊʸ¤Ç¤¹¡£
+¡¡¡¡¡¡¤È¤¤¤Ã¤Æ¤â¡¢¤¿¤À¤¿¤ó¤Ë¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥á¥Ã¥»¡¼¥¸¤òÁ÷¤ë¤À¤±¤Ç¤¹¤±¤É¤Í¡£(^_^;
+¡¡¡¡¡¡¡Êsoopy¤Ç¤Ï¡¢´Ø¿ô¥³¡¼¥ë¤â¥á¥Ã¥»¡¼¥¸¼°¤È¤·¤Æ¼Â¸½¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¡Ë
+¡¡¡¡¡¡¡¡soopy¤Ë¤ª¤¤¤Æ¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ê¹½Ê¸¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
+
+¡¡¡¡¡¡¡¡¡ã¥ª¥Ö¥¸¥§¥¯¥È¡ä¡¡¡ã¥á¥Ã¥»¡¼¥¸¡ä
+
+
+¡¡¡¡¡¡¡¡Îã¡£
+<pre>
+             "string" length;
+
+             [1,2,3] map ({arg:[x]; do:[x+1];} eval);
+
+             [3...7] each ({arg:[x]; do:[println x];} eval);
+
+             {
+               fun main(){do: println "Hello, world!";};
+             } main();
+
+             {
+               a: 3;
+               fun f(x){do:a+x;};
+             } f 7;
+
+</pre>
+
+....¥³¥á¥ó¥È
+
+¡¡¡¡¡¡¡¡/* ¤È */¡¡¤Ë°Ï¤Þ¤ì¤¿Éôʬ¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£
+¡¡¡¡¡¡¡¡¡ô¡¡¤«¤é¹ÔËö¤Þ¤Ç¤â¥³¥á¥ó¥È¤Ç¤¹¡£
+
+
+
+
+...¤µ¤Þ¤¶¤Þ¤ÊÁȤ߹þ¤ß·¿
+
+¡¡¡¡£µ¼ïÎà¤Îʸ¤À¤±¤Ç¤Ï¡¢Ê£»¨¤Ê¥×¥í¥°¥é¥à¤ÏÁȤá¤Ê¤¤¤Î¤Ç¡¢
+soopy¤Ë¤Ï¤µ¤Þ¤¶¤Þ¤Ê¼ïÎà¤ÎÁȤ߹þ¤ß·¿¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
+
+À°¿ô¡ÊInt)
+¡¡£°¤«¤é£¹¤Î¿ô»ú¤Îʤӡ£¤è¤¯¤¢¤ë¤ä¤Ä¡£
+
+¼Â¿ô¡ÊReal)
+¡¡£°¡¥£µ¤È¤«¾®¿ôÅÀ¤ò»È¤¦¿ô»ú¡£
+
+ÏÀÍý·¿¡ÊBool)
+¡¡true¡Ê¿¿¡Ë¤Èfalse¡Êµ¶¡Ë¤Çɽ¤µ¤ì¤ë¡£
+
+ʸ»ú¡ÊChar)
+¡¡¡Ç¤È¡Ç¤Ç¤Ï¤µ¤Þ¤ì¤¿£±Ê¸»ú¤Î¥­¥ã¥é¥¯¥¿¡£
+
+ʸ»úÎó
+¡¡¡É¤È¡É¤Ç°Ï¤Þ¤ì¤¿Ê¸»ú¤Îʤӡ£
+
+
+
+¡¡°Ê²¼¤Ë¡¢¤½¤Î¾¤Ë¤É¤ó¤Ê·¿¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¤«¤À¤±½ñ¤¤¤Æ¤ª¤­¤Þ¤¹¡£
+¾Ü¤·¤¯¤Ï<CLASS Reference>¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
+
+    List(¥ê¥¹¥È), NameSpace(¥ª¥Ö¥¸¥§¥¯¥È),
+    Array, TextFileIn, TextFileOut,
+    Primitive, Closure(¥¯¥í¡¼¥¸¥ã¡Ë
+
+
+
+..ÆþÌç
+...¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Îµ¯Æ°¤È½ªÎ»
+
+¡¡soopy¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ò°ú¿ô¤Ê¤·¤Çµ¯Æ°¤¹¤ë¤È¡¢
+¥×¥í¥ó¥×¥È¡Ê¡ä¡Ë¤¬É½¼¨¤µ¤ì¤Æ¡¢¥æ¡¼¥¶¤ÎÆþÎÏÂÔ¤Á¤Ë
+¤Ê¤ê¤Þ¤¹¡£
+¡¡¤³¤³¤Ç¡¢¤¤¤í¤¤¤í¤Êʸ¤òÆþÎϤ¹¤ë¤È¡¢soopy¤¬
+ʸ¤ò²ò¼á¤·¼Â¹Ô¤·¤Þ¤¹¡£
+¡¡soopy¤ò½ª¤ï¤ë¤È¤­¤Ë¤Ï¡¢EOF¡ÊWindows¤Ê¤éCtrl-Z¡Ë¤ò
+ÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£
+
+¡¡¤Þ¤¿¡¢¤¢¤é¤«¤¸¤áÍÑ°Õ¤·¤¿¥×¥í¥°¥é¥à¥Õ¥¡¥¤¥ë¤ò
+¼Â¹Ô¤¹¤ë¤È¤­¤Ë¤Ï¡¢
+
+soopy filename [°ú¿ôʤÓ]
+
+¡¡¤Ç£Ï£Ë¤Ç¤¹¡£
+
+
+...ºÇ½é¤Î¥×¥í¥°¥é¥à
+
+¡¡¸À¸ì¤ÎÆþÌç¤È¤¤¤¨¤Ð¡¢"Hello, world"¤Ç¤¹¤¬¡¢
+soopy¤Ç¤Ï¤É¤¦¤Ê¤ë¤Î¤Ç¤·¤ç¤¦¡£
+¡¡¤¤¤¯¤Ä¤«ÊýË¡¤Ï¤¢¤ê¤Þ¤¹¤¬¡¢ºÇ½é¤Ï¡¢
+
+/* 1 */
+
+println "Hello, World!";
+
+¡¡¤ÇÀâÌÀ¤·¤Þ¤¹¡£
+¡¡¤Þ¤ºÂè°ì¤Ë³Ð¤¨¤ÆÍߤ·¤¤¤Î¤Ï¡¢Ê¸¤Î½ª¤ï¤ê¤Ë¤Ïɬ¤º
+¥»¥ß¥³¥í¥ó¡Ê¡¨¡Ë¤¬É¬ÍפÀ¤È¤¤¤¦¤³¤È¤Ç¤¹¡£
+¡¡¤Ç¤Ï¡¢soopy¤òµ¯Æ°¤·¤Æ¾å¤Îʸ¤òÆþÎϤ·¤Æ¤ß¤Æ
+¤¯¤À¤µ¤¤¡£Ê¸¤òºÇ¸å¤Þ¤ÇÆþÎϤ·¤¿¤é¡¢²þ¹Ô¥­¡¼¤ò
+²¡¤·¤Þ¤¹¡£
+
+¡¡soopy¤Ë¤Ï¡¢5¼ïÎà¤Îʸ¤·¤«¤Ê¤¤¤ï¤±¤Ç¤¹¤¬¡¢
+¤Ç¤Ï¤³¤Îʸ¤Ï£±¾Ï¤ÇÀâÌÀ¤·¤¿¤¦¤Á¤Î¤É¤Îʸ¤Ë¤¢¤¿¤ë
+¤Î¤Ç¤·¤ç¤¦¤«¡£
+¡¡¤ª¤ï¤«¤ê¤Î¤è¤¦¤Ë¡ãñ½ã¤Ê¼°¡ä¤Ç¤â¡¢¡ãÂåÆþʸ¡ä¤Ê¤É¤Ç¤â
+¤Ê¤¤¤Ç¤¹¤«¤é¡¢¡ã¥á¥Ã¥»¡¼¥¸¼°¡ä¤Ç¤¹¡£
+¡¡¡ã¥á¥Ã¥»¡¼¥¸¼°¡ä¤Ï¡¢¤Ä¤Í¤Ë
+
+¡¡¡ã¥ª¥Ö¥¸¥§¥¯¥È¡ä¡¡¡ã¥á¥Ã¥»¡¼¥¸¡ä
+
+¡¡¤È¤¤¤¦·Á¤ò¤·¤Æ¤¤¤Þ¤¹¤«¤é¡¢¤³¤Î¾ì¹ç¡¢
+println ¤¬¥ª¥Ö¥¸¥§¥¯¥È¡¢"Hello, World!"¤¬
+¥á¥Ã¥»¡¼¥¸¤Ë¤Ê¤ê¤Þ¤¹¡£¤Ç¤Ï¡¢¤½¤ì¤¾¤ì¤É¤ó¤Ê·¿¤Î
+¥ª¥Ö¥¸¥§¥¯¥È¤Ê¤Î¤«¸«¤Æ¤¤¤­¤Þ¤·¤ç¤¦¡£¡Ê¥á¥Ã¥»¡¼¥¸¤â
+¼Â¤Ïñ¤Ê¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¹¡£¡Ë
+¡¡"Hello, World!"¤Ï¡Öʸ»úÎó¡ÊString)¡×¤Ç¤¹¤¬¡¢
+println¤Ï¥ª¥Ö¥¸¥§¥¯¥È¤ò°ú¿ô¤È¤·¤Æ¼õ¤±¼è¤ê²èÌ̤Ë
+ɽ¼¨¤¹¤ë¡Ö¥×¥ê¥ß¥Æ¥£¥Ö¡ÊÁȤ߹þ¤ß´Ø¿ô¡Ë¡×¤Ç¤¹¡£
+¡¡¤Ç¤¹¤«¤é¡¢¾å¤Îʸ¤Ï¥×¥ê¥ß¥Æ¥£¥Ö¤Ëʸ»úÎó¤ò
+¥á¥Ã¥»¡¼¥¸¤È¤·¤ÆÁ÷¤Ã¤Æ¤¤¤ë¤ï¤±¤Ç¤¹¡£
+¡¡¤Á¤Ê¤ß¤Ë¡¢println¤ÎÊÖÃͤϼ«Ê¬¼«¿È¤Ç¤¹¤Î¤Ç¡¢
+¤Ä¤Å¤±¤¶¤Þ¤Ë¥×¥ê¥ó¥È¤·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢
+
+println object1 object2 ... objectN;
+
+¡¡¤Ê¤É¤È½ñ¤±¤Þ¤¹¡£
+
+
+/* 2 */
+
+<pre>
+{
+  fun main(){do: println "Hello, World!";};
+} main();
+</pre>
+
+¡¡¾å¤Îʸ¤Ï¡¢¡Ð¡¡¤È¡¡¡Ñ¤Ë°Ï¤Þ¤ì¤¿Éôʬ¤¬¥ª¥Ö¥¸¥§¥¯¥È¤ò
+ɽ¤·¤Æ¤¤¤Æ¡¢¤½¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ëmain¤È¤¤¤¦¥·¥ó¥Ü¥ë¤ò
+Á÷¤Ã¤Æ¤¤¤Þ¤¹¡£
+¡¡¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥·¥ó¥Ü¥ë¤¬Á÷¤é¤ì¤ë¤È¡¢¤½¤Î¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤Î
+Ʊ¤¸Ì¾Á°¤ÎÍ×ÁǤ¬ÊÖ¤µ¤ì¤Þ¤¹¡£¤³¤Î¾ì¹ç¡¢main¤È¤¤¤¦Ì¾Á°¤Î
+´Ø¿ô¡Ê¼ÂºÝ¤Ë¤Ï¥¯¥í¡¼¥¸¥ã¡Ë¤¬Ê֤äƤ­¤Þ¤¹¡£
+¡¡¤½¤·¤Æ¡¢Ê֤äƤ­¤¿´Ø¿ô¤Ë¤µ¤é¤Ë¡Ê¡Ë¡á¥Ì¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ò
+¥á¥Ã¥»¡¼¥¸¤È¤·¤ÆÁ÷¤ë¤³¤È¤Ë¤è¤ê¡¢´Ø¿ô¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
+
+¡¡·ë¶É¡¢/* £² */¤Îʸ¤Ç¤â¡¢¡Ê¡ö£±¡ö¡Ë¤Îʸ¤ÈƱÍͤˡ¢
+"Hello, World!"¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
+
+
+
+...´Êñ¤Ê¼°
+
+¡¡»»½Ñ¼°¤äÏÀÍý¼°¤Ê¤É¤ÏC¸À¸ì¤Ê¤É¤È¤½¤ì¤Û¤ÉÊѤï¤ê¤¬¤¢¤ê¤Þ¤»¤ó¡Ê¤Î¤Ç¾Êά¡Ë¡£
+
+
+...¥ê¥¹¥È
+
+¡¡¥ê¥¹¥È¤È¤Ï¡¢Lisp¤Ç¤¤¤¦¥ê¥¹¥È¤È°ì½ï¤Ç¤¹¡£
+Lisp¤òÃΤé¤Ê¤¯¤Æ¤âÌäÂꤢ¤ê¤Þ¤»¤ó¡£[ ¤È] ¤Ç°Ï¤Þ¤ì¤¿¡¢
+ñ¤Ê¤ë¥ª¥Ö¥¸¥§¥¯¥È¤ÎʤӤǤ¹¡£¡Ê¤Ò¤È¤Ä¤Ò¤È¤Ä¤ÎÍ×ÁǤÏ
+¥³¥ó¥Þ(,)¤¢¤ë¤¤¤Ï¥»¥ß¥³¥í¥ó(;)¤Ç¶èÀÚ¤ê¤Þ¤¹¡£¡Ë
+¡¡¥ê¥¹¥È¤Î¤Ê¤«¤Ë¤Ï¿ô»ú¤À¤í¤¦¤¬¡¢¼°¤À¤í¤¦¤¬¡¢ÂåÆþʸ¤À¤í¤¦¤¬¡¢
+¥á¥Ã¥»¡¼¥¸¼°¤À¤í¤¦¤¬¡¢¤Ê¤ó¤Ç¤âÆþ¤ê¤Þ¤¹¡£
+
+¡¡Îã¡£
+
+<pre>
+   [1,2,3];
+
+   [45, "string", 'c', x + y, println "Hello"];
+</pre>
+
+
+¡¡¤Þ¤¿¡¢¥ê¥¹¥È¤ÎÆüì¤Ê·Á¤È¤·¤Æ¡¢
+
+<pre>
+¡¡[¡ã½é´üÃÍ¡ä..¡ã½ªÃÍ¡ä]
+</pre>
+
+¡¡¤È¤¤¤¦·Á¤Î¤â¤Î¤¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤Ï¡¢¡ã½é´üÃ͡䤫¤é¡ã½ªÃÍ¡ä¤Þ¤Ç¤Î
+À°¿ô¤Î¥ê¥¹¥È¤ÈƱ¤¸°ÕÌ£¤Ç¤¹¡£Î㤨¤Ð¡¢  [1,2,3,4,5]¡¡¤È¡¡[1..5]¡¡
+¤ÏƱ¤¸°ÕÌ£¤Ç¤¹¡£
+¡¡¤È¤³¤í¤Ç¡¢¡ã½ªÃÍ¡ä¤Ï¾Êά²Äǽ¤Ç¤¹¡£¾Êά¤¹¤ë¤È¤É¤¦¤Ê¤ë¤«¤È
+¤¤¤¦¤È¡¢Ìµ¸Â¥ê¥¹¥È¤òɽ¤·¤Þ¤¹¡£
+¡¡Î㤨¤Ð¡¢[27..] ¤Ï¡¢£²£·¤«¤é£±¤º¤ÄÁý¤¨¤ë̵¸Â¤Î¥ê¥¹¥È¤òɽ¤·¤Þ¤¹¡£
+
+¡¡¤µ¤é¤Ë¡¢
+<pre>
+¡¡[¡ã½é´üÃÍ¡ä..¡ã¼¡¤ÎÃÍ¡ä..¡ã½ªÃÍ¡ä]
+</pre>
+
+¡¡¤È¤¹¤ì¤Ð¡¢¡ã¼¡¤ÎÃÍ¡ä¡Ý¡ã½é´üÃ͡䤺¤ÄÁý¤¨¤ë¥ê¥¹¥È¤¬½ÐÍè¤Þ¤¹¡£
+¤³¤Î¾ì¹ç¤â¡¢¡ã½ªÃÍ¡ä¤Ï¾Êά¤·¤Æ̵¸Â¥ê¥¹¥È¤òºî¤ì¤Þ¤¹¡£
+
+
+...¥¿¥×¥ë¡ÊÁÈ¡Ë
+
+¡¡¥¿¥×¥ë¤È¤Ï¡¢¡Ê ¤È ¡Ë ¤Ç°Ï¤Þ¤ì¤¿¡¢<b>£²¤Ä°Ê¾å</b>¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ÎʤӤǤ¹¡£
+¡Ê¤Ò¤È¤Ä¤Ò¤È¤Ä¤ÎÍ×ÁǤϥ³¥ó¥Þ(,)¤Ç¶èÀÚ¤ê¤Þ¤¹¡£¡Ë
+¡¡´Ø¿ô¤ËÊ£¿ô¤Î°ú¿ô¤òÅϤ¹¤È¤­¤Ê¤É¤Ë»È¤ï¤ì¤Þ¤¹¡£
+
+
+...´Ø¿ô
+
+
+<ol>
+  <li>´Ø¿ôÄêµÁ
+    <blockquote>
+      ´Ø¿ôÄêµÁ¤Ï¡¢°Ê²¼¤Î·Á¤ò¤·¤Æ¤¤¤Þ¤¹¡£
+<pre>
+        fun func_name(arg1, arg2,...,argN){<br>
+          require: [statement list];<br>
+          var: [symbol list];<br>
+          do: [statement list];<br>
+          ensure: [statement list];<br>
+          rescue: [statement list];<br>
+        };<br>
+<pre>
+      require: ¤Ë¤Ï¡¢´Ø¿ô¤Î»öÁ°¾ò·ï¤Îʤӡ¢<br>
+      var: ¤Ë¤Ï¡¢ÊÑ¿ô̾¡Ê¥·¥ó¥Ü¥ë¡Ë¤Î¥ê¥¹¥È¡¢<br>
+      do: ¤Ë¤Ï¡¢´Ø¿ôËÜÂÎ(¼ÂºÝ¤Ë¼Â¹Ô¤µ¤ì¤ëʸ)¤Îʤӡ¢<br>
+      ensure: ¤Ë¤Ï¡¢»ö¸å¾ò·ï¤Îʤӡ¢<br>
+      rescue: ¤Ë¤Ï¡¢´Ø¿ôËÜÂΤä»ö¸å¾ò·ïÆâ¤ÇÎã³°¤¬µ¯¤­¤¿»þ¤Ë¼Â¹Ô¤µ¤ì¤ëʸ¤ÎʤÓ<br>
+      ¤òÄêµÁ¤¹¤ë¡£<br>
+    </blockquote>
+<br>
+<br>
+</ol>
+
+¡¡¡¡Îã¡£
+<pre>
+      fun square(x){do: [x * x];};¡¡/*¡¡Æó¾è¤ò·×»»¤¹¤ë´Ø¿ôsquare¤ÎÄêµÁ¡¡*/
+
+¡¡¡¡¡¡fun func2(x,y){    /*¡¡´Ø¿ô¼«ÂΤˤϤ¿¤¤¤·¤Æ°ÕÌ£¤Ï¤Ê¤¤¡¡*/
+        var: [n,m],¡¡¡¡¡¡/*¡¡¥í¡¼¥«¥ëÊÑ¿ô¤ÎÀë¸À¡¡*/
+        do: [
+          n = x + y;
+          m = x * y;
+          n - m ¡¡¡¡¡¡¡¡ /*¡¡n - m ¤ÎÃͤ¬¤¬´Ø¿ô¤ÎÌá¤êÃÍ¡¡*/
+        ];
+      };
+</pre>
+
+¡¡¤Þ¤¿¡¢´Ø¿ô¤ò¼Â¹Ô¤¹¤ë¤Ë¤Ï¡¢´Ø¿ô¤Ë°ú¿ô¤òʤ٤¿
+¥¿¥×¥ë¤òÁ÷¤ê¤Þ¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+      func ();
+
+      square (4);
+
+      someFunction (2,7);
+</pre>
+
+¡¡£²°ú¿ô¤Î´Ø¿ô¤Ë°ú¿ô¤ò£±¸Ä¤·¤«ÅϤµ¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
+¥¨¥é¡¼¤Ë¤Ï¤Ê¤é¤º¡¢ºÇ½é¤Î°ú¿ô¤ËÅϤ·¤¿Ãͤ¬·ë¤ÓÉÕ¤±¤é¤ì¤¿¡¢
+£±°ú¿ô¤Î´Ø¿ô¤¬ÊÖ¤ê¤Þ¤¹¡£
+¡¡°ìÈ̤ËÊ£¿ô¤Î°ú¿ô¤ò¤È¤ë´Ø¿ô¤Ë¡¢¾¯¤Ê¤¤°ú¿ô¤·¤«
+ÅϤµ¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢ÅϤ·¤¿¤Ö¤ó¤Î°ú¿ô¤Î¤ß¡¢Ãͤ¬·ë¤Ó¤Ä¤±¤é¤ì¤¿
+´Ø¿ô¡Ê¥¯¥í¡¼¥¸¥ã¡Ë¤¬Ê֤äƤ­¤Þ¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+      g = func2 7;  /*¡¡g ¤Ï¡¢£±°ú¿ô¤Î´Ø¿ô¡¡*/
+      g 8;          /*¡¡´Ø¿ô¤ÎÃͤϡ¢-41 */
+</pre>
+
+
+
+...¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ
+....¥Í¡¼¥à¥¹¥Ú¡¼¥¹(NameSpace)¤ÎÄêµÁ
+
+¡¡soopy¤Ë¤Ï¼Â¤Ï¥¯¥é¥¹¤È¤¤¤¦³µÇ°¤¬¤¢¤ê¤Þ¤»¤ó¡£
+¤Ç¤â¡¢¥ª¥Ö¥¸¥§¥¯¥È¡Ê¥¤¥ó¥¹¥¿¥ó¥¹¡Ë¤Ïºî¤ì¤Þ¤¹¡£
+soopy¤Ç¤Ï¡¢¥ª¥Ö¥¸¥§¥¯¥È¤Ï¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤È
+¸Æ¤Ð¤ì¤Þ¤¹¡£¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤Ï¡¢Ê̤θƤÓÊý¤ò¤¹¤ë¤È
+Ï¢ÁÛÇÛÎó¤È¤â¤¤¤¤¤Þ¤¹¡£
+
+¡¡¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤òºî¤ë¤Ë¤Ï¡¢¡Ð¡¡¤È¡¡¡Ñ¤Ë°Ï¤Þ¤ì¡¢¥»¥ß¥³¥í¥ó(¡¨)
+¤Ç¶èÀÚ¤é¤ì¤¿¥Õ¥£¡¼¥Á¥ã¤ÎÀë¸À¤ÎʤӤǤ¹¡£
+¡¡¥Õ¥£¡¼¥Á¥ã¤ÎÀë¸À¤Ï
+
+¡¡¡ã¥·¥ó¥Ü¥ë¡ä¡§¡¡Ê¸
+¡¡¤Î·Á¤ò¤·¤Æ¤¤¤ë¤«¡¢
+¤Þ¤¿¤Ï¡¢
+¡¡´Ø¿ôÀë¸À
+¤Þ¤¿¤Ï¡¢
+¡¡Äê¿ôÀë¸À
+¤Þ¤¿¤Ï¡¢
+¡¡¥×¥í¥Ñ¥Æ¥£Àë¸À
+¤Þ¤¿¤Ï¡¢
+¡¡¥Ç¡¼¥¿¥¿¥¤¥×Àë¸À
+¤Ç¤¹¡£
+
+
+¡¡²¼¤Îʸ¤Ï¡¢¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤·¤Þ¤¹¡£
+¡Ê¤·¤«¤·¡¢¥ª¥Ö¥¸¥§¥¯¥È¤½¤Î¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£¡Ë
+<pre>
+      { a: 3; b: x; }
+</pre>
+
+  ¤¢¤¯¤Þ¤Ç¡¢¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ëʸ¤Ê¤Î¤Ç¡¢
+¾å¤Îʸ¤¬¼Â¹Ô¤µ¤ì¤ë¤¿¤Ó¡¢À¸À®¤µ¤ì¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ï
+ÊÌʪ¤Ç¤¹¡£
+
+¡¡¤è¤Ã¤Æ¡¢
+
+<pre>
+      fun f(){
+        do: [
+          {
+            a: 7;
+            fun printIt(){do: [println a]; };
+          }
+        ];
+      };
+</pre>
+
+¤Î¤È¤­¡¢
+
+<pre>
+      x = f();
+      y = f();
+</pre>
+
+¤È¤¹¤ë¤È¡¢£ø¤È£ù¤Î»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤ÏÊÌʪ¤Ç¤¹¡£¤·¤«¤·¡¢
+£ø¤È£ù¤Î¹½Â¤¤ÏƱ¤¸¤Ç¤¹¡£
+¡¡¤È¤¤¤¦¤³¤È¤Ï¡¢¥¯¥é¥¹¤ò»È¤ï¤Ê¤¯¤Æ¤â¡¢Æ±¤¸À­¼Á¤Î
+¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®²Äǽ¤È¤¤¤¦¤³¤È¤Ç¤¹¡£¤Þ¤¿¡¢´Ø¿ô£æ¤Ï
+£Ã¡Ü¡Ü¤Ê¤É¤ÎÉáÄ̤Υª¥Ö¥¸¥§¥¯¥È»Ø¸þ¸À¸ì¤Ë¤ª¤±¤ë
+¥³¥ó¥¹¥È¥é¥¯¥¿¤ÎÌòÌܤò¤·¤Æ¤¤¤ë¤³¤È¤¬¤ï¤«¤ë¤È»×¤¤¤Þ¤¹¡£
+
+¡¡£æ¤¬°ú¿ô¤ò¤È¤ë´Ø¿ô¤À¤È¤·¤¿¤é¡¢¤É¤¦¤Ç¤·¤ç¤¦¡£
+¤µ¤Þ¤¶¤Þ¤Ê¥ª¥Ö¥¸¥§¥¯¥È¤¬ºî¤ì¤ë¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
+¤ä¤Ã¤Æ¤ß¤Þ¤·¤ç¤¦¡£
+
+<pre>
+
+  fun map(f,l){
+    do: match(l){
+          []:    [];
+          x::xs: f x :: map(f,xs);
+        };
+  };
+
+  fun con(list,func){
+    do: [
+      {
+        fun run(){
+          do: [
+            map (func, list);
+          ];
+        };
+      };
+    ];
+  };
+
+  fun add1(x){
+    do: [x + 1];
+  };
+
+  fun add2(x){
+    do: [x + 2];
+  };
+
+  a = con([1,2,3,4,5], add1);
+  b = con([1..5], add2);
+  a run();
+  b run();
+</pre>
+
+
+
+
+....¥Õ¥£¡¼¥Á¥ã¡¼¤Î¥¢¥¯¥»¥¹
+
+¡¡¡¡¡¡¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Õ¥£¡¼¥Á¥ã¡¼¡ÊÍ×ÁǡˤòÆɤ߽Ф¹¤Ë¤Ï
+¡¡¡¡¥ª¥Ö¥¸¥§¥¯¥È¤ËÆɤ߽Ф·¤¿¤¤¥Õ¥£¡¼¥Á¥ã¡¼¤Î̾Á°¡Ê¥·¥ó¥Ü¥ë¡Ë¤ò
+¡¡¡¡¥á¥Ã¥»¡¼¥¸¤È¤·¤ÆÁ÷¤ê¤Þ¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+      obj = {
+        num:3;
+        str:"Hello";
+        fun func(x){do: [x*num]; };
+      };
+      obj num;  /*¡¡£³¤¬Ê֤äƤ¯¤ë¡¡*/
+      obj str;  /*¡¡"Hello"¤¬Ê֤äƤ¯¤ë¡¡*/
+      obj func; /*¡¡°ú¿ô¤Ë£³¤ò­¤¹´Ø¿ô¤¬Ê֤äƤ¯¤ë¡¡*/
+      f = obj func;
+      f(7);     /* 10¤¬Ê֤äƤ¯¤ë */
+</pre>
+
+
+....¥Õ¥£¡¼¥Á¥ã¡¼¤Î¹¹¿·
+
+¡¡¡¡¡¡¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Õ¥£¡¼¥Á¥ã¡¼¤Ë½ñ¤­¹þ¤à¡Ê¹¹¿·¡Ë¤¹¤ë¤Ë¤Ï¡¢
+¡¡¡¡Åö¤¿¤êÁ°¤Ç¤¹¤¬¡¢ÂåÆþʸ¤ò»È¤¤¤Þ¤¹¡£
+¡¡¡¡¡¡¥Õ¥£¡¼¥Á¥ã¡¼¤òÆɤ߹þ¤à¤Î¤Ï
+
+¡¡¡¡¡¡¡ã¥ª¥Ö¥¸¥§¥¯¥È¡ä¡¡¡ã¥Õ¥£¡¼¥Á¥ã¡¼Ì¾¡ä
+
+¡¡¡¡¤Ç¤¹¤«¤é¡¢½ñ¤­¹þ¤ß¤ÏÅöÁ³¡¢
+
+¡¡¡¡¡¡¡ã¥ª¥Ö¥¸¥§¥¯¥È¡ä¡¡¡ã¥Õ¥£¡¼¥Á¥ã¡¼Ì¾¡ä¡¡¡á¡¡¡ã½ñ¤­¹þ¤ß¤¿¤¤ÃÍ¡ä
+
+¡¡¡¡¤Ç¤¹¡£´Êñ¤Ç¤¹¤Í¡£
+¡¡¡¡¡ÊLisp¤òÃΤäƤ¤¤ëÊý¤Ë¤Ï¡¢Common Lisp ¤Î setf ¤ò¹Í¤¨¤Æ¤¤¤¿¤À¤±¤ì¤Ð
+¤¤¤¤¤È»×¤¤¤Þ¤¹¡£¤«¤¨¤Ã¤Æ°ÕÌ£ÉÔÌÀ¡©¡Ë
+
+¡¡¡¡Îã¡£
+<pre>
+      obj = {
+        num:3;
+        str:"Hello";
+        fun func(x){do: [x*num]; };
+      };
+      obj num;      /*¡¡£³¤¬Ê֤äƤ¯¤ë¡¡*/
+      obj num = 8;  /*¡¡num ¤ÎÃͤò¹¹¿·¡¡*/
+      obj num;      /*¡¡£¸¤¬Ê֤äƤ¯¤ë¡¡*/
+</pre>
+
+
+....¥×¥í¥Ñ¥Æ¥£Àë¸À
+
+¡¡¡¡¥×¥í¥Ñ¥Æ¥£¤Ï¡¢Delphi¤È¤«¤Ë¤¢¤ë¤â¤Î¤È¹Í¤¨Êý¤ÏƱ¤¸¤Ç¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+a = {
+        b: 1;
+
+        fun getf(){do: b;};
+        fun setf(x){do: b = x;};
+
+        property c {
+            set: setf;
+            get: getf;
+        };
+    };
+</pre>
+¡¡¡¡¾å¤ÎÎã¤Ç¡¢
+
+<pre>
+  a c;
+</pre>
+¡¡¡¡¤È¥Õ¥£¡¼¥Á¥ã¡¼£ã¤Ë¥¢¥¯¥»¥¹¤·¤è¤¦¤È¤¹¤ë¤È¡¢
+¡¡set:¡¡¤Ç»ØÄꤵ¤ì¤¿´Ø¿ô¤¬¸Æ¤Ó½Ð¤µ¤ì¡¢¤½¤ÎÊÖÃͤ¬
+¡¡ÃͤȤʤê¤Þ¤¹¡£
+
+¡¡¡¡¤Þ¤¿¡¢
+<pre>
+  a c = value;
+</pre>
+¡¡¡¡¤È¥Õ¥£¡¼¥Á¥ã¡¼£ã¤ËÂåÆþ¤·¤è¤¦¤È¤¹¤ë¤È¡¢
+¡¡get:¡¡¤Ç»ØÄꤵ¤ì¤¿´Ø¿ô¤¬¡¢value¤ò°ú¿ô¤È¤·¤Æ
+¡¡¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
+
+
+....¥Ç¡¼¥¿¥¿¥¤¥×Àë¸À
+
+¡¡¥Ç¡¼¥¿¥¿¥¤¥×¡ÊÂå¿ô·¿¡Ë¤Ï¡¢Ã±½ã¤Ê¤â¤Î¤Ï¡¢C/C++¸À¸ì¤Ê¤É¤Î
+Îóµó·¿¤Ë»÷¤Æ¤¤¤Þ¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+  datatype day = Mon | Tue | Wed | Thi | Fri | Sat | Sun;
+</pre>
+
+¡¡¤³¤Î¤Þ¤Þ¤Ç¤Ï¡¢¤»¤¤¤¼¤¤Äê¿ô¤ÎÂå¤ï¤ê¤°¤é¤¤¤Ë¤·¤«¤Ê¤ê¤Þ¤»¤ó¤Î¤Ç
+¤Á¤ç¤Ã¤È³ÈÄ¥¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
+<pre>
+datatype day =
+  Mon {
+    const workday? = true;
+  }
+| Tue {
+    const workday? = true;
+  }
+| Wed {
+    const workday? = true;
+  }
+| Thi {
+    const workday? = true;
+  }
+| Fri {
+    const workday? = true;
+  }
+| Sat {
+    const workday? = false;
+  }
+| Sun {
+    const workday? = false;
+  }
+;
+</pre>
+¡¡¤È¤¹¤ë¤È¡¢
+<pre>
+  Mon workday?;  # true
+
+  Sun workday?;  # false
+</pre>
+
+¡¡¤Î¤è¤¦¤Ë»È¤¨¤Þ¤¹¡£
+
+¡¡¤Ç¤Ï¡¢workday?¤ÎµÕholiday?¤òÄêµÁ¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
+<pre>
+  Mon {
+    const workday? = true;
+    const holiday? = false;
+  }
+| Tue {
+    const workday? = true;
+    const holiday? = false;
+  }
+  ...
+</pre>
+¡¡¤Î¤è¤¦¤Ë¡¢¤¹¤Ù¤Æ¤ÎÍËÆü¤Ëholiday?¤òÄêµÁ¤·¤Æ¤â¤¤¤¤¤Î¤Ç¤¹¤¬¡¢
+ÌÌÅݤǤ¹¡£¤½¤³¤Ç¡¢
+<pre>
+datatype day {
+    property holiday? {get: isHoliday;};
+    fun isHoliday(){
+      do: [!workday?];
+    };
+  }
+= Mon {
+    const workday? = true;
+  }
+| Tue {
+    const workday? = true;
+  }
+| Wed {
+    const workday? = true;
+  }
+| Thi {
+    const workday? = true;
+  }
+| Fri {
+    const workday? = true;
+  }
+| Sat {
+    const workday? = false;
+  }
+| Sun {
+    const workday? = false;
+  }
+;
+</pre>
+¡¡¤Î¤è¤¦¤Ë¡¢datatype day ¤Î¸å¤í¤Ë¥Ç¡¼¥¿¥¿¥¤¥×¤Î
+¤¹¤Ù¤Æ¤Î¥á¥ó¥Ð¡¼¤«¤é»ÈÍѤǤ­¤ë¥Õ¥£¡¼¥Á¥ã¡¼¤ò
+ÄêµÁ¤·¤Þ¤¹¡£
+¡¡¤³¤¦¤¹¤ì¤Ð¡¢
+<pre>
+Mon holiday?;
+Sat holiday?;
+</pre>
+¡¡¤È¤¤¤¦¤Õ¤¦¤Ë¡¢day·¿¤Î¤¹¤Ù¤Æ¤ÎÍ×ÁǤǡ¢¥á¥½¥Ã¥Éholiday?
+¤¬»ÈÍѤǤ­¤Þ¤¹¡£
+
+
+¡¡¤³¤Î¤è¤¦¤Ë¡¢¥Ç¡¼¥¿¥¿¥¤¥×¤Ï¤¢¤¿¤«¤â¥ª¥Ö¥¸¥§¥¯¥È¤Î¤è¤¦¤Ë
+¤µ¤Þ¤¶¤Þ¤Ê¥Õ¥£¡¼¥Á¥ã¡¼¤ò¤â¤Æ¤Þ¤¹¡£¥Õ¥£¡¼¥Á¥ã¡¼¤Ë¤Ï
+Äê¿ô¡¢´Ø¿ô¡¢ÊÑ¿ô¤Ê¤É¤¬»ÈÍѲÄǽ¤Ç¤¹¡£
+
+¡¡¤Þ¤¿¡¢¥Ç¡¼¥¿¥¿¥¤¥×¤Ï½é´ü²½Ãͤò¤â¤Æ¤Þ¤¹¡£
+<pre>
+datatype fig =  Rect(x:int, y:int)¡¡| Circle(r:int);
+</pre>
+¡¡¤È¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢
+<pre>
+r = Rect(5,7);
+c = Circle(8);
+
+r x;  # 5
+c r;  # 8
+</pre>
+¡¡¤Î¤è¤¦¤Ë¡¢½é´ü²½¤·¤¿Ãͤ˥¢¥¯¥»¥¹½ÐÍè¤Þ¤¹¡£
+¤µ¤é¤Ë¡¢
+<pre>
+datatype fig =
+  Rect(x:int, y:int){
+    fun area(){
+      do: x * y;
+    };
+  }
+| Circle(r:int){
+    pi: 3;
+    fun area(){
+      do: r * r * pi;
+    };
+  }
+;
+</pre>
+¡¡¤È¤¹¤ë¤È¡¢
+<pre>
+r = Rect(5,7);
+c = Circle(8);
+
+r area();  # £ò¤ÏRect¤Ê¤Î¤Ç¡¢Rect¤Îarea¤¬¸Æ¤Ð¤ì¤ë¡£Ãͤϡ¢£³£µ
+c area();  # £ã¤ÏCircle¤Ê¤Î¤Ç¡¢Circle¤Îarea¤¬¸Æ¤Ð¤ì¤ë¡£Ãͤϡ¢£±£¹£²
+</pre>
+¡¡¤Î¤è¤¦¤Ë»È¤¨¤Þ¤¹¡£
+
+¡¡¤³¤Î¤è¤¦¤Ë¡¢Soopy¤Î¥Ç¡¼¥¿¥¿¥¤¥×¤Ï¡¢StandardML ¤ä, Gofer ¤Ê¤É¤Î
+´Ø¿ô·¿¸À¸ì¤ÎÂå¿ô·¿¤ò³ÈÄ¥¤·¤¿¤â¤Î¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
+
+
+....·Ñ¾µ
+
+¡¡soopy¤Ï·Ñ¾µ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó¡£
+¡¡¤¿¤À¤·¡¢·Ñ¾µ¤ËÊѤï¤ëµ¡Ç½¤È¤·¤Æ¡¢¥Í¡¼¥à¥¹¥Ú¡¼¥¹Æ±»Î¤Î
+²Ã»»¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£
+
+¡¡Î㤨¤Ð¡¢
+<pre>
+  super_obj = {
+    name: "ansi common lisp";
+    writer: "paul";
+  };
+¡¡¤Î¤È¤­¤Ë
+
+<pre>
+  child_obj = super_obj + {
+    publisher: "Pearson";
+  };
+</pre>
+¡¡¤È¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢child_obj ¤Ï¡¢super_obj¡¡¤ÎÍ×ÁǤÎ
+¤Û¤«¤Ë¡¢¿·¤¿¤ÊÍ×ÁǤòÄɲä·¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤Ê¤ê¤Þ¤¹¡£
+
+¡¡¤Þ¤¿¡¢
+<pre>
+  another_obj = child_obj + {
+    name: "hack!";
+  };
+</pre>
+¡¡¤È¤¹¤ë¤È¡¢Æ±Ì¾¤ÎÍ×ÁÇ(name)¤Ï±£¤µ¤ì¤Æ¤·¤Þ¤¤¡¢
+¥¢¥¯¥»¥¹½ÐÍè¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£
+¡¡¤³¤ì¤ò²óÈò¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¤â¤È¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ÎÍ×ÁÇ̾¤ò
+²¼µ­¤Î¤è¤¦¤Ë¥ê¥Í¡¼¥à¤·¤Þ¤¹¡£¡Ê'$'¤Ç»Ï¤Þ¤ë¤â¤Î¤ò¥·¥ó¥Ü¥ë¡Ë
+<pre>
+  yet_another_obj = child_obj rename {name: $rename_name;} + {
+    name: "hack?";
+  };
+</pre>
+
+
+¤Þ¤¿¡¢¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥Ô¡¼¤òºî¤ë¤È¤­¤Ë¤â¡¢²Ã»»¤¬»È¤¨¤Þ¤¹¡£
+Á°½Ò¤Î¤è¤¦¤Ë´Ø¿ô¤ò»È¤Ã¤Æ¤â¤¤¤¤¤Î¤Ç¤¹¤¬¡¢¤â¤Ã¤È´Êñ¤Ë
+¸µ¤Ë¤Ê¤ë¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤Ë¶õ¤Î¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò­¤·¤Æ¤ä¤ì¤Ð¤¤¤¤¤Î¤Ç¤¹¡£
+<pre>
+  original_rect = {x:0; y:0; width:100; height:100;};]
+
+  rect1 = original_rect + {};
+</pre>
+¥³¥Ô¡¼¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤ËÊѹ¹¤ò²Ã¤¨¤Æ¤â¡¢¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ÎÃͤÏ
+ÊѤï¤ê¤Þ¤»¤ó¡£
+
+¤µ¤é¤Ë¡¢¤Á¤ç¤Ã¤È¤À¤±°ã¤¦¥ª¥Ö¥¸¥§¥¯¥È¤òºî¤ë¤È¤­¤Ë¤Ï¡¢
+ÊѤ¨¤¿¤¤Í×ÁǤÀ¤±¤Î¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò­¤·¤Æ¤ä¤ê¤Þ¤¹¡£
+<pre>
+  rect2 = original_rect + {width: 640; height:480;};
+</pre>
+
+
+
+....¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤«¤é´Ø¿ô¤òºî¤ë¡£
+
+¡¡¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤Ë¥á¥Ã¥»¡¼¥¸eval¤òÁ÷¤ë¤³¤È¤Ë¤è¤ê¡¢
+´Ø¿ô¤ò¤Ä¤¯¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£½ñ¼°¤Ï¡¢´Ø¿ôÄêµÁ¤Ë¤Û¤Ü
+Ʊ¤¸¤Ç¤¹¡£¤¿¤À¡¢¿·¤¿¤Ë¡¢arg: ¤È¤¤¤¦Í×ÁǤò»ØÄê¤Ç¤­¤Þ¤¹¡£
+¡¡arg:¡¡¤Ï°ú¿ô¤Î¥ê¥¹¥È¤Ç¤¹¡£
+
+¡¡Îã¡£
+
+<pre>
+  f = {arg:[x]; do:[x * x]; } eval;
+</pre>
+¡¡¤³¤ì¤Ç¡¢Æó¾è¤òµá¤á¤ë´Ø¿ô¤òÄêµÁ¤Ç¤­¤Þ¤¹¡£
+
+
+...¥¯¥í¡¼¥¸¥ã
+¡Ê¹©»öÃæ¡Ë
+
+
+...À©¸æ¹½Â¤
+
+¡¡À©¸æ¹½Â¤¤Ï match ¤È loop ¤Î£²¼ïÎà¤À¤±¤Ç¤¹¡£
+
+....match
+
+¡¡soopy¤Ë¤ª¤±¤ëmatch¤Ï¡¢¤Û¤«¤Î¸À¸ì¤È¤Ï°ã¤¤¡¢
+¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Î¤¿¤á¤Î¹½Ê¸¤Ç¤¹¡£
+¡¡ÌµÏÀ¡¢ÉáÄ̤Ëʬ´ô½èÍý¤âµ­½Ò¤Ç¤­¤Þ¤¹¡£
+
+¡¡°ìÈ̤ˡ¢match¤Ï¼¡¤Î·Á¤ò¤·¤Æ¤¤¤Þ¤¹¡£
+
+<pre>
+  match(¼°){
+    ¥Ñ¥¿¡¼¥ó£±¡§ [¼°¤¬¥Ñ¥¿¡¼¥ó£±¤Ë¥Þ¥Ã¥Á¤·¤¿¤È¤­¼Â¹Ô¤µ¤ì¤ëʸ¤Î¥ê¥¹¥È];
+    ¥Ñ¥¿¡¼¥ó£²¡§ [¼°¤¬¥Ñ¥¿¡¼¥ó£²¤Ë¥Þ¥Ã¥Á¤·¤¿¤È¤­¼Â¹Ô¤µ¤ì¤ëʸ¤Î¥ê¥¹¥È];
+    ....
+    ¥Ñ¥¿¡¼¥óN¡§ ¡¡[¼°¤¬¥Ñ¥¿¡¼¥óN¤Ë¥Þ¥Ã¥Á¤·¤¿¤È¤­¼Â¹Ô¤µ¤ì¤ëʸ¤Î¥ê¥¹¥È];
+  };
+</pre>
+
+¡¡Îã¡£
+<pre>
+    match(i > 10){
+      true:  [¼°¤Î¥ê¥¹¥È£±];
+      false: [¼°¤Î¥ê¥¹¥È£²];
+    };
+</pre>
+¡¡¡¡¤â¤·¡¢i > 10 ¤¬¿¿¤Ê¤é¤Ð¡¢true¡¡¤È¥Þ¥Ã¥Á¤·¤Æ¡¢
+¼°¤Î¥ê¥¹¥È£±¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£¤â¤·¡¢µ¶¤Ê¤é¤Ð¡¢
+false¤È¥Þ¥Ã¥Á¤·¤Æ¡¢¼°¤Î¥ê¥¹¥È£²¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
+
+¡¡¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤¬¤â¤Ã¤È¤â°ÒÎϤòȯ´ø¤¹¤ë¤Î¤Ï¡¢¥Ñ¥¿¡¼¥ó¤Ë
+ÊÑ¿ô¤¬´Þ¤Þ¤ì¤ë¤È¤­¤Ç¤¹¡£
+<pre>
+  match([2,3,4]){
+    [x,y,z]; [println x y z]; # £ø¤Ï£²¡¤£ù¤Ï£³¡¤£ú¤Ï£´¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤Æ¤«¤é¡¢
+                              # Ê¸¤Î¥ê¥¹¥È¤¬¼Â¹Ô¤µ¤ì¤ë¡£
+  };
+</pre>
+
+¡¡¥Ñ¥¿¡¼¥ó¤Ë¤Ï¡¢¤µ¤Þ¤¶¤Þ¤Ê¤â¤Î¤¬¤¢¤ê¤Þ¤¹¡£
+<pre>
+  match(variable){
+    0:        [.....]; # ¥Ñ¥¿¡¼¥ó¤Ï¡¢À°¿ô¤À¤Ã¤¿¤ê¡¢
+    'c':      [....];  # Ê¸»ú¤À¤Ã¤¿¤ê¡¢
+    "string": [ ....]; # Ê¸»úÎó¤À¤Ã¤¿¤ê¡¢
+    [x,y]:    [....];  # ¥ê¥¹¥È¤À¤Ã¤¿¤ê¡¢
+    (n,m,l):  [....];  # ¥¿¥×¥ë¤À¤Ã¤¿¤ê¡¢
+    true:     [....];  # ¿¿µ¶ÃͤÀ¤Ã¤¿¤ê¤·¤Þ¤¹¡£
+    other:    [....];  # ¤Þ¤¿¡¢¥·¥ó¥Ü¥ë¤Ï¤¹¤Ù¤Æ¤Î¥Ñ¥¿¡¼¥ó¤Ë°ìÃפ·¤Þ¤¹¡£
+                       # ¤³¤Î¤È¤­¡¢variable ¤ÎÃͤ¬¡¢ other ¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤Þ¤¹¡£
+  };
+</pre>
+
+
+....loop
+
+¡¡loop¤Ï¼¡¤Î·Á¼°¤ò¤·¤Æ¤¤¤Þ¤¹¡£
+
+  loop Label Namespace;
+
+¡¡¶ñÂÎŪ¤Ë¤Ï¡¢
+
+<pre>
+  loop Label {
+    from: [¥ë¡¼¥×¤ËÆþ¤ëÁ°¤Ë¼Â¹Ô¤µ¤ì¤ë¼°¤Î¥ê¥¹¥È];
+    step: [¼¡¤Î¥ë¡¼¥×¤ËÆþ¤ë¤È¤­¤Ë¡¢¼Â¹Ô¤µ¤ì¤ë¼°¤Î¥ê¥¹¥È];
+    while: [¼°¤¬µ¶¤Ë¤Ê¤ë¤È¥ë¡¼¥×¤ò½ªÎ»]; (¤Þ¤¿¤Ï¡¢until: [])
+    do: [
+¡¡¡¡¡¡¡¡¥ë¡¼¥×ËÜÂÎ
+    ];
+    variant: [];¡¡¡¡¡ô¡¡¥ë¡¼¥×ÊѲ½É½ÌÀ¡Ê¸½»þÅÀ¤Ç¤Ï°Ọ̵̃¤·¡Ë
+    invariant: [];¡¡¡ô¡¡¥ë¡¼¥×ÉÔÊÑɽÌÀ¡Ê¸½»þÅÀ¤Ç¤Ï°Ọ̵̃¤·¡Ë
+  };
+</pre>
+
+¡¡¤È¤¤¤¦·Á¤ò¤·¤Æ¤¤¤Þ¤¹¡£Label¤Ï¾Êά²Äǽ¤Ç¤¹¡£
+¤Þ¤¿¡¢¥Í¡¼¥à¥¹¥Ú¡¼¥¹Æâ¤Î¤¹¤Ù¤Æ¤ÎÍ×ÁǤâ¾Êά²Äǽ¤Ç¤¹¡£
+
+.....exit
+
+¡¡¥ë¡¼¥×Æâ¤Ç¡¢
+
+  exit;
+
+¡¡¤È¤¤¤¦¼°¤¬É¾²Á¤µ¤ì¤ë¤È¡¢°ìÈÖÆ⦤Υ롼¥×¤òæ½Ð¤·¤Þ¤¹¡£
+¤¢¤ë¤¤¤Ï¡¢
+
+  Label.exit;
+
+  ¤È¤¹¤ë¤È¡¢Label¤¬°ìÃפ¹¤ë¥ë¡¼¥×¤òæ½Ð¤·¤Þ¤¹¡£
+¤µ¤é¤Ë¡¢
+
+  Label.exit(¼°);
+
+¡¡¤È¤¹¤ë¤È¡¢Label¤¬°ìÃפ¹¤ë¥ë¡¼¥×¤òæ½Ð¤·¡¢¼°¤ÎÃͤòloop¼°¤Î
+ÃͤȤ·¤Þ¤¹¡£
+¡¡¥é¥Ù¥ë¤Î¤Ê¤¤¡¢exit(¼°)¡¨¤Ç¤âÃͤòÊÖ¤»¤Þ¤¹¡£
+
+
+.....next
+
+  next; ¤Ï¡¢¥ë¡¼¥×¤ÎÀèƬ¤ËÌá¤ê¤Þ¤¹¡£¥é¥Ù¥ë¤Ä¤­¤Î
+Labe.next;¡¡¤Ï¡¢Label¤¬°ìÃפ¹¤ë¥ë¡¼¥×¤ÎÀèƬ¤ËÌá¤ê¤Þ¤¹¡£
+
+
+...Æþ½ÐÎÏ
+....¥Õ¥¡¥¤¥ëÆþ½ÐÎÏ
+
+¡¡¥Õ¥¡¥¤¥ë¤ÎÆþ½ÐÎϤˤϡ¢¤½¤ì¤¾¤ìopenIn, openOut ¤È¤¤¤¦
+¥×¥ê¥ß¥Æ¥£¥Ö¤ò»È¤¤¤Þ¤¹¡£
+¡¡openIn ¤Ï¡¢ÆþÎÏÍѤΥե¡¥¤¥ë¤ò³«¤­¤Þ¤¹¡£
+¡¡openOut ¤Ï¡¢½ÐÎÏÍѤΥե¡¥¤¥ë¤ò³«¤­¤Þ¤¹¡£
+¡¡»È¤¤½ª¤ï¤Ã¤¿¥Õ¥¡¥¤¥ë¤Ïɬ¤ºclose ¥á¥Ã¥»¡¼¥¸¤òÁ÷¤Ã¤Æ
+ÊĤ¸¤Æ¤ª¤­¤Þ¤·¤ç¤¦¡£
+
+¡¡Îã¡£
+
+<pre>
+    fin = openIn "filename";¡¡¡¡/*¡¡ÆþÎÏ¥Õ¥¡¥¤¥ë¤Î¥ª¡¼¥×¥ó¡¡*/
+    line = fin readline;¡¡  ¡¡¡¡/*¡¡£±¹ÔÆɤ߹þ¤ß¡¡*/
+    ch  = fin readChar;         /*¡¡£±Ê¸»úÆɤ߹þ¤ß */
+    fin close;                  /*¡¡³«¤¤¤¿¤éɬ¤ºÊĤ¸¤ë¡¡*/
+
+    fout = openOut "output";    /*¡¡½ÐÎÏ¥Õ¥¡¥¤¥ë¤Î¥ª¡¼¥×¥ó¡¡*/
+    fout writeChar 'A';         /*¡¡£±Ê¸»ú½ÐÎÏ¡¡*/
+    p = fout printline;         /*¡¡½ÐÎÏÍÑ´Ø¿ô¤ò¡¢ÊÑ¿ô¤ËÂåÆþ¤·¤È¤¯¤Î¤¬¡¢soopyή¡¡*/
+    p "first line";             /*¡¡£±¹Ô½ÐÎÏ¡¡*/
+    p "second line";
+    p "third line";
+    fout close;                 /*¡¡³«¤¤¤¿¤éɬ¤ºÊĤ¸¤ë¡¡*/
+</pre>
+
+....Socket
+
+¡¡Socket¡Ê¥¯¥é¥¤¥¢¥ó¥È¡Ë¤ò³«¤¯¤Ë¤Ï¡¢ÁȤ߹þ¤ß¥ª¥Ö¥¸¥§¥¯¥ÈSocket¤Ë
+¥á¥Ã¥»¡¼¥¸open¤òÁ÷¤ê¤Þ¤¹¡£½ñ¼°¤Ï¡¢
+<pre>
+   Socket open hostname port
+</pre>
+¡¡¤Ç¤¹¡£
+¡¡Socket¤Ï¡¢eof?, write, writeline, readline ¤Î£´¤Ä¤Î
+¥á¥Ã¥»¡¼¥¸¤ò¼õ¤±ÉÕ¤±¤Þ¤¹¡£
+¡¡»È¤¤½ª¤ï¤Ã¤¿Socket¤Ïɬ¤ºclose ¥á¥Ã¥»¡¼¥¸¤òÁ÷¤Ã¤Æ
+ÊĤ¸¤Æ¤ª¤­¤Þ¤·¤ç¤¦¡£
+
+¡¡Îã¡£
+
+<pre>
+  sock = Socket open "sourceforge.jp" 80;
+  w = sock writeline;
+  w "GET /index.html HTTP/1.0";
+  w "Accept: */*";
+  w "";
+
+  reader = EucJP encoderIn sock;
+  loop {
+    until: reader eof?;
+    do: [
+      line = reader readline;
+      println line;
+    ];
+  };
+  sock close;
+</pre>
+
+
+..¥ê¥Õ¥¡¥ì¥ó¥¹
+...ͽÌó¸ì
+¡¡soopy¤Ï°Ê²¼¤Î¸ì¤òͽÌó¸ì¤È¤·¤Æ¤¤¤Þ¤¹¡£
+¡¡Í½Ìó¸ì¤Ï»È¤Ã¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£
+
+object, number, int, real, bool, string, char, nil
+fun, const, property, private, public
+match, super, true, false, loop, next, redo, retry
+
+...ÁȤ߹þ¤ß¥ª¥Ö¥¸¥§¥¯¥È
+
+....Soopy
+¡¡¥·¥¹¥Æ¥à´ØÏ¢¤Î¥Ç¡¼¥¿¤òÊÝ»ý¤·¤Æ¤¤¤Þ¤¹¡£
+
+.....CommandLine
+¡¡¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¤ò¥ê¥¹¥È¤È¤Î·Á¤ÇÊÝ»ý¤·¤Æ¤¤¤Þ¤¹¡£
+¡¡Îã¡£
+<pre>
+    match(Soopy CommandLine){
+      []: 0;
+      [arg1]: 1;
+      [arg1, arg2]: 2;
+      [arg1, arg2, arg3]: 3;
+      _: "Many args!";
+    };
+</pre>
+
+.....Date
+¡¡ÆüÉÕ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë¤¿¤á¤Ë»ÈÍѤ·¤Þ¤¹¡£
+
+      new year month day
+¡¡¡¡¡¡¡¡¿·¤·¤¤ÆüÉÕ¤òÊÖ¤¹¡£
+
+      today
+¡¡¡¡¡¡¡¡º£Æü¤ÎÆüÉÕ¤òÊÖ¤¹¡£
+
+....Env
+¡¡´Ä¶­ÊÑ¿ô¤òÊÝ»ý¤·¤Æ¤¤¤Þ¤¹¡£
+
+¡¡Îã¡£
+
+<pre>
+    Env "PATH";
+
+    Env "HOME";
+</pre>
+
+
+....Dir
+¡¡Dir·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤òÊÝ»ý¤·¤Æ¤¤¤Þ¤¹¡£
+¤³¤ì¤ò»È¤¦¤³¤È¤Ë¤è¤Ã¤Æ¡¢¥Ç¥£¥ì¥¯¥È¥êÁàºî¤¬½ÐÍè¤Þ¤¹¡£
+
+¡¡Îã¡£
+<pre>
+    Dir chdir "/usr/local/lib";
+
+    Dir mkdir "test";
+
+    Dir rmdir "test";
+
+    Dir list ".";
+
+    Dir pwd;
+</pre>
+
+...Primitive
+....array
+    array:type (dim1,dim2,....,dimN)
+¡¡¡¡¡¡¡¡N¼¡¸µ¤ÎÇÛÎó¤òºî¤ë¡£:type ¤Ï¾Êά²Ä¡£
+¡¡¡¡¡¡¡¡type¤¬»ØÄꤵ¤ì¤Æ¤¤¤ì¤Ð¡¢»ØÄꤵ¤ì¤¿·¿¤Î¤ß¤ÎÇÛÎó¤Ë¤Ê¤ë¡£
+
+....openIn
+    openIn filename
+¡¡¡¡¡¡¡¡Ê¸»úÎófilename¤Çɽ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤òÆþÎÏÍѤ˳«¤¯¡£
+¡¡¡¡¡¡¡¡File(input)¤òÊÖ¤¹¡£
+
+....openOut
+    openOut filename
+¡¡¡¡¡¡¡¡Ê¸»úÎófilename¤Çɽ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤ò½ÐÎÏÍѤ˳«¤¯¡£
+¡¡¡¡¡¡¡¡File(output)¤òÊÖ¤¹¡£
+
+....openAppend
+    openAppend filename
+¡¡¡¡¡¡¡¡Ê¸»úÎófilename¤Çɽ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤òÄɲýñ¤­¹þ¤ßÍѤ˳«¤¯¡£
+¡¡¡¡¡¡¡¡File(output)¤òÊÖ¤¹¡£
+
+....load
+    load filename
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ëfilename¤òsoopy¥×¥í¥°¥é¥à¤È¤·¤Æ¥í¡¼¥É¤¹¤ë¡£
+
+....print
+    print object
+¡¡¡¡¡¡¡¡object¤ò²èÌ̤Ëɽ¼¨¤¹¤ë
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϴؿôprint¼«¿È¡£
+
+....println
+    println object
+¡¡¡¡¡¡¡¡object¤ò²èÌ̤Ëɽ¼¨¤·¡¢¤½¤Î¸å²þ¹Ô¤òɽ¼¨¤¹¤ë¡£
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϴؿôprintln¼«¿È¡£
+
+....quit
+    quit ()
+¡¡¡¡¡¡¡¡soopy¤ò½ªÎ»¤¹¤ë¡£
+
+
+
+...CLASS Reference
+....Array
+
+      depth
+¡¡¡¡¡¡¡¡ÇÛÎó¤Î¼¡¸µ¤òÊÖ¤¹
+
+      dimension
+¡¡¡¡¡¡¡¡ÇÛÎó¤Î¼¡¸µ¤òɽ¤¹¥ê¥¹¥È¤òÊÖ¤¹
+¡¡¡¡¡¡¡¡Îã¡£
+<pre>
+           ary = array (3,4,5);
+           ary dimention;  /* [3,4,5] ¤¬ÊÖ¤ë */
+</pre>
+
+
+....Char
+      isAlpha?, isAlphaNum?, isDigit?
+      isHexDigit?, isLower?, isSpace?, isUpper?
+      isDoubleByteChar?, isWideChar?
+¡¡¡¡¡¡¡¡¤½¤ì¤¾¤ìʸ»ú¤Î¼ïÎà¤òȽÄꤹ¤ë¡£
+
+      lower
+¡¡¡¡¡¡¡¡¾®Ê¸»ú¤òÊÖ¤¹¡£
+
+      pred
+¡¡¡¡¡¡¡¡Ê¸»ú¥³¡¼¥É¤¬Á°¤Îʸ»ú¤òÊÖ¤¹¡£
+
+      succ
+¡¡¡¡¡¡¡¡Ê¸»ú¥³¡¼¥É¤¬¼¡¤Îʸ»ú¤òÊÖ¤¹¡£
+
+      toInt
+¡¡¡¡¡¡¡¡Ê¸»ú¤ÎTRON¥³¡¼¥É¤òÊÖ¤¹¡£
+
+      toString
+¡¡¡¡¡¡¡¡Ê¸»úÎó¤òÊÖ¤¹¡£
+
+      upper
+¡¡¡¡¡¡¡¡Âçʸ»ú¤òÊÖ¤¹¡£
+
+
+....Date
+
+      new year month day
+¡¡¡¡¡¡¡¡¿·¤·¤¤ÆüÉÕ¤òÊÖ¤¹¡£
+
+      today
+¡¡¡¡¡¡¡¡º£Æü¤ÎÆüÉÕ¤òÊÖ¤¹¡£
+
+
+....DateTime
+
+
+....Dir
+
+      chdir aString
+¡¡¡¡¡¡¡¡¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£
+
+      list aDir
+¡¡¡¡¡¡¡¡¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë°ìÍ÷¤ò¥ê¥¹¥È¤ÇÊÖ¤¹¡£
+
+      glob aPath
+¡¡¡¡¡¡¡¡aPath¤Ë¥Þ¥Ã¥Á¤¹¤ë¥Õ¥¡¥¤¥ë¤Î°ìÍ÷¤ò¥ê¥¹¥È¤ÇÊÖ¤¹¡£
+
+      pwd
+¡¡¡¡¡¡¡¡¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤òÊÖ¤¹¡£
+
+      mkdir aString
+¡¡¡¡¡¡¡¡¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤¹¤ë¡£
+
+      rmdir aString
+¡¡¡¡¡¡¡¡¥Ç¥£¥ì¥¯¥È¥ê¤òºï½ü¤¹¤ë¡£
+
+
+....File(input)
+
+      close
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë¡£
+
+      eof?
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤¬ºÇ¸å¤Þ¤Ç¤¤¤Ã¤¿¤«È½Äꤹ¤ë¡£
+
+      peekChar
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤«¤é£±Ê¸»úÀèÆɤߤ¹¤ë¡£
+
+      read
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤ò¤¹¤Ù¤ÆÆɤ߹þ¤à¡£
+
+      readLine
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤ò£±¹ÔÆɤ߹þ¤à¡£
+
+      readLineS
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤«¤é¤¹¤Ù¤Æ¤Î¹Ô¤òÆɤ߹þ¤à¡£
+
+      readChar
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤«¤é£±Ê¸»úÆɤ߹þ¤à¡£
+
+
+
+
+....File(output)
+
+      close
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë¡£
+
+      flush
+¡¡¡¡¡¡¡¡¥Ð¥Ã¥Õ¥¡¤ò¥Õ¥é¥Ã¥·¥å¤¹¤ë¡£
+
+      terpri
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤Ë²þ¹Ô¤ò½ñ¤­½Ð¤¹¡£
+
+      writeChar aChar
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤Ëʸ»úaChar¤ò½ñ¤­½Ð¤¹¡£
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϥ᥽¥Ã¥ÉwriteChar¼«¿È¡£
+
+      write object
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤Ëobject¤Îʸ»úÎóɽ¸½¤ò½ñ¤­½Ð¤¹¡£
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϥ᥽¥Ã¥Éwrite¼«¿È¡£
+
+      writeLine object
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤Ëobject¤Îʸ»úÎóɽ¸½¤È²þ¹Ô¤ò½ñ¤­½Ð¤¹¡£
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϥ᥽¥Ã¥ÉwriteLine¼«¿È¡£
+
+
+....Int
+      toChar
+¡¡¡¡¡¡¡¡À°¿ô(TRON¥³¡¼¥É)¤Çɽ¤µ¤ì¤ëʸ»ú¤òÊÖ¤¹¡£
+
+      toReal
+¡¡¡¡¡¡¡¡À°¿ô¤ò¼Â¿ô¤Ë¤·¤¿ÃͤòÊÖ¤¹¡£
+
+      toString
+¡¡¡¡¡¡¡¡À°¿ô¤Îʸ»úÎóɽ¸½¤òÊÖ¤¹¡£
+
+      repeat aNameSpace
+¡¡¡¡¡¡¡¡À°¿ô²ó¡¢aNameSpace¤ò´Ø¿ô¤È¤·¤Æ¡¢À°¿ô²ó·«¤êÊÖ¤·¼Â¹Ô¤¹¤ë¡£
+
+<pre>
+        Îã.   10 repeat {arg:[x]; do: [println "hello"];};
+
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ê¸½ºß¤Î·«¤êÊÖ¤·²ó¿ô¤¬°ú¿ô¤È¤·¤ÆÅϤµ¤ì¤ë¤Î¤Ç¡¢
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡É¬¤º¡¢arg: ¤Ç¡¢°ú¿ô¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£¡Ë
+</pre>
+
+....List
+
+      head
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤Î¥Ø¥Ã¥ÉÉôʬ(car)¤òÊÖ¤¹¡£
+
+      tail
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤Î¥Æ¡¼¥ëÉôʬ(cdr)¤òÊÖ¤¹¡£
+
+      isList?
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤«¤É¤¦¤«¤ÎȽÄê¡£¾ï¤Ë¿¿¡£
+
+      isNIL?
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤¬¥Ì¥ë¤«¤É¤¦¤«¤òȽÄꤹ¤ë¡£
+
+      nth n
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤ÎnÈÖÌܤÎÍ×ÁǤòÊÖ¤¹¡£¡ÊºÇ½é¤ÎÍ×ÁǤϣ°ÈÖÌÜ¡Ë
+
+      each func
+¡¡¡¡¡¡¡¡¥ê¥¹¥ÈÆâ¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¡¢´Ø¿ôfunc¤òŬÍѤ¹¤ë¡£
+¡¡¡¡¡¡¡¡ÊÖ¤êÃͤÏVoid¡£
+
+      foldl func
+¡¡¡¡¡¡¡¡¥ê¥¹¥ÈÆâ¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¡¢£²°ú¿ô¤Î´Ø¿ôfunc¤ò
+¡¡¡¡¡¡¡¡º¸¤«¤é½çÈÖ¤ËŬÍѤ·¤¿ÃͤòÊÖ¤¹¡£
+
+      foldr
+¡¡¡¡¡¡¡¡¥ê¥¹¥ÈÆâ¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¡¢£²°ú¿ô¤Î´Ø¿ôfunc¤ò
+¡¡¡¡¡¡¡¡±¦¤«¤é½çÈÖ¤ËŬÍѤ·¤¿ÃͤòÊÖ¤¹¡£
+
+      map func
+¡¡¡¡¡¡¡¡¥ê¥¹¥ÈÆâ¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¡¢´Ø¿ôfunc¤òŬÍѤ·¤¿
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤òÊÖ¤¹¡£
+
+      member aObject
+¡¡¡¡¡¡¡¡aObject¤¬´Þ¤Þ¤ì¤ë¤«¤É¤¦¤«¿¿µ¶ÃͤòÊÖ¤¹¡£
+
+      sort
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤òÀ°Îó¤·¤¿¥ê¥¹¥È¤òÊÖ¤¹¡£
+
+      filter aFunc
+¡¡¡¡¡¡¡¡aFunc¤Ë¤ï¤¿¤¹¤È¿¿¤Ë¤Ê¤ë¥Ç¡¼¥¿¤À¤±¤Î¥ê¥¹¥È¤òÊÖ¤¹¡£
+
+
+
+....NameSpace
+      rename aNameSpace
+¡¡¡¡¡¡¡¡aNameSpace(¤â¤È¤Î̾Á°¡§Êѹ¹¸å¤Î̾Á°¤ÎÂСˤˤâ¤È¤Å¤­
+¡¡¡¡¡¡¡¡¥Õ¥£¡¼¥ë¥É̾¤òÊѹ¹¤·¤¿¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤òÊÖ¤¹¡£
+
+      append aSymbol aObject
+¡¡¡¡¡¡¡¡aSymbol->aObject¤ÎÂФòÄɲ乤ë¡ÊÇ˲õŪÁàºî¡Ë¡£
+
+      eval
+¡¡¡¡¡¡¡¡¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò´Ø¿ô²½¤·¤ÆÊÖ¤¹¡£
+
+      keys
+¡¡¡¡¡¡¡¡¤¹¤Ù¤Æ¤Î¥­¡¼¤Î¥ê¥¹¥È¤òÊÖ¤¹¡£
+
+      delete aKey
+¡¡¡¡¡¡¡¡aKey¤òºï½ü¤¹¤ë¡ÊÇ˲õŪÁàºî¡Ë¡£
+
+      lookup aKey
+¡¡¡¡¡¡¡¡aKey¤ËÂбþ¤¹¤ëÃͤòÊÖ¤¹¡£
+
+
+....Real
+      toInt
+¡¡¡¡¡¡¡¡¼Â¿ô¤ÎÀ°¿ôÉô¤òÊÖ¤¹¡£
+
+      toString
+¡¡¡¡¡¡¡¡¼Â¿ô¤Îʸ»úÎóɽ¸½¤òÊÖ¤¹¡£
+
+      abs
+¡¡¡¡¡¡¡¡ÀäÂÐÃͤòÊÖ¤·¤Þ¤¹¡£
+
+      acos
+¡¡¡¡¡¡¡¡¥¢¡¼¥¯¥³¥µ¥¤¥ó¡ÊµÕ;¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      asin
+¡¡¡¡¡¡¡¡¥¢¡¼¥¯¥µ¥¤¥ó¡ÊµÕÀµ¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      atan
+¡¡¡¡¡¡¡¡¥¢¡¼¥¯¥¿¥ó¥¸¥§¥ó¥È¡ÊµÕÀµÀܡˤòÊÖ¤·¤Þ¤¹¡£
+
+      atan2 y
+¡¡¡¡¡¡¡¡y/self ¤Î¥¢¡¼¥¯¥¿¥ó¥¸¥§¥ó¥È¤òÊÖ¤·¤Þ¤¹¡£
+ ¡¡¡¡¡¡¡Êself¡Ë¤Ï¥á¥Ã¥»¡¼¥¸¤òÁ÷¤é¤ì¤¿¼Â¿ô¼«¿È¡£
+
+      ceil
+¡¡¡¡¡¡¡¡¾®¿ôÅÀ°Ê²¼¤òÀÚ¤ê¾å¤²¤¿ÃͤòÊÖ¤·¤Þ¤¹¡£
+
+      cos
+¡¡¡¡¡¡¡¡¥³¥µ¥¤¥ó¡Ê;¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      cosh
+¡¡¡¡¡¡¡¡¥Ï¥¤¥Ñ¥Ü¥ê¥Ã¥¯¥³¥µ¥¤¥ó¡ÊÁжÊÀþ;¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      exp
+¡¡¡¡¡¡¡¡»Ø¿ô´Ø¿ô£å¤Îself¾è¤òÊÖ¤·¤Þ¤¹¡£
+
+      floor
+¡¡¡¡¡¡¡¡¾®¿ôÅÀ°Ê²¼¤òÀÚ¤ê¼Î¤Æ¤¿ÃͤòÊÖ¤·¤Þ¤¹¡£
+
+      fmod y
+¡¡¡¡¡¡¡¡self¤òy¤Ç³ä¤Ã¤¿¾ê;¤òÊÖ¤·¤Þ¤¹¡£
+
+      frexp
+¡¡¡¡¡¡¡¡²¾¿ôÉô£í¤È»Ø¿ôÉô£î¤ÎÁÈ¡Ê£í¡¢£î¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      hypot y
+¡¡¡¡¡¡¡¡Ä¾³Ñ»°³Ñ·Á¤Î¼ÐÊÕ¤ÎŤµ¤ò·×»»¤·¤Þ¤¹¡£
+
+      ldexp exp
+¡¡¡¡¡¡¡¡self * 2 ^exp ¤òÊÖ¤·¤Þ¤¹¡£
+
+      log
+¡¡¡¡¡¡¡¡¼«Á³Âпô¤òÊÖ¤·¤Þ¤¹¡£
+
+      log10
+¡¡¡¡¡¡¡¡¾ïÍÑÂпô¤òÊÖ¤·¤Þ¤¹¡£
+
+      pow y
+¡¡¡¡¡¡¡¡self ¤Î y¾è¤òÊÖ¤·¤Þ¤¹¡£
+
+      sin
+¡¡¡¡¡¡¡¡¥µ¥¤¥ó¡ÊÀµ¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      sinh
+¡¡¡¡¡¡¡¡¥Ï¥¤¥Ñ¥Ü¥ê¥Ã¥¯¥µ¥¤¥ó¡ÊÁжÊÀþÀµ¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      sqrt
+¡¡¡¡¡¡¡¡Ê¿Êýº¬¤òÊÖ¤·¤Þ¤¹¡£
+
+      tan
+¡¡¡¡¡¡¡¡¥¿¥ó¥¸¥§¥ó¥È¡ÊÀµÀܡˤòÊÖ¤·¤Þ¤¹¡£
+
+      tanh
+¡¡¡¡¡¡¡¡¥Ï¥¤¥Ñ¥Ü¥ê¥Ã¥¯¥¿¥ó¥¸¥§¥ó¥È¡ÊÁжÊÀþÀµÀܡˤòÊÖ¤·¤Þ¤¹¡£
+
+
+....Socket
+
+      close
+¡¡¡¡¡¡¡¡Socket¤òÊĤ¸¤ë¡£
+
+      eof?
+¡¡¡¡¡¡¡¡Socket¤¬ºÇ¸å¤Þ¤Ç¤¤¤Ã¤¿¤«È½Äꤹ¤ë¡£
+
+      readLine
+¡¡¡¡¡¡¡¡Socket¤«¤é£±¹ÔÆɤ߹þ¤à¡£
+
+      flush
+¡¡¡¡¡¡¡¡¥Ð¥Ã¥Õ¥¡¤ò¥Õ¥é¥Ã¥·¥å¤¹¤ë¡£
+
+      write aString
+¡¡¡¡¡¡¡¡Socket¤Ëʸ»úÎó¤ò½ñ¤­½Ð¤¹¡£
+
+      writeLine aString
+¡¡¡¡¡¡¡¡Socket¤Ëʸ»úÎó¤È²þ¹Ô(CR+LF)¤ò½ñ¤­½Ð¤·¡¢
+¡¡¡¡¡¡¡¡¥Ð¥Ã¥Õ¥¡¤ò¥Õ¥é¥Ã¥·¥å¤¹¤ë¡£
+
+
+....String
+
+      length
+¡¡¡¡¡¡¡¡Ê¸»úÎó¤ÎŤµ¡£
+
+      sub (i,j)
+¡¡¡¡¡¡¡¡iÈÖÌܤÎʸ»ú¤«¤é¡¢jʸ»úʬ¤Îʸ»úÎó¡£
+
+      nth n
+¡¡¡¡¡¡¡¡nÈÖÌܤÎʸ»ú¡£
+
+      symbol
+¡¡¡¡¡¡¡¡Ê¸»úÎ󤫤饷¥ó¥Ü¥ë¤òºî¤ë¡£
+
+      split aChar
+¡¡¡¡¡¡¡¡aChar¤Çʸ»úÎó¤òʬ³ä¤·¤¿¥ê¥¹¥È¤òÊÖ¤¹¡£
+
+      tr aChar1 aChar2
+¡¡¡¡¡¡¡¡aChar1¤òaChar2¤Ç¤¹¤Ù¤ÆÃÖ¤­´¹¤¨¤¿Ê¸»úÎó¤òÊÖ¤¹¡£
+
+      reader
+¡¡¡¡¡¡¡¡Ê¸»úÎó¥ê¡¼¥À¤òÊÖ¤¹¡£
+
+      upper
+¡¡¡¡¡¡¡¡¾®Ê¸»ú¤ò¤¹¤Ù¤ÆÂçʸ»ú¤ËÃÖ¤­´¹¤¨¤¿Ê¸»úÎó¡£
+
+      lower
+¡¡¡¡¡¡¡¡Âçʸ»ú¤ò¤¹¤Ù¤Æ¾®Ê¸»ú¤ËÃÖ¤­´¹¤¨¤¿Ê¸»úÎó¡£
+
+      replace aString1 aString2
+¡¡¡¡¡¡¡¡aString1¤òaString2¤Ë¤¹¤Ù¤ÆÃÖ¤­´¹¤¨¤¿Ê¸»úÎó¡£
+
+      toInt
+¡¡¡¡¡¡¡¡Ê¸»úÎ󤫤éÀ°¿ô¤òÊÖ¤¹¡£
+
+      find aString aInt
+¡¡¡¡¡¡¡¡aString¤òaIntÈÖÌܤÎʸ»ú¤«¤é¸¡º÷¤ò¤Ï¤¸¤á
+¡¡¡¡¡¡¡¡¸«¤Ä¤«¤Ã¤¿¾ì½ê¡Ê²¿ÈÖÌܤ«¡Ë¤òÊÖ¤¹¡£
+¡¡¡¡¡¡¡¡¤¿¤À¤·¡¢ºÇ½é¤Îʸ»ú¤Ï£°ÈÖÌܤȤ¹¤ë¡£
+
+....Time
+
+      new hour minute second
+¡¡¡¡¡¡¡¡¿·¤·¤¤»þ¹ï¤òÊÖ¤¹¡£
+
+      now
+¡¡¡¡¡¡¡¡º£¤Î»þ¹ï¤òÊÖ¤¹¡£
+
+
+....Tuple
+
+      length
+¡¡¡¡¡¡¡¡¥¿¥×¥ë¤Î¥µ¥¤¥º¡£
+
+      first
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      second
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      third
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      fourth
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      fifth
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      nth n
+¡¡¡¡¡¡¡¡nÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+
+
+
+..License
+
+Copyright (C) 2002 by SUZUKI Jun. All rights reserved.
+
+¤³¤Î¥½¥Õ¥È¥¦¥§¥¢¡Êsoopy¡Ë¤ÏGPL(GNU General Public License)¤Ë
+½¾¤Ã¤Æ¤¤¤Þ¤¹¡£
+Á´¤Æ¤Î¸¢Íø¤Ïºî¼Ô(SUZUKI Jun)¤¬ÊÝ»ý¤·¤Æ¤¤¤Þ¤¹¤¬¡¢
+ÍøÍÑ¡¢ºÆÇÛÉÛ¤ÏGPL¤Ë½¾¤¦¸Â¤ê¼«Í³¤Ç¤¹¡£ºÆÇÛÉۤˤÏÏ¢Íí¤ÏÉÔÍפǤ¹¡£
+
+¤Ê¤ª¡¢ºî¼Ô¤ÏÍøÍѼԤ¬ËÜ¥½¥Õ¥È¥¦¥§¥¢¤òÍøÍѤ·¤¿¤³¤È¤Ë¤è¤ê
+À¸¤¸¤¿¤¤¤«¤Ê¤ë»³²¤Ë¤â¤½¤ÎÀÕǤ¤òÉ餤¤Þ¤»¤ó¡£
+
+
+
+..»²¹Íʸ¸¥¤Ê¤É
+
+»²¹Í¤Ë¤·¤¿¸À¸ì
+
+LENS(<A HREF="http://prog.vub.ac.be/poolresearch/lens/contents.html" TARGET="_blank">http://prog.vub.ac.be/poolresearch/lens/contents.html</A>)
+
+»²¹Í½ñÀÒ
+
+C¥Þ¥¬¥¸¥ó¡¡£±£¹£¹£¹Ç¯£¸¡¢£¹·î¹æ¡¡¡¡¡¡¥½¥Õ¥È¥Ð¥ó¥¯¡¡¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°´©
+¡¡¡Ö³ØÌä¤Î¥¹¥¹¥á¡×¡¡¤­¤À¤¢¤­¤é
+
+
+
diff --git a/doc/tutorial/tutorial.txt b/doc/tutorial/tutorial.txt
new file mode 100644 (file)
index 0000000..d0bb244
--- /dev/null
@@ -0,0 +1,1196 @@
+
+.soopy
+
+soopy¤ÏLENS¤äEiffel,StandardMLÅù¤ò»²¹Í¤Ë¡¢¤Ê¤ë¤Ù¤¯Ã±½ã¤Êʸˡ¤ò
+¤á¤¶¤·¤Æºî¤é¤ì¤¿¥×¥í¥°¥é¥à¸À¸ì¤Ç¤¹¡£
+
+Æÿ§¡§¡Ê²¼¤Ë¤¤¤¯¤Ë¤·¤¿¤¬¤Ã¤Æ¤À¤ó¤À¤ó²ø¤·¤¯¤Ê¤ê¤Þ¤¹¡£¡Ë
+
+¡¡¡¡¡¦¥·¥ó¥×¥ë¤Êʸˡ
+¡¡¡¡¡¦Lisp¤ÈSmalltalk¤ÈML¤ò­¤·¤Æ3¤Ç³ä¤Ã¤¿¤è¤¦¤ÊÊ·°Ïµ¤
+¡¡¡¡¡¦Ë­ÉÙ¤ÊÁȤ߹þ¤ß·¿
+¡¡¡¡¡¦¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á
+¡¡¡¡¡¦¥¯¥é¥¹¤È¤¤¤¦³µÇ°¤¬¤Ê¤¤¤Î¤Ë¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ
+¡¡¡¡¡¦´Ø¿ô·¿¸À¸ì¤È¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¸À¸ì¤¬Èù̯¤Ëº®¤¶¤Ã¤¿¸À¸ì»ÅÍÍ
+
+
+
+¤Ê¤ª¡¢¤³¤Î¥É¥­¥å¥á¥ó¥È¤Ïµ×ÊÝ͵°ìϺ»á¤Î¡ÚtxtCompile¡Û¤ò
+»ÈÍѤ·¤Æºî¤é¤ì¤Æ¤¤¤Þ¤¹¡£´¶¼Õ¡£
+
+
+..¥¤¥ó¥¹¥È¡¼¥ë
+
+¼Â¹Ô¥Õ¥¡¥¤¥ësoopy(.exe)¤ò¥Ñ¥¹¤Î¤È¤ª¤Ã¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ËÃÖ¤­¤Þ¤¹¡£
+°Ê¾å¡£
+
+
+..³µÍ×
+
+ʸ¤Î¼ïÎà
+¡¡Ã±½ã¤Ê¼°
+¡¡ÂåÆþʸ
+¡¡¥á¥Ã¥»¡¼¥¸¼°
+¡¡¥³¥á¥ó¥È
+
+¤µ¤Þ¤¶¤Þ¤ÊÁȤ߹þ¤ß·¿
+
+
+...ʸ¤Î¼ïÎà
+
+¡¡¡¡soopy¤Î¹½Ê¸¤ÏÈó¾ï¤Ëñ½ã¤Ç¤¹¡£Â礭¤¯¤ï¤±¤ë¤È¼¡¤Î£µ¼ïÎà¤À¤±¤Ç¤¹¡£
+
+¡¡¡¡¡¡£±¡¥»»½Ñ¼°¡Ê¡Ü¡¢¡Ý¡¢¡ö¡¢¡¿¡¢¡ó¡Ë¡¢ÏÀÍý¼°¡Êand¡¢or¡Ë¤Ê¤É¤Îñ½ã¤Ê¼°
+¡¡¡¡¡¡£²¡¥ÂåÆþʸ
+¡¡¡¡¡¡£³¡¥¥á¥Ã¥»¡¼¥¸¼°
+¡¡¡¡¡¡£´¡¥À©¸æ¹½Â¤ -- ¾ò·ïʬ´ô(if)¤È·«¤êÊÖ¤·(loop)¡£
+¡¡¡¡¡¡£µ¡¥Äê¿ô¤ä´Ø¿ô¤ÎÀë¸À¡£
+
+¡¡¡¡¤½¤ì¤¾¤ì¤Îʸ¤Ë¤Ä¤¤¤Æ´Êñ¤ËÀâÌÀ¤·¤Þ¤¹¡£
+
+....ñ½ã¤Ê¼°
+
+¡¡¡¡¡¡¡¡Ã±½ã¤Ê¼°¤Ë¤Ï¡¢Ã±¹à±é»»»Ò¤È£²¹à±é»»»Ò¤¬¤¢¤ê¤Þ¤¹¡£
+
+¡¡¡¡¡¡¡¡¡¡»»½Ñ¼°¤Î
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡²Ã»»¡Ê¡Ü¡Ë¡¢¸º»»¡Ê¡Ý¡Ë¡¢³Ý¤±»»¡Ê¡ö¡Ë¡¢³ä¤ê»»¡Ê¡¿¡Ë¡¢¾ê;¡Ê¡ó¡Ë
+¡¡¡¡¡¡¡¡¡¡ÏÀÍý¼°¤Î
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥¢¥ó¥É¡Êand¡Ë¡¢¥ª¥¢¡Êor¡Ë¡¢ÈÝÄê¡Ê¡ª¡Ë
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÅùÃÍ¡Ê¡á¡á¡Ë¡¢Åù¤·¤¯¤Ê¤¤¡Ê¡ª¡á¡Ë¡¢
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡Â礭¤¤¡Ê¡ä¡Ë¡¢°Ê¾å¡Ê¡ä¡á¡Ë¡¢¾®¤µ¤¤¡Ê¡ã¡Ë¡¢°Ê²¼¡Ê¡ã¡á¡Ë
+¡¡¡¡¡¡¡¡¡¡¤½¤Î¤Û¤«¤Ë¡¢Lisp¤Ë¤ª¤±¤ëCons¤ËÃͤ¹¤ë¡Ê¡§¡§¡Ë±é»»»Ò¤ä¡¢¡÷±é»»»Ò¤Ê¤É¤¬¤¢¤ê¤Þ¤¹¡£
+
+¡¡¡¡¡¡±é»»»Ò¤ÎÍ¥Àè½ç°Ì¤Ï°Ê²¼¤Î¤È¤ª¤ê¤Ç¤¹¡£¡Ê¤¿¤À¤·¡¢¾­ÍèŪ¤Ë¤ÏÍ¥Àè½ç°Ì¤Ï
+¡¡¡¡¡¡ÊѤï¤ë²ÄǽÀ­¤â¤¢¤ë¡£¡Ê¸½»þÅÀ¤Ç¤Ï¿¼¤¯¹Í¤¨¤Æ¤Ê¤¤¤â¤ó¤Ç¡£¡£¡£^_^;¡Ë¡Ë
+
+¡¡¡¡¡¡¡¡Í¥Àè½ç°Ì
+
+<pre>
+¡¡¡¡¡¡¡¡¡¡Ä㤤¡¡¡¡or
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡and
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ª
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡==, !=
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡>, >=, <, <=
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡+, -
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡*, /, %
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ý¡Êñ¹à¡Ë
+¡¡¡¡¡¡¡¡¡¡¹â¤¤¡¡¡¡.., ::, //, @
+</pre>
+
+
+
+....ÂåÆþʸ
+
+.....ÉáÄ̤ÎÂåÆþ
+
+¡¡¡¡¡¡¡¡ÂåÆþʸ¤Ï¡¢¥¤¥³¡¼¥ë¡Ê¡á¡Ë¤Ç·ë¤Ð¤ì¤¿º¸Êդλؤ·¼¨¤¹¾ì½ê¤Ë
+¡¡¡¡¡¡±¦ÊÕ¤ÎÃͤò·ë¤ÓÉÕ¤±¤Þ¤¹¡£
+¡¡¡¡¡¡¡¡¤Þ¡£¼ê³¤­·¿¤Î¸À¸ì¤Ë¤Ï¤è¤¯¤¢¤ë¤ä¤Ä¤Ç¤¹¡£
+
+¡¡¡¡¡¡¡¡Îã¡£
+<pre>
+              pi = 3.14;
+
+              msg = "Hello, world!";
+
+              anArray(2,3) = 'c';
+
+              square = {arg:[x]; do:[x * x];};
+
+              anObject aFeature = "Hummm?";
+
+</pre>
+¡¡¡¡¡¡¡¡¡¡¡¡¤Ê¤É¤Ê¤É¡£
+
+.....¿½ÅÂåÆþ
+
+¡¡¡¡¡¡¡¡Â¿½ÅÂåÆþ¤Ï°ìÅÙ¤ËÊ£¿ô¤Î¾ì½ê¤ËÃͤò·ë¤Ó¤Ä¤±¤Þ¤¹¡£
+
+¡¡¡¡¡¡¡¡Îã¡£
+<pre>
+              let (x,y,z) = (2, 'a', "hello");
+</pre>
+
+
+....¥á¥Ã¥»¡¼¥¸¼°
+
+¡¡¡¡¡¡¡¡¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¸À¸ì¤Ë¤È¤Ã¤Æ¡¢¤â¤Ã¤È¤â½ÅÍפÊʸ¤Ç¤¹¡£
+¡¡¡¡¡¡¤È¤¤¤Ã¤Æ¤â¡¢¤¿¤À¤¿¤ó¤Ë¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥á¥Ã¥»¡¼¥¸¤òÁ÷¤ë¤À¤±¤Ç¤¹¤±¤É¤Í¡£(^_^;
+¡¡¡¡¡¡¡Êsoopy¤Ç¤Ï¡¢´Ø¿ô¥³¡¼¥ë¤â¥á¥Ã¥»¡¼¥¸¼°¤È¤·¤Æ¼Â¸½¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¡Ë
+¡¡¡¡¡¡¡¡soopy¤Ë¤ª¤¤¤Æ¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ê¹½Ê¸¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
+
+¡¡¡¡¡¡¡¡¡ã¥ª¥Ö¥¸¥§¥¯¥È¡ä¡¡¡ã¥á¥Ã¥»¡¼¥¸¡ä
+
+
+¡¡¡¡¡¡¡¡Îã¡£
+<pre>
+             "string" length;
+
+             [1,2,3] map ({arg:[x]; do:[x+1];} eval);
+
+             [3...7] each ({arg:[x]; do:[println x];} eval);
+
+             {
+               fun main(){do: println "Hello, world!";};
+             } main();
+
+             {
+               a: 3;
+               fun f(x){do:a+x;};
+             } f 7;
+
+</pre>
+
+....¥³¥á¥ó¥È
+
+¡¡¡¡¡¡¡¡/* ¤È */¡¡¤Ë°Ï¤Þ¤ì¤¿Éôʬ¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£
+¡¡¡¡¡¡¡¡¡ô¡¡¤«¤é¹ÔËö¤Þ¤Ç¤â¥³¥á¥ó¥È¤Ç¤¹¡£
+
+
+
+
+...¤µ¤Þ¤¶¤Þ¤ÊÁȤ߹þ¤ß·¿
+
+¡¡¡¡£µ¼ïÎà¤Îʸ¤À¤±¤Ç¤Ï¡¢Ê£»¨¤Ê¥×¥í¥°¥é¥à¤ÏÁȤá¤Ê¤¤¤Î¤Ç¡¢
+soopy¤Ë¤Ï¤µ¤Þ¤¶¤Þ¤Ê¼ïÎà¤ÎÁȤ߹þ¤ß·¿¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
+
+À°¿ô¡ÊInt)
+¡¡£°¤«¤é£¹¤Î¿ô»ú¤Îʤӡ£¤è¤¯¤¢¤ë¤ä¤Ä¡£
+
+¼Â¿ô¡ÊReal)
+¡¡£°¡¥£µ¤È¤«¾®¿ôÅÀ¤ò»È¤¦¿ô»ú¡£
+
+ÏÀÍý·¿¡ÊBool)
+¡¡true¡Ê¿¿¡Ë¤Èfalse¡Êµ¶¡Ë¤Çɽ¤µ¤ì¤ë¡£
+
+ʸ»ú¡ÊChar)
+¡¡¡Ç¤È¡Ç¤Ç¤Ï¤µ¤Þ¤ì¤¿£±Ê¸»ú¤Î¥­¥ã¥é¥¯¥¿¡£
+
+ʸ»úÎó
+¡¡¡É¤È¡É¤Ç°Ï¤Þ¤ì¤¿Ê¸»ú¤Îʤӡ£
+
+
+
+¡¡°Ê²¼¤Ë¡¢¤½¤Î¾¤Ë¤É¤ó¤Ê·¿¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¤«¤À¤±½ñ¤¤¤Æ¤ª¤­¤Þ¤¹¡£
+¾Ü¤·¤¯¤Ï<CLASS Reference>¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
+
+    List(¥ê¥¹¥È), NameSpace(¥ª¥Ö¥¸¥§¥¯¥È),
+    Array, TextFileIn, TextFileOut,
+    Primitive, Closure(¥¯¥í¡¼¥¸¥ã¡Ë
+
+
+
+..ÆþÌç
+...¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Îµ¯Æ°¤È½ªÎ»
+
+¡¡soopy¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ò°ú¿ô¤Ê¤·¤Çµ¯Æ°¤¹¤ë¤È¡¢
+¥×¥í¥ó¥×¥È¡Ê¡ä¡Ë¤¬É½¼¨¤µ¤ì¤Æ¡¢¥æ¡¼¥¶¤ÎÆþÎÏÂÔ¤Á¤Ë
+¤Ê¤ê¤Þ¤¹¡£
+¡¡¤³¤³¤Ç¡¢¤¤¤í¤¤¤í¤Êʸ¤òÆþÎϤ¹¤ë¤È¡¢soopy¤¬
+ʸ¤ò²ò¼á¤·¼Â¹Ô¤·¤Þ¤¹¡£
+¡¡soopy¤ò½ª¤ï¤ë¤È¤­¤Ë¤Ï¡¢EOF¡ÊWindows¤Ê¤éCtrl-Z¡Ë¤ò
+ÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£
+
+¡¡¤Þ¤¿¡¢¤¢¤é¤«¤¸¤áÍÑ°Õ¤·¤¿¥×¥í¥°¥é¥à¥Õ¥¡¥¤¥ë¤ò
+¼Â¹Ô¤¹¤ë¤È¤­¤Ë¤Ï¡¢
+
+soopy filename [°ú¿ôʤÓ]
+
+¡¡¤Ç£Ï£Ë¤Ç¤¹¡£
+
+
+...ºÇ½é¤Î¥×¥í¥°¥é¥à
+
+¡¡¸À¸ì¤ÎÆþÌç¤È¤¤¤¨¤Ð¡¢"Hello, world"¤Ç¤¹¤¬¡¢
+soopy¤Ç¤Ï¤É¤¦¤Ê¤ë¤Î¤Ç¤·¤ç¤¦¡£
+¡¡¤¤¤¯¤Ä¤«ÊýË¡¤Ï¤¢¤ê¤Þ¤¹¤¬¡¢ºÇ½é¤Ï¡¢
+
+(* 1 *)
+
+println "Hello, World!";
+
+¡¡¤ÇÀâÌÀ¤·¤Þ¤¹¡£
+¡¡¤Þ¤ºÂè°ì¤Ë³Ð¤¨¤ÆÍߤ·¤¤¤Î¤Ï¡¢Ê¸¤Î½ª¤ï¤ê¤Ë¤Ïɬ¤º
+¥»¥ß¥³¥í¥ó¡Ê¡¨¡Ë¤¬É¬ÍפÀ¤È¤¤¤¦¤³¤È¤Ç¤¹¡£
+¡¡¤Ç¤Ï¡¢soopy¤òµ¯Æ°¤·¤Æ¾å¤Îʸ¤òÆþÎϤ·¤Æ¤ß¤Æ
+¤¯¤À¤µ¤¤¡£Ê¸¤òºÇ¸å¤Þ¤ÇÆþÎϤ·¤¿¤é¡¢²þ¹Ô¥­¡¼¤ò
+²¡¤·¤Þ¤¹¡£
+
+¡¡soopy¤Ë¤Ï¡¢5¼ïÎà¤Îʸ¤·¤«¤Ê¤¤¤ï¤±¤Ç¤¹¤¬¡¢
+¤Ç¤Ï¤³¤Îʸ¤Ï£±¾Ï¤ÇÀâÌÀ¤·¤¿¤¦¤Á¤Î¤É¤Îʸ¤Ë¤¢¤¿¤ë
+¤Î¤Ç¤·¤ç¤¦¤«¡£
+¡¡¤ª¤ï¤«¤ê¤Î¤è¤¦¤Ë¡ãñ½ã¤Ê¼°¡ä¤Ç¤â¡¢¡ãÂåÆþʸ¡ä¤Ê¤É¤Ç¤â
+¤Ê¤¤¤Ç¤¹¤«¤é¡¢¡ã¥á¥Ã¥»¡¼¥¸¼°¡ä¤Ç¤¹¡£
+¡¡¡ã¥á¥Ã¥»¡¼¥¸¼°¡ä¤Ï¡¢¤Ä¤Í¤Ë
+
+¡¡¡ã¥ª¥Ö¥¸¥§¥¯¥È¡ä¡¡¡ã¥á¥Ã¥»¡¼¥¸¡ä
+
+¡¡¤È¤¤¤¦·Á¤ò¤·¤Æ¤¤¤Þ¤¹¤«¤é¡¢¤³¤Î¾ì¹ç¡¢
+println ¤¬¥ª¥Ö¥¸¥§¥¯¥È¡¢"Hello, World!"¤¬
+¥á¥Ã¥»¡¼¥¸¤Ë¤Ê¤ê¤Þ¤¹¡£¤Ç¤Ï¡¢¤½¤ì¤¾¤ì¤É¤ó¤Ê·¿¤Î
+¥ª¥Ö¥¸¥§¥¯¥È¤Ê¤Î¤«¸«¤Æ¤¤¤­¤Þ¤·¤ç¤¦¡£¡Ê¥á¥Ã¥»¡¼¥¸¤â
+¼Â¤Ïñ¤Ê¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¹¡£¡Ë
+¡¡"Hello, World!"¤Ï¡Öʸ»úÎó¡ÊString)¡×¤Ç¤¹¤¬¡¢
+println¤Ï¥ª¥Ö¥¸¥§¥¯¥È¤ò°ú¿ô¤È¤·¤Æ¼õ¤±¼è¤ê²èÌ̤Ë
+ɽ¼¨¤¹¤ë¡Ö¥×¥ê¥ß¥Æ¥£¥Ö¡ÊÁȤ߹þ¤ß´Ø¿ô¡Ë¡×¤Ç¤¹¡£
+¡¡¤Ç¤¹¤«¤é¡¢¾å¤Îʸ¤Ï¥×¥ê¥ß¥Æ¥£¥Ö¤Ëʸ»úÎó¤ò
+¥á¥Ã¥»¡¼¥¸¤È¤·¤ÆÁ÷¤Ã¤Æ¤¤¤ë¤ï¤±¤Ç¤¹¡£
+¡¡¤Á¤Ê¤ß¤Ë¡¢println¤ÎÊÖÃͤϼ«Ê¬¼«¿È¤Ç¤¹¤Î¤Ç¡¢
+¤Ä¤Å¤±¤¶¤Þ¤Ë¥×¥ê¥ó¥È¤·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢
+
+println object1 object2 ... objectN;
+
+¡¡¤Ê¤É¤È½ñ¤±¤Þ¤¹¡£
+
+
+(* 2 *)
+
+<pre>
+{
+  fun main(){do: println "Hello, World!";};
+} main();
+</pre>
+
+¡¡¾å¤Îʸ¤Ï¡¢¡Ð¡¡¤È¡¡¡Ñ¤Ë°Ï¤Þ¤ì¤¿Éôʬ¤¬¥ª¥Ö¥¸¥§¥¯¥È¤ò
+ɽ¤·¤Æ¤¤¤Æ¡¢¤½¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ëmain¤È¤¤¤¦¥·¥ó¥Ü¥ë¤ò
+Á÷¤Ã¤Æ¤¤¤Þ¤¹¡£
+¡¡¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥·¥ó¥Ü¥ë¤¬Á÷¤é¤ì¤ë¤È¡¢¤½¤Î¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤Î
+Ʊ¤¸Ì¾Á°¤ÎÍ×ÁǤ¬ÊÖ¤µ¤ì¤Þ¤¹¡£¤³¤Î¾ì¹ç¡¢main¤È¤¤¤¦Ì¾Á°¤Î
+´Ø¿ô¡Ê¼ÂºÝ¤Ë¤Ï¥¯¥í¡¼¥¸¥ã¡Ë¤¬Ê֤äƤ­¤Þ¤¹¡£
+¡¡¤½¤·¤Æ¡¢Ê֤äƤ­¤¿´Ø¿ô¤Ë¤µ¤é¤Ë¡Ê¡Ë¡á¥Ì¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ò
+¥á¥Ã¥»¡¼¥¸¤È¤·¤ÆÁ÷¤ë¤³¤È¤Ë¤è¤ê¡¢´Ø¿ô¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
+
+¡¡·ë¶É¡¢(* £² *)¤Îʸ¤Ç¤â¡¢¡Ê¡ö£±¡ö¡Ë¤Îʸ¤ÈƱÍͤˡ¢
+"Hello, World!"¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
+
+
+
+...´Êñ¤Ê¼°
+
+¡¡»»½Ñ¼°¤äÏÀÍý¼°¤Ê¤É¤ÏC¸À¸ì¤Ê¤É¤È¤½¤ì¤Û¤ÉÊѤï¤ê¤¬¤¢¤ê¤Þ¤»¤ó¡Ê¤Î¤Ç¾Êά¡Ë¡£
+
+
+...¥ê¥¹¥È
+
+¡¡¥ê¥¹¥È¤È¤Ï¡¢Lisp¤Ç¤¤¤¦¥ê¥¹¥È¤È°ì½ï¤Ç¤¹¡£
+Lisp¤òÃΤé¤Ê¤¯¤Æ¤âÌäÂꤢ¤ê¤Þ¤»¤ó¡£[ ¤È] ¤Ç°Ï¤Þ¤ì¤¿¡¢
+ñ¤Ê¤ë¥ª¥Ö¥¸¥§¥¯¥È¤ÎʤӤǤ¹¡£¡Ê¤Ò¤È¤Ä¤Ò¤È¤Ä¤ÎÍ×ÁǤÏ
+¥³¥ó¥Þ(,)¤¢¤ë¤¤¤Ï¥»¥ß¥³¥í¥ó(;)¤Ç¶èÀÚ¤ê¤Þ¤¹¡£¡Ë
+¡¡¥ê¥¹¥È¤Î¤Ê¤«¤Ë¤Ï¿ô»ú¤À¤í¤¦¤¬¡¢¼°¤À¤í¤¦¤¬¡¢ÂåÆþʸ¤À¤í¤¦¤¬¡¢
+¥á¥Ã¥»¡¼¥¸¼°¤À¤í¤¦¤¬¡¢¤Ê¤ó¤Ç¤âÆþ¤ê¤Þ¤¹¡£
+
+¡¡Îã¡£
+
+<pre>
+   [1,2,3];
+
+   [45, "string", 'c', x + y, println "Hello"];
+</pre>
+
+
+¡¡¤Þ¤¿¡¢¥ê¥¹¥È¤ÎÆüì¤Ê·Á¤È¤·¤Æ¡¢
+
+<pre>
+¡¡[¡ã½é´üÃÍ¡ä..¡ã½ªÃÍ¡ä]
+</pre>
+
+¡¡¤È¤¤¤¦·Á¤Î¤â¤Î¤¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤Ï¡¢¡ã½é´üÃ͡䤫¤é¡ã½ªÃÍ¡ä¤Þ¤Ç¤Î
+À°¿ô¤Î¥ê¥¹¥È¤ÈƱ¤¸°ÕÌ£¤Ç¤¹¡£Î㤨¤Ð¡¢  [1,2,3,4,5]¡¡¤È¡¡[1..5]¡¡
+¤ÏƱ¤¸°ÕÌ£¤Ç¤¹¡£
+¡¡¤È¤³¤í¤Ç¡¢¡ã½ªÃÍ¡ä¤Ï¾Êά²Äǽ¤Ç¤¹¡£¾Êά¤¹¤ë¤È¤É¤¦¤Ê¤ë¤«¤È
+¤¤¤¦¤È¡¢Ìµ¸Â¥ê¥¹¥È¤òɽ¤·¤Þ¤¹¡£
+¡¡Î㤨¤Ð¡¢[27..] ¤Ï¡¢£²£·¤«¤é£±¤º¤ÄÁý¤¨¤ë̵¸Â¤Î¥ê¥¹¥È¤òɽ¤·¤Þ¤¹¡£
+
+¡¡¤µ¤é¤Ë¡¢
+<pre>
+¡¡[¡ã½é´üÃÍ¡ä..¡ã¼¡¤ÎÃÍ¡ä..¡ã½ªÃÍ¡ä]
+</pre>
+
+¡¡¤È¤¹¤ì¤Ð¡¢¡ã¼¡¤ÎÃÍ¡ä¡Ý¡ã½é´üÃ͡䤺¤ÄÁý¤¨¤ë¥ê¥¹¥È¤¬½ÐÍè¤Þ¤¹¡£
+¤³¤Î¾ì¹ç¤â¡¢¡ã½ªÃÍ¡ä¤Ï¾Êά¤·¤Æ̵¸Â¥ê¥¹¥È¤òºî¤ì¤Þ¤¹¡£
+
+
+...¥¿¥×¥ë¡ÊÁÈ¡Ë
+
+¡¡¥¿¥×¥ë¤È¤Ï¡¢¡Ê ¤È ¡Ë ¤Ç°Ï¤Þ¤ì¤¿¡¢<b>£²¤Ä°Ê¾å</b>¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ÎʤӤǤ¹¡£
+¡Ê¤Ò¤È¤Ä¤Ò¤È¤Ä¤ÎÍ×ÁǤϥ³¥ó¥Þ(,)¤Ç¶èÀÚ¤ê¤Þ¤¹¡£¡Ë
+¡¡´Ø¿ô¤ËÊ£¿ô¤Î°ú¿ô¤òÅϤ¹¤È¤­¤Ê¤É¤Ë»È¤ï¤ì¤Þ¤¹¡£
+
+
+...´Ø¿ô
+
+
+<ol>
+  <li>´Ø¿ôÄêµÁ
+    <blockquote>
+      ´Ø¿ôÄêµÁ¤Ï¡¢°Ê²¼¤Î·Á¤ò¤·¤Æ¤¤¤Þ¤¹¡£
+<pre>
+        fun func_name(arg1, arg2,...,argN){<br>
+          require: [statement list];<br>
+          var: [symbol list];<br>
+          do: [statement list];<br>
+          ensure: [statement list];<br>
+          rescue: [statement list];<br>
+        };<br>
+<pre>
+      require: ¤Ë¤Ï¡¢´Ø¿ô¤Î»öÁ°¾ò·ï¤Îʤӡ¢<br>
+      var: ¤Ë¤Ï¡¢ÊÑ¿ô̾¡Ê¥·¥ó¥Ü¥ë¡Ë¤Î¥ê¥¹¥È¡¢<br>
+      do: ¤Ë¤Ï¡¢´Ø¿ôËÜÂÎ(¼ÂºÝ¤Ë¼Â¹Ô¤µ¤ì¤ëʸ)¤Îʤӡ¢<br>
+      ensure: ¤Ë¤Ï¡¢»ö¸å¾ò·ï¤Îʤӡ¢<br>
+      rescue: ¤Ë¤Ï¡¢´Ø¿ôËÜÂΤä»ö¸å¾ò·ïÆâ¤ÇÎã³°¤¬µ¯¤­¤¿»þ¤Ë¼Â¹Ô¤µ¤ì¤ëʸ¤ÎʤÓ<br>
+      ¤òÄêµÁ¤¹¤ë¡£<br>
+    </blockquote>
+<br>
+<br>
+</ol>
+
+¡¡¡¡Îã¡£
+<pre>
+      fun square(x){do: [x * x];};¡¡(*¡¡Æó¾è¤ò·×»»¤¹¤ë´Ø¿ôsquare¤ÎÄêµÁ¡¡*)
+
+¡¡¡¡¡¡fun func2(x,y){    (*¡¡´Ø¿ô¼«ÂΤˤϤ¿¤¤¤·¤Æ°ÕÌ£¤Ï¤Ê¤¤¡¡*)
+        var: [n,m],¡¡¡¡¡¡(*¡¡¥í¡¼¥«¥ëÊÑ¿ô¤ÎÀë¸À¡¡*)
+        do: [
+          n = x + y;
+          m = x * y;
+          n - m ¡¡¡¡¡¡¡¡ (*¡¡n - m ¤ÎÃͤ¬¤¬´Ø¿ô¤ÎÌá¤êÃÍ¡¡*)
+        ];
+      };
+</pre>
+
+¡¡¤Þ¤¿¡¢´Ø¿ô¤ò¼Â¹Ô¤¹¤ë¤Ë¤Ï¡¢´Ø¿ô¤Ë°ú¿ô¤òʤ٤¿
+¥¿¥×¥ë¤òÁ÷¤ê¤Þ¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+      func ();
+
+      square (4);
+
+      someFunction (2,7);
+</pre>
+
+¡¡£²°ú¿ô¤Î´Ø¿ô¤Ë°ú¿ô¤ò£±¸Ä¤·¤«ÅϤµ¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
+¥¨¥é¡¼¤Ë¤Ï¤Ê¤é¤º¡¢ºÇ½é¤Î°ú¿ô¤ËÅϤ·¤¿Ãͤ¬·ë¤ÓÉÕ¤±¤é¤ì¤¿¡¢
+£±°ú¿ô¤Î´Ø¿ô¤¬ÊÖ¤ê¤Þ¤¹¡£
+¡¡°ìÈ̤ËÊ£¿ô¤Î°ú¿ô¤ò¤È¤ë´Ø¿ô¤Ë¡¢¾¯¤Ê¤¤°ú¿ô¤·¤«
+ÅϤµ¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢ÅϤ·¤¿¤Ö¤ó¤Î°ú¿ô¤Î¤ß¡¢Ãͤ¬·ë¤Ó¤Ä¤±¤é¤ì¤¿
+´Ø¿ô¡Ê¥¯¥í¡¼¥¸¥ã¡Ë¤¬Ê֤äƤ­¤Þ¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+      g = func2 7;  (*¡¡g ¤Ï¡¢£±°ú¿ô¤Î´Ø¿ô¡¡*)
+      g 8;          (*¡¡´Ø¿ô¤ÎÃͤϡ¢-41 *)
+</pre>
+
+
+
+...¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ
+....¥Í¡¼¥à¥¹¥Ú¡¼¥¹(NameSpace)¤ÎÄêµÁ
+
+¡¡soopy¤Ë¤Ï¼Â¤Ï¥¯¥é¥¹¤È¤¤¤¦³µÇ°¤¬¤¢¤ê¤Þ¤»¤ó¡£
+¤Ç¤â¡¢¥ª¥Ö¥¸¥§¥¯¥È¡Ê¥¤¥ó¥¹¥¿¥ó¥¹¡Ë¤Ïºî¤ì¤Þ¤¹¡£
+soopy¤Ç¤Ï¡¢¥ª¥Ö¥¸¥§¥¯¥È¤Ï¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤È
+¸Æ¤Ð¤ì¤Þ¤¹¡£¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤Ï¡¢Ê̤θƤÓÊý¤ò¤¹¤ë¤È
+Ï¢ÁÛÇÛÎó¤È¤â¤¤¤¤¤Þ¤¹¡£
+
+¡¡¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤òºî¤ë¤Ë¤Ï¡¢¡Ð¡¡¤È¡¡¡Ñ¤Ë°Ï¤Þ¤ì¡¢¥»¥ß¥³¥í¥ó(¡¨)
+¤Ç¶èÀÚ¤é¤ì¤¿¥Õ¥£¡¼¥Á¥ã¤ÎÀë¸À¤ÎʤӤǤ¹¡£
+¡¡¥Õ¥£¡¼¥Á¥ã¤ÎÀë¸À¤Ï
+
+¡¡¡ã¥·¥ó¥Ü¥ë¡ä¡§¡¡Ê¸
+¡¡¤Î·Á¤ò¤·¤Æ¤¤¤ë¤«¡¢
+¤Þ¤¿¤Ï¡¢
+¡¡´Ø¿ôÀë¸À
+¤Þ¤¿¤Ï¡¢
+¡¡Äê¿ôÀë¸À
+¤Þ¤¿¤Ï¡¢
+¡¡¥×¥í¥Ñ¥Æ¥£Àë¸À
+¤Þ¤¿¤Ï¡¢
+¡¡¥Ç¡¼¥¿¥¿¥¤¥×Àë¸À
+¤Ç¤¹¡£
+
+
+¡¡²¼¤Îʸ¤Ï¡¢¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤·¤Þ¤¹¡£
+¡Ê¤·¤«¤·¡¢¥ª¥Ö¥¸¥§¥¯¥È¤½¤Î¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£¡Ë
+<pre>
+      { a: 3; b: x; }
+</pre>
+
+  ¤¢¤¯¤Þ¤Ç¡¢¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ëʸ¤Ê¤Î¤Ç¡¢
+¾å¤Îʸ¤¬¼Â¹Ô¤µ¤ì¤ë¤¿¤Ó¡¢À¸À®¤µ¤ì¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ï
+ÊÌʪ¤Ç¤¹¡£
+
+¡¡¤è¤Ã¤Æ¡¢
+
+<pre>
+      fun f(){
+        do: [
+          {
+            a: 7;
+            fun printIt(){do: [println a]; };
+          }
+        ];
+      };
+</pre>
+
+¤Î¤È¤­¡¢
+
+<pre>
+      x = f();
+      y = f();
+</pre>
+
+¤È¤¹¤ë¤È¡¢£ø¤È£ù¤Î»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤ÏÊÌʪ¤Ç¤¹¡£¤·¤«¤·¡¢
+£ø¤È£ù¤Î¹½Â¤¤ÏƱ¤¸¤Ç¤¹¡£
+¡¡¤È¤¤¤¦¤³¤È¤Ï¡¢¥¯¥é¥¹¤ò»È¤ï¤Ê¤¯¤Æ¤â¡¢Æ±¤¸À­¼Á¤Î
+¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®²Äǽ¤È¤¤¤¦¤³¤È¤Ç¤¹¡£¤Þ¤¿¡¢´Ø¿ô£æ¤Ï
+£Ã¡Ü¡Ü¤Ê¤É¤ÎÉáÄ̤Υª¥Ö¥¸¥§¥¯¥È»Ø¸þ¸À¸ì¤Ë¤ª¤±¤ë
+¥³¥ó¥¹¥È¥é¥¯¥¿¤ÎÌòÌܤò¤·¤Æ¤¤¤ë¤³¤È¤¬¤ï¤«¤ë¤È»×¤¤¤Þ¤¹¡£
+
+¡¡£æ¤¬°ú¿ô¤ò¤È¤ë´Ø¿ô¤À¤È¤·¤¿¤é¡¢¤É¤¦¤Ç¤·¤ç¤¦¡£
+¤µ¤Þ¤¶¤Þ¤Ê¥ª¥Ö¥¸¥§¥¯¥È¤¬ºî¤ì¤ë¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
+¤ä¤Ã¤Æ¤ß¤Þ¤·¤ç¤¦¡£
+
+<pre>
+
+  fun map(f,l){
+    do: if(l){
+          []:    [];
+          x::xs: f x :: map(f,xs);
+        };
+  };
+
+  fun con(list,func){
+    do: [
+      {
+        fun run(){
+          do: [
+          map (func, list);
+          ];
+        };
+      };
+    ];
+  };
+
+  fun add1(x){
+    do: [x + 1];
+  };
+
+  fun add2(x){
+    do: [x + 2];
+  };
+
+  a = con([1,2,3,4,5], add1);
+  b = con([1..5], add2);
+  a run();
+  b run();
+</pre>
+
+
+
+
+....¥Õ¥£¡¼¥Á¥ã¡¼¤Î¥¢¥¯¥»¥¹
+
+¡¡¡¡¡¡¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Õ¥£¡¼¥Á¥ã¡¼¡ÊÍ×ÁǡˤòÆɤ߽Ф¹¤Ë¤Ï
+¡¡¡¡¥ª¥Ö¥¸¥§¥¯¥È¤ËÆɤ߽Ф·¤¿¤¤¥Õ¥£¡¼¥Á¥ã¡¼¤Î̾Á°¡Ê¥·¥ó¥Ü¥ë¡Ë¤ò
+¡¡¡¡¥á¥Ã¥»¡¼¥¸¤È¤·¤ÆÁ÷¤ê¤Þ¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+      obj = {
+        num:3;
+        str:"Hello";
+        fun func(x){do: [x*num]; };
+      };
+      obj num;  (*¡¡£³¤¬Ê֤äƤ¯¤ë¡¡*)
+      obj str;  (*¡¡"Hello"¤¬Ê֤äƤ¯¤ë¡¡*)
+      obj func; (*¡¡°ú¿ô¤Ë£³¤ò­¤¹´Ø¿ô¤¬Ê֤äƤ¯¤ë¡¡*)
+      f = obj func;
+      f(7);     (* 10¤¬Ê֤äƤ¯¤ë *)
+</pre>
+
+
+....¥Õ¥£¡¼¥Á¥ã¡¼¤Î¹¹¿·
+
+¡¡¡¡¡¡¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Õ¥£¡¼¥Á¥ã¡¼¤Ë½ñ¤­¹þ¤à¡Ê¹¹¿·¡Ë¤¹¤ë¤Ë¤Ï¡¢
+¡¡¡¡Åö¤¿¤êÁ°¤Ç¤¹¤¬¡¢ÂåÆþʸ¤ò»È¤¤¤Þ¤¹¡£
+¡¡¡¡¡¡¥Õ¥£¡¼¥Á¥ã¡¼¤òÆɤ߹þ¤à¤Î¤Ï
+
+¡¡¡¡¡¡¡ã¥ª¥Ö¥¸¥§¥¯¥È¡ä¡¡¡ã¥Õ¥£¡¼¥Á¥ã¡¼Ì¾¡ä
+
+¡¡¡¡¤Ç¤¹¤«¤é¡¢½ñ¤­¹þ¤ß¤ÏÅöÁ³¡¢
+
+¡¡¡¡¡¡¡ã¥ª¥Ö¥¸¥§¥¯¥È¡ä¡¡¡ã¥Õ¥£¡¼¥Á¥ã¡¼Ì¾¡ä¡¡¡á¡¡¡ã½ñ¤­¹þ¤ß¤¿¤¤ÃÍ¡ä
+
+¡¡¡¡¤Ç¤¹¡£´Êñ¤Ç¤¹¤Í¡£
+¡¡¡¡¡ÊLisp¤òÃΤäƤ¤¤ëÊý¤Ë¤Ï¡¢Common Lisp ¤Î setf ¤ò¹Í¤¨¤Æ¤¤¤¿¤À¤±¤ì¤Ð
+¤¤¤¤¤È»×¤¤¤Þ¤¹¡£¤«¤¨¤Ã¤Æ°ÕÌ£ÉÔÌÀ¡©¡Ë
+
+¡¡¡¡Îã¡£
+<pre>
+      obj = {
+        num:3;
+        str:"Hello";
+        fun func(x){do: [x*num]; };
+      };
+      obj num;      (*¡¡£³¤¬Ê֤äƤ¯¤ë¡¡*)
+      obj num = 8;  (*¡¡num ¤ÎÃͤò¹¹¿·¡¡*)
+      obj num;      (*¡¡£¸¤¬Ê֤äƤ¯¤ë¡¡*)
+</pre>
+
+
+....¥×¥í¥Ñ¥Æ¥£Àë¸À
+
+¡¡¡¡¥×¥í¥Ñ¥Æ¥£¤Ï¡¢Delphi¤È¤«¤Ë¤¢¤ë¤â¤Î¤È¹Í¤¨Êý¤ÏƱ¤¸¤Ç¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+a = {
+        b: 1;
+
+        fun getf(){do: b;};
+        fun setf(x){do: b = x;};
+
+        property c {
+            set: setf;
+            get: getf;
+        };
+    };
+</pre>
+¡¡¡¡¾å¤ÎÎã¤Ç¡¢
+
+<pre>
+  a c;
+</pre>
+¡¡¡¡¤È¥Õ¥£¡¼¥Á¥ã¡¼£ã¤Ë¥¢¥¯¥»¥¹¤·¤è¤¦¤È¤¹¤ë¤È¡¢
+¡¡set:¡¡¤Ç»ØÄꤵ¤ì¤¿´Ø¿ô¤¬¸Æ¤Ó½Ð¤µ¤ì¡¢¤½¤ÎÊÖÃͤ¬
+¡¡ÃͤȤʤê¤Þ¤¹¡£
+
+¡¡¡¡¤Þ¤¿¡¢
+<pre>
+  a c = value;
+</pre>
+¡¡¡¡¤È¥Õ¥£¡¼¥Á¥ã¡¼£ã¤ËÂåÆþ¤·¤è¤¦¤È¤¹¤ë¤È¡¢
+¡¡get:¡¡¤Ç»ØÄꤵ¤ì¤¿´Ø¿ô¤¬¡¢value¤ò°ú¿ô¤È¤·¤Æ
+¡¡¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
+
+
+....¥Ç¡¼¥¿¥¿¥¤¥×Àë¸À
+
+¡¡¥Ç¡¼¥¿¥¿¥¤¥×¡ÊÂå¿ô·¿¡Ë¤Ï¡¢Ã±½ã¤Ê¤â¤Î¤Ï¡¢C/C++¸À¸ì¤Ê¤É¤Î
+Îóµó·¿¤Ë»÷¤Æ¤¤¤Þ¤¹¡£
+
+¡¡¡¡Îã¡£
+<pre>
+  datatype day = Mon | Tue | Wed | Thi | Fri | Sat | Sun;
+</pre>
+
+¡¡¤³¤Î¤Þ¤Þ¤Ç¤Ï¡¢¤»¤¤¤¼¤¤Äê¿ô¤ÎÂå¤ï¤ê¤°¤é¤¤¤Ë¤·¤«¤Ê¤ê¤Þ¤»¤ó¤Î¤Ç
+¤Á¤ç¤Ã¤È³ÈÄ¥¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
+<pre>
+datatype day =
+  Mon {
+    const workday = true;
+  }
+| Tue {
+    const workday = true;
+  }
+| Wed {
+    const workday = true;
+  }
+| Thi {
+    const workday = true;
+  }
+| Fri {
+    const workday = true;
+  }
+| Sat {
+    const workday = false;
+  }
+| Sun {
+    const workday = false;
+  }
+;
+</pre>
+¡¡¤È¤¹¤ë¤È¡¢
+<pre>
+  Mon workday;  # true
+
+  Sun workday;  # false
+</pre>
+
+¡¡¤Î¤è¤¦¤Ë»È¤¨¤Þ¤¹¡£
+¡¡¤³¤Î¤è¤¦¤Ë¡¢¥Ç¡¼¥¿¥¿¥¤¥×¤Ï¤¢¤¿¤«¤â¥ª¥Ö¥¸¥§¥¯¥È¤Î¤è¤¦¤Ë
+¤µ¤Þ¤¶¤Þ¤Ê¥Õ¥£¡¼¥Á¥ã¡¼¤ò¤â¤Æ¤Þ¤¹¡£¥Õ¥£¡¼¥Á¥ã¡¼¤Ë¤Ï
+Äê¿ô¡¢´Ø¿ô¡¢ÊÑ¿ô¤Ê¤É¤¬»ÈÍѲÄǽ¤Ç¤¹¡£
+
+¡¡¤Þ¤¿¡¢¥Ç¡¼¥¿¥¿¥¤¥×¤Ï½é´ü²½Ãͤò¤â¤Æ¤Þ¤¹¡£
+<pre>
+datatype fig =  Rect(x:int, y:int)¡¡| Circle(r:int);
+</pre>
+¡¡¤È¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢
+<pre>
+r = Rect(5,7);
+c = Circle(8);
+
+r x;  # 5
+c r;  # 8
+</pre>
+¡¡¤Î¤è¤¦¤Ë¡¢½é´ü²½¤·¤¿Ãͤ˥¢¥¯¥»¥¹½ÐÍè¤Þ¤¹¡£
+¤µ¤é¤Ë¡¢
+<pre>
+datatype fig =
+  Rect(x:int, y:int){
+    fun area(){
+      do: x * y;
+    };
+  }
+| Circle(r:int){
+    pi: 3;
+    fun area(){
+      do: r * r * pi;
+    };
+  }
+;
+</pre>
+¡¡¤È¤¹¤ë¤È¡¢
+<pre>
+r = Rect(5,7);
+c = Circle(8);
+
+r area();  # £ò¤ÏRect¤Ê¤Î¤Ç¡¢Rect¤Îarea¤¬¸Æ¤Ð¤ì¤ë¡£Ãͤϡ¢£³£µ
+c area();  # £ã¤ÏCircle¤Ê¤Î¤Ç¡¢Circle¤Îarea¤¬¸Æ¤Ð¤ì¤ë¡£Ãͤϡ¢£±£¹£²
+</pre>
+¡¡¤Î¤è¤¦¤Ë»È¤¨¤Þ¤¹¡£
+
+¡¡¤³¤Î¤è¤¦¤Ë¡¢Soopy¤Î¥Ç¡¼¥¿¥¿¥¤¥×¤Ï¡¢StandardML ¤ä, Gofer ¤Ê¤É¤Î
+´Ø¿ô·¿¸À¸ì¤ÎÂå¿ô·¿¤ò³ÈÄ¥¤·¤¿¤â¤Î¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
+
+
+....·Ñ¾µ
+
+¡¡soopy¤Ï·Ñ¾µ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó¡£
+¡¡¤¿¤À¤·¡¢·Ñ¾µ¤ËÊѤï¤ëµ¡Ç½¤È¤·¤Æ¡¢¥Í¡¼¥à¥¹¥Ú¡¼¥¹Æ±»Î¤Î
+²Ã»»¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£
+
+¡¡Î㤨¤Ð¡¢
+<pre>
+  super_obj = {
+    name: "ansi common lisp";
+    writer: "paul";
+  };
+¡¡¤Î¤È¤­¤Ë
+
+<pre>
+  child_obj = super_obj + {
+    publisher: "Pearson";
+  };
+</pre>
+¡¡¤È¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢child_obj ¤Ï¡¢super_obj¡¡¤ÎÍ×ÁǤÎ
+¤Û¤«¤Ë¡¢¿·¤¿¤ÊÍ×ÁǤòÄɲä·¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤Ê¤ê¤Þ¤¹¡£
+
+¡¡¤Þ¤¿¡¢
+<pre>
+  another_obj = child_obj + {
+    name: "hack!";
+  };
+</pre>
+¡¡¤È¤¹¤ë¤È¡¢Æ±Ì¾¤ÎÍ×ÁÇ(name)¤Ï±£¤µ¤ì¤Æ¤·¤Þ¤¤¡¢
+¥¢¥¯¥»¥¹½ÐÍè¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£
+¡¡¤³¤ì¤ò²óÈò¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¤â¤È¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ÎÍ×ÁÇ̾¤ò
+²¼µ­¤Î¤è¤¦¤Ë¥ê¥Í¡¼¥à¤·¤Þ¤¹¡£
+<pre>
+  yet_another_obj = child_obj rename {name: $rename_name;} + {
+    name: "hack?";
+  };
+</pre>
+
+
+....¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤«¤é´Ø¿ô¤òºî¤ë¡£
+
+¡¡¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤Ë¥á¥Ã¥»¡¼¥¸eval¤òÁ÷¤ë¤³¤È¤Ë¤è¤ê¡¢
+´Ø¿ô¤ò¤Ä¤¯¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£½ñ¼°¤Ï¡¢´Ø¿ôÄêµÁ¤Ë¤Û¤Ü
+Ʊ¤¸¤Ç¤¹¡£¤¿¤À¡¢¿·¤¿¤Ë¡¢arg: ¤È¤¤¤¦Í×ÁǤò»ØÄê¤Ç¤­¤Þ¤¹¡£
+¡¡arg:¡¡¤Ï°ú¿ô¤Î¥ê¥¹¥È¤Ç¤¹¡£
+
+¡¡Îã¡£
+
+<pre>
+  f = {arg:[x]; do:[x * x]; } eval;
+</pre>
+¡¡¤³¤ì¤Ç¡¢Æó¾è¤òµá¤á¤ë´Ø¿ô¤òÄêµÁ¤Ç¤­¤Þ¤¹¡£
+
+
+...¥¯¥í¡¼¥¸¥ã
+¡Ê¹©»öÃæ¡Ë
+
+
+...À©¸æ¹½Â¤
+
+¡¡À©¸æ¹½Â¤¤Ï if ¤È loop ¤Î£²¼ïÎà¤À¤±¤Ç¤¹¡£
+
+....if
+
+¡¡soopy¤Ë¤ª¤±¤ëif¤Ï¡¢¤Û¤«¤Î¸À¸ì¤È¤Ï°ã¤¤¡¢
+¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤Î¤¿¤á¤Î¹½Ê¸¤Ç¤¹¡£
+¡¡ÌµÏÀ¡¢ÉáÄ̤Ëʬ´ô½èÍý¤âµ­½Ò¤Ç¤­¤Þ¤¹¡£
+
+¡¡°ìÈ̤ˡ¢if¤Ï¼¡¤Î·Á¤ò¤·¤Æ¤¤¤Þ¤¹¡£
+
+<pre>
+  if(¼°){
+    ¥Ñ¥¿¡¼¥ó£±¡§ [¼°¤¬¥Ñ¥¿¡¼¥ó£±¤Ë¥Þ¥Ã¥Á¤·¤¿¤È¤­¼Â¹Ô¤µ¤ì¤ëʸ¤Î¥ê¥¹¥È];
+    ¥Ñ¥¿¡¼¥ó£²¡§ [¼°¤¬¥Ñ¥¿¡¼¥ó£²¤Ë¥Þ¥Ã¥Á¤·¤¿¤È¤­¼Â¹Ô¤µ¤ì¤ëʸ¤Î¥ê¥¹¥È];
+    ....
+    ¥Ñ¥¿¡¼¥óN¡§ ¡¡[¼°¤¬¥Ñ¥¿¡¼¥óN¤Ë¥Þ¥Ã¥Á¤·¤¿¤È¤­¼Â¹Ô¤µ¤ì¤ëʸ¤Î¥ê¥¹¥È];
+  };
+</pre>
+
+¡¡Îã¡£
+<pre>
+    if(i > 10){
+      true:  [¼°¤Î¥ê¥¹¥È£±];
+      false: [¼°¤Î¥ê¥¹¥È£²];
+    };
+</pre>
+¡¡¡¡¤â¤·¡¢i > 10 ¤¬¿¿¤Ê¤é¤Ð¡¢true¡¡¤È¥Þ¥Ã¥Á¤·¤Æ¡¢
+¼°¤Î¥ê¥¹¥È£±¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£¤â¤·¡¢µ¶¤Ê¤é¤Ð¡¢
+false¤È¥Þ¥Ã¥Á¤·¤Æ¡¢¼°¤Î¥ê¥¹¥È£²¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
+
+¡¡¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤¬¤â¤Ã¤È¤â°ÒÎϤòȯ´ø¤¹¤ë¤Î¤Ï¡¢¥Ñ¥¿¡¼¥ó¤Ë
+ÊÑ¿ô¤¬´Þ¤Þ¤ì¤ë¤È¤­¤Ç¤¹¡£
+<pre>
+  if([2,3,4]){
+    [x,y,z]; [println x y z]; # £ø¤Ï£²¡¤£ù¤Ï£³¡¤£ú¤Ï£´¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤Æ¤«¤é¡¢
+                              # Ê¸¤Î¥ê¥¹¥È¤¬¼Â¹Ô¤µ¤ì¤ë¡£
+  };
+</pre>
+
+¡¡¥Ñ¥¿¡¼¥ó¤Ë¤Ï¡¢¤µ¤Þ¤¶¤Þ¤Ê¤â¤Î¤¬¤¢¤ê¤Þ¤¹¡£
+<pre>
+  if(variable){
+    0:        [.....]; # ¥Ñ¥¿¡¼¥ó¤Ï¡¢À°¿ô¤À¤Ã¤¿¤ê¡¢
+    'c':      [....];  # Ê¸»ú¤À¤Ã¤¿¤ê¡¢
+    "string": [ ....]; # Ê¸»úÎó¤À¤Ã¤¿¤ê¡¢
+    [x,y]:    [....];  # ¥ê¥¹¥È¤À¤Ã¤¿¤ê¡¢
+    (n,m,l):  [....];  # ¥¿¥×¥ë¤À¤Ã¤¿¤ê¡¢
+    true:     [....];  # ¿¿µ¶ÃͤÀ¤Ã¤¿¤ê¤·¤Þ¤¹¡£
+    other:    [....];  # ¤Þ¤¿¡¢¥·¥ó¥Ü¥ë¤Ï¤¹¤Ù¤Æ¤Î¥Ñ¥¿¡¼¥ó¤Ë°ìÃפ·¤Þ¤¹¡£
+                       # ¤³¤Î¤È¤­¡¢variable ¤ÎÃͤ¬¡¢ other ¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤Þ¤¹¡£
+  };
+</pre>
+
+
+....loop
+
+¡¡loop¤Ï¼¡¤Î·Á¼°¤ò¤·¤Æ¤¤¤Þ¤¹¡£
+
+  loop Label Namespace;
+
+¡¡¶ñÂÎŪ¤Ë¤Ï¡¢
+
+<pre>
+  loop Label {
+    from: [¥ë¡¼¥×¤ËÆþ¤ëÁ°¤Ë¼Â¹Ô¤µ¤ì¤ë¼°¤Î¥ê¥¹¥È];
+    step: [¼¡¤Î¥ë¡¼¥×¤ËÆþ¤ë¤È¤­¤Ë¡¢¼Â¹Ô¤µ¤ì¤ë¼°¤Î¥ê¥¹¥È];
+    while: [¼°¤¬µ¶¤Ë¤Ê¤ë¤È¥ë¡¼¥×¤ò½ªÎ»]; (¤Þ¤¿¤Ï¡¢until: [])
+    do: [
+¡¡¡¡¡¡¡¡¥ë¡¼¥×ËÜÂÎ
+    ];
+    variant: [];¡¡¡¡¡ô¡¡¥ë¡¼¥×ÊѲ½É½ÌÀ¡Ê¸½»þÅÀ¤Ç¤Ï°Ọ̵̃¤·¡Ë
+    invariant: [];¡¡¡ô¡¡¥ë¡¼¥×ÉÔÊÑɽÌÀ¡Ê¸½»þÅÀ¤Ç¤Ï°Ọ̵̃¤·¡Ë
+  };
+</pre>
+
+¡¡¤È¤¤¤¦·Á¤ò¤·¤Æ¤¤¤Þ¤¹¡£Label¤Ï¾Êά²Äǽ¤Ç¤¹¡£
+¤Þ¤¿¡¢¥Í¡¼¥à¥¹¥Ú¡¼¥¹Æâ¤Î¤¹¤Ù¤Æ¤ÎÍ×ÁǤâ¾Êά²Äǽ¤Ç¤¹¡£
+
+.....exit
+
+¡¡¥ë¡¼¥×Æâ¤Ç¡¢
+
+  exit;
+
+¡¡¤È¤¤¤¦¼°¤¬É¾²Á¤µ¤ì¤ë¤È¡¢°ìÈÖÆ⦤Υ롼¥×¤òæ½Ð¤·¤Þ¤¹¡£
+¤¢¤ë¤¤¤Ï¡¢
+
+  Label.exit;
+
+  ¤È¤¹¤ë¤È¡¢Label¤¬°ìÃפ¹¤ë¥ë¡¼¥×¤òæ½Ð¤·¤Þ¤¹¡£
+¤µ¤é¤Ë¡¢
+
+  Label.exit(¼°);
+
+¡¡¤È¤¹¤ë¤È¡¢Label¤¬°ìÃפ¹¤ë¥ë¡¼¥×¤òæ½Ð¤·¡¢¼°¤ÎÃͤòloop¼°¤Î
+ÃͤȤ·¤Þ¤¹¡£
+¡¡¥é¥Ù¥ë¤Î¤Ê¤¤¡¢exit(¼°)¡¨¤Ç¤âÃͤòÊÖ¤»¤Þ¤¹¡£
+
+
+.....next
+
+  next; ¤Ï¡¢¥ë¡¼¥×¤ÎÀèƬ¤ËÌá¤ê¤Þ¤¹¡£¥é¥Ù¥ë¤Ä¤­¤Î
+Labe.next;¡¡¤Ï¡¢Label¤¬°ìÃפ¹¤ë¥ë¡¼¥×¤ÎÀèƬ¤ËÌá¤ê¤Þ¤¹¡£
+
+
+...¥Õ¥¡¥¤¥ëÆþ½ÐÎÏ
+
+¡¡¥Õ¥¡¥¤¥ë¤ÎÆþ½ÐÎϤˤϡ¢¤½¤ì¤¾¤ìopenIn, openOut ¤È¤¤¤¦
+¥×¥ê¥ß¥Æ¥£¥Ö¤ò»È¤¤¤Þ¤¹¡£
+¡¡openIn ¤Ï¡¢ÆþÎÏÍѤΥե¡¥¤¥ë¤ò³«¤­¤Þ¤¹¡£
+¡¡openOut ¤Ï¡¢½ÐÎÏÍѤΥե¡¥¤¥ë¤ò³«¤­¤Þ¤¹¡£
+¡¡»È¤¤½ª¤ï¤Ã¤¿¥Õ¥¡¥¤¥ë¤Ïɬ¤ºclose ¥á¥Ã¥»¡¼¥¸¤òÁ÷¤Ã¤Æ
+ÊĤ¸¤Æ¤ª¤­¤Þ¤·¤ç¤¦¡£
+
+¡¡Îã¡£
+
+<pre>
+    fin = openIn "filename";¡¡¡¡(*¡¡ÆþÎÏ¥Õ¥¡¥¤¥ë¤Î¥ª¡¼¥×¥ó¡¡*)
+    line = fin readline;¡¡  ¡¡¡¡(*¡¡£±¹ÔÆɤ߹þ¤ß¡¡*)
+    ch  = fin readChar;         (*¡¡£±Ê¸»úÆɤ߹þ¤ß *)
+    fin close;                  (*¡¡³«¤¤¤¿¤éɬ¤ºÊĤ¸¤ë¡¡*)
+
+    fout = openOut "output";    (*¡¡½ÐÎÏ¥Õ¥¡¥¤¥ë¤Î¥ª¡¼¥×¥ó¡¡*)
+    fout writeChar 'A';         (*¡¡£±Ê¸»ú½ÐÎÏ¡¡*)
+    p = fout printline;         (*¡¡½ÐÎÏÍÑ´Ø¿ô¤ò¡¢ÊÑ¿ô¤ËÂåÆþ¤·¤È¤¯¤Î¤¬¡¢soopyή¡¡*)
+    p "first line";             (*¡¡£±¹Ô½ÐÎÏ¡¡*)
+    p "second line";
+    p "third line";
+    fout close;                 (*¡¡³«¤¤¤¿¤éɬ¤ºÊĤ¸¤ë¡¡*)
+</pre>
+
+
+
+
+..¥ê¥Õ¥¡¥ì¥ó¥¹
+...ͽÌó¸ì
+¡¡soopy¤Ï°Ê²¼¤Î¸ì¤òͽÌó¸ì¤È¤·¤Æ¤¤¤Þ¤¹¡£
+¡¡Í½Ìó¸ì¤Ï»È¤Ã¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£
+
+object, number, int, real, bool, string, char, nil
+fun, const, property, private, public
+if, super, true, false, loop, next, redo, retry
+
+...Primitive
+....array
+    array:type (dim1,dim2,....,dimN)
+¡¡¡¡¡¡¡¡N¼¡¸µ¤ÎÇÛÎó¤òºî¤ë¡£:type ¤Ï¾Êά²Ä¡£
+¡¡¡¡¡¡¡¡type¤¬»ØÄꤵ¤ì¤Æ¤¤¤ì¤Ð¡¢»ØÄꤵ¤ì¤¿·¿¤Î¤ß¤ÎÇÛÎó¤Ë¤Ê¤ë¡£
+
+....openIn
+    openIn filename
+¡¡¡¡¡¡¡¡Ê¸»úÎófilename¤Çɽ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤òÆþÎÏÍѤ˳«¤¯¡£
+
+....openOut
+    openOut filename
+¡¡¡¡¡¡¡¡Ê¸»úÎófilename¤Çɽ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤ò½ÐÎÏÍѤ˳«¤¯¡£
+
+....load
+    load filename
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ëfilename¤òsoopy¥×¥í¥°¥é¥à¤È¤·¤Æ¥í¡¼¥É¤¹¤ë¡£
+
+....print
+    print object
+¡¡¡¡¡¡¡¡object¤ò²èÌ̤Ëɽ¼¨¤¹¤ë
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϥ᥽¥Ã¥Éprint¼«¿È¡£
+
+....println
+    println object
+¡¡¡¡¡¡¡¡object¤ò²èÌ̤Ëɽ¼¨¤·¡¢¤½¤Î¸å²þ¹Ô¤òɽ¼¨¤¹¤ë¡£
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϥ᥽¥Ã¥Éprintln¼«¿È¡£
+
+
+
+
+...CLASS Reference
+....Array
+
+      depth
+¡¡¡¡¡¡¡¡ÇÛÎó¤Î¼¡¸µ¤òÊÖ¤¹
+
+      dimension
+¡¡¡¡¡¡¡¡ÇÛÎó¤Î¼¡¸µ¤òɽ¤¹¥ê¥¹¥È¤òÊÖ¤¹
+¡¡¡¡¡¡¡¡Îã¡£
+<pre>
+           ary = array (3,4,5);
+           ary dimention;  (* [3,4,5] ¤¬ÊÖ¤ë *)
+</pre>
+
+
+
+....List
+
+      head
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤Î¥Ø¥Ã¥ÉÉôʬ(car)¤òÊÖ¤¹¡£
+
+      tail
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤Î¥Æ¡¼¥ëÉôʬ(cdr)¤òÊÖ¤¹¡£
+
+      isList?
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤«¤É¤¦¤«¤ÎȽÄê¡£¾ï¤Ë¿¿¡£
+
+      isNIL?
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤¬¥Ì¥ë¤«¤É¤¦¤«¤òȽÄꤹ¤ë¡£
+
+      nth n
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤ÎnÈÖÌܤÎÍ×ÁǤòÊÖ¤¹¡£¡ÊºÇ½é¤ÎÍ×ÁǤϣ°ÈÖÌÜ¡Ë
+
+      each func
+¡¡¡¡¡¡¡¡¥ê¥¹¥ÈÆâ¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¡¢´Ø¿ôfunc¤òŬÍѤ¹¤ë¡£
+¡¡¡¡¡¡¡¡ÊÖ¤êÃͤÏVoid¡£
+
+      foldl func
+¡¡¡¡¡¡¡¡¥ê¥¹¥ÈÆâ¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¡¢£²°ú¿ô¤Î´Ø¿ôfunc¤ò
+¡¡¡¡¡¡¡¡º¸¤«¤é½çÈÖ¤ËŬÍѤ·¤¿ÃͤòÊÖ¤¹¡£
+
+      foldr
+¡¡¡¡¡¡¡¡¥ê¥¹¥ÈÆâ¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¡¢£²°ú¿ô¤Î´Ø¿ôfunc¤ò
+¡¡¡¡¡¡¡¡±¦¤«¤é½çÈÖ¤ËŬÍѤ·¤¿ÃͤòÊÖ¤¹¡£
+
+      map func
+¡¡¡¡¡¡¡¡¥ê¥¹¥ÈÆâ¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¡¢´Ø¿ôfunc¤òŬÍѤ·¤¿
+¡¡¡¡¡¡¡¡¥ê¥¹¥È¤òÊÖ¤¹¡£
+
+
+
+
+....Char
+      isAlpha?, isAlphaNum?, isDigit?
+      isHexDigit?, isLower?, isSpace?, isUpper?
+¡¡¡¡¡¡¡¡¤½¤ì¤¾¤ìʸ»ú¤Î¼ïÎà¤òȽÄꤹ¤ë¡£
+
+      lower
+¡¡¡¡¡¡¡¡¾®Ê¸»ú¤òÊÖ¤¹¡£
+
+      pred
+¡¡¡¡¡¡¡¡Ê¸»ú¥³¡¼¥É¤¬Á°¤Îʸ»ú¤òÊÖ¤¹¡£
+
+      succ
+¡¡¡¡¡¡¡¡Ê¸»ú¥³¡¼¥É¤¬¼¡¤Îʸ»ú¤òÊÖ¤¹¡£
+
+      toInt
+¡¡¡¡¡¡¡¡Ê¸»ú¤ÎTRON¥³¡¼¥É¤òÊÖ¤¹¡£
+
+      toString
+¡¡¡¡¡¡¡¡Ê¸»úÎó¤òÊÖ¤¹¡£
+
+      upper
+¡¡¡¡¡¡¡¡Âçʸ»ú¤òÊÖ¤¹¡£
+
+
+
+....Int
+      toChar
+¡¡¡¡¡¡¡¡À°¿ô(TRON¥³¡¼¥É)¤Çɽ¤µ¤ì¤ëʸ»ú¤òÊÖ¤¹¡£
+
+      toReal
+¡¡¡¡¡¡¡¡À°¿ô¤ò¼Â¿ô¤Ë¤·¤¿ÃͤòÊÖ¤¹¡£
+
+      toString
+¡¡¡¡¡¡¡¡À°¿ô¤Îʸ»úÎóɽ¸½¤òÊÖ¤¹¡£
+
+      repeat aNameSpace
+¡¡¡¡¡¡¡¡À°¿ô²ó¡¢aNameSpace¤ò´Ø¿ô¤È¤·¤Æ¡¢À°¿ô²ó·«¤êÊÖ¤·¼Â¹Ô¤¹¤ë¡£
+
+<pre>
+        Îã.   10 repeat {arg:[x]; do: [println "hello"];};
+
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ê¸½ºß¤Î·«¤êÊÖ¤·²ó¿ô¤¬°ú¿ô¤È¤·¤ÆÅϤµ¤ì¤ë¤Î¤Ç¡¢
+¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡É¬¤º¡¢arg: ¤Ç¡¢°ú¿ô¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£¡Ë
+</pre>
+
+....Real
+      toInt
+¡¡¡¡¡¡¡¡¼Â¿ô¤ÎÀ°¿ôÉô¤òÊÖ¤¹¡£
+
+      toString
+¡¡¡¡¡¡¡¡¼Â¿ô¤Îʸ»úÎóɽ¸½¤òÊÖ¤¹¡£
+
+      abs
+¡¡¡¡¡¡¡¡ÀäÂÐÃͤòÊÖ¤·¤Þ¤¹¡£
+
+      acos
+¡¡¡¡¡¡¡¡¥¢¡¼¥¯¥³¥µ¥¤¥ó¡ÊµÕ;¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      asin
+¡¡¡¡¡¡¡¡¥¢¡¼¥¯¥µ¥¤¥ó¡ÊµÕÀµ¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      atan
+¡¡¡¡¡¡¡¡¥¢¡¼¥¯¥¿¥ó¥¸¥§¥ó¥È¡ÊµÕÀµÀܡˤòÊÖ¤·¤Þ¤¹¡£
+
+      atan2 y
+¡¡¡¡¡¡¡¡y/self ¤Î¥¢¡¼¥¯¥¿¥ó¥¸¥§¥ó¥È¤òÊÖ¤·¤Þ¤¹¡£
+ ¡¡¡¡¡¡¡Êself¡Ë¤Ï¥á¥Ã¥»¡¼¥¸¤òÁ÷¤é¤ì¤¿¼Â¿ô¼«¿È¡£
+
+      ceil
+¡¡¡¡¡¡¡¡¾®¿ôÅÀ°Ê²¼¤òÀÚ¤ê¾å¤²¤¿ÃͤòÊÖ¤·¤Þ¤¹¡£
+
+      cos
+¡¡¡¡¡¡¡¡¥³¥µ¥¤¥ó¡Ê;¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      cosh
+¡¡¡¡¡¡¡¡¥Ï¥¤¥Ñ¥Ü¥ê¥Ã¥¯¥³¥µ¥¤¥ó¡ÊÁжÊÀþ;¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      exp
+¡¡¡¡¡¡¡¡»Ø¿ô´Ø¿ô£å¤Îself¾è¤òÊÖ¤·¤Þ¤¹¡£
+
+      floor
+¡¡¡¡¡¡¡¡¾®¿ôÅÀ°Ê²¼¤òÀÚ¤ê¼Î¤Æ¤¿ÃͤòÊÖ¤·¤Þ¤¹¡£
+
+      fmod y
+¡¡¡¡¡¡¡¡self¤òy¤Ç³ä¤Ã¤¿¾ê;¤òÊÖ¤·¤Þ¤¹¡£
+
+      frexp
+¡¡¡¡¡¡¡¡²¾¿ôÉô£í¤È»Ø¿ôÉô£î¤ÎÁÈ¡Ê£í¡¢£î¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      hypot y
+¡¡¡¡¡¡¡¡Ä¾³Ñ»°³Ñ·Á¤Î¼ÐÊÕ¤ÎŤµ¤ò·×»»¤·¤Þ¤¹¡£
+
+      ldexp exp
+¡¡¡¡¡¡¡¡self * 2 ^exp ¤òÊÖ¤·¤Þ¤¹¡£
+
+      log
+¡¡¡¡¡¡¡¡¼«Á³Âпô¤òÊÖ¤·¤Þ¤¹¡£
+
+      log10
+¡¡¡¡¡¡¡¡¾ïÍÑÂпô¤òÊÖ¤·¤Þ¤¹¡£
+
+      pow y
+¡¡¡¡¡¡¡¡self ¤Î y¾è¤òÊÖ¤·¤Þ¤¹¡£
+
+      sin
+¡¡¡¡¡¡¡¡¥µ¥¤¥ó¡ÊÀµ¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      sinh
+¡¡¡¡¡¡¡¡¥Ï¥¤¥Ñ¥Ü¥ê¥Ã¥¯¥µ¥¤¥ó¡ÊÁжÊÀþÀµ¸¹¡Ë¤òÊÖ¤·¤Þ¤¹¡£
+
+      sqrt
+¡¡¡¡¡¡¡¡Ê¿Êýº¬¤òÊÖ¤·¤Þ¤¹¡£
+
+      tan
+
+      tanh
+¡¡¡¡¡¡¡¡¥Ï¥¤¥Ñ¥Ü¥ê¥Ã¥¯¥¿¥ó¥¸¥§¥ó¥È¡ÊÁжÊÀþÀµÀܡˤòÊÖ¤·¤Þ¤¹¡£
+
+
+....String
+
+      length
+¡¡¡¡¡¡¡¡Ê¸»úÎó¤ÎŤµ¡£
+
+      sub (i,j)
+¡¡¡¡¡¡¡¡iÈÖÌܤÎʸ»ú¤«¤é¡¢jʸ»úʬ¤Îʸ»úÎó¡£
+
+      nth n
+¡¡¡¡¡¡¡¡nÈÖÌܤÎʸ»ú¡£
+
+      toInt¡¡¡ªÌ¤¼ÂÁõ¡ª
+¡¡¡¡¡¡¡¡À°¿ô¤ËÊÑ´¹¡£
+
+      toReal¡¡¡ªÌ¤¼ÂÁõ¡ª
+¡¡¡¡¡¡¡¡¼Â¿ô¤ËÊÑ´¹¡£
+
+
+....Tuple
+
+      length
+¡¡¡¡¡¡¡¡¥¿¥×¥ë¤Î¥µ¥¤¥º¡£
+
+      first
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      second
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      third
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      fourth
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      fifth
+¡¡¡¡¡¡¡¡1ÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+      nth n
+¡¡¡¡¡¡¡¡nÈÖÌܤÎÍ×ÁǤò¤È¤ê¤À¤¹¡£
+
+
+....TextFileIn
+
+      close
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë¡£
+
+      iseof?
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤¬ºÇ¸å¤Þ¤Ç¤¤¤Ã¤¿¤«È½Äꤹ¤ë¡£
+
+      peekChar
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤«¤é£±Ê¸»úÀèÆɤߤ¹¤ë¡£
+
+      read
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤ò¤¹¤Ù¤ÆÆɤ߹þ¤à¡£
+
+      readLine
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤ò£±¹ÔÆɤ߹þ¤à¡£
+
+      readLineS
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤«¤é¤¹¤Ù¤Æ¤Î¹Ô¤òÆɤ߹þ¤à¡£
+
+      readChar
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤«¤é£±Ê¸»úÆɤ߹þ¤à¡£
+
+
+
+
+....TextFileOut
+
+      close
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë¡£
+
+      flush
+¡¡¡¡¡¡¡¡¥Ð¥Ã¥Õ¥¡¤ò¥Õ¥é¥Ã¥·¥å¤¹¤ë¡£
+
+      terpri
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤Ë²þ¹Ô¤ò½ñ¤­½Ð¤¹¡£
+
+      writeChar aChar
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤Ëʸ»úaChar¤ò½ñ¤­½Ð¤¹¡£
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϥ᥽¥Ã¥ÉwriteChar¼«¿È¡£
+
+      write object
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤Ëobject¤Îʸ»úÎóɽ¸½¤ò½ñ¤­½Ð¤¹¡£
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϥ᥽¥Ã¥Éwrite¼«¿È¡£
+
+      writeLine object
+¡¡¡¡¡¡¡¡¥Õ¥¡¥¤¥ë¤Ëobject¤Îʸ»úÎóɽ¸½¤È²þ¹Ô¤ò½ñ¤­½Ð¤¹¡£
+¡¡¡¡¡¡¡¡Ìá¤êÃͤϥ᥽¥Ã¥ÉwriteLine¼«¿È¡£
+
+
+
+
+..License
+
+Copyright (C) 2002 by SUZUKI Jun. All rights reserved.
+
+¤³¤Î¥½¥Õ¥È¥¦¥§¥¢¡Êsoopy¡Ë¤ÏGPL(GNU General Public License)¤Ë
+½¾¤Ã¤Æ¤¤¤Þ¤¹¡£
+Á´¤Æ¤Î¸¢Íø¤Ïºî¼Ô(SUZUKI Jun)¤¬ÊÝ»ý¤·¤Æ¤¤¤Þ¤¹¤¬¡¢
+ÍøÍÑ¡¢ºÆÇÛÉÛ¤ÏGPL¤Ë½¾¤¦¸Â¤ê¼«Í³¤Ç¤¹¡£ºÆÇÛÉۤˤÏÏ¢Íí¤ÏÉÔÍפǤ¹¡£
+
+¤Ê¤ª¡¢ºî¼Ô¤ÏÍøÍѼԤ¬ËÜ¥½¥Õ¥È¥¦¥§¥¢¤òÍøÍѤ·¤¿¤³¤È¤Ë¤è¤ê
+À¸¤¸¤¿¤¤¤«¤Ê¤ë»³²¤Ë¤â¤½¤ÎÀÕǤ¤òÉ餤¤Þ¤»¤ó¡£
+
+
+
+..»²¹Íʸ¸¥¤Ê¤É
+
+»²¹Í¤Ë¤·¤¿¸À¸ì
+
+LENS(<A HREF="http://prog.vub.ac.be/poolresearch/lens/contents.html" TARGET="_blank">http://prog.vub.ac.be/poolresearch/lens/contents.html</A>)
+
+»²¹Í½ñÀÒ
+
+C¥Þ¥¬¥¸¥ó¡¡£±£¹£¹£¹Ç¯£¸¡¢£¹·î¹æ¡¡¡¡¡¡¥½¥Õ¥È¥Ð¥ó¥¯¡¡¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°´©
+¡¡¡Ö³ØÌä¤Î¥¹¥¹¥á¡×¡¡¤­¤À¤¢¤­¤é
+
+
+
diff --git a/src/Array.cpp b/src/Array.cpp
new file mode 100644 (file)
index 0000000..77a5fed
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Array.cpp,v 1.13 2004/03/24 11:53:44 randy Exp $
+ */
+
+#include <stdio.h>
+
+#include "soopy.h"
+
+/*
+ * class SpArray
+ */
+
+SpBaseArray::SpBaseArray(uintvec& v)
+  : dimension(v)
+{
+    depth = dimension.size();
+}
+
+// primitives
+SpValue& SpBaseArray::getDepth(SpValue& self)
+{
+    SpArray* array = self.asArray();
+    //    static SpValue result;
+    //    result.setInt(array->depth);
+    //    return result;
+    return SpIntResult(array->depth);
+}
+
+SpValue& SpBaseArray::getDimension(SpValue& self)
+{
+    SpValue temp;
+    SpArray* array = self.asArray();
+    uintvec::iterator it;
+    it = array->dimension.begin();
+    temp.setInt(*it);
+    SpCons* head = new SpCons(temp);
+    SpCons* ptr = head;
+    it++;
+    for(; it != array->dimension.end(); it++){
+        temp.setInt(*it);
+        ptr->append(temp);
+        SpValue v;
+        v = ptr->nextList();
+        ptr = (SpCons*)v.asList();
+    }
+    //    static SpValue result;
+    //    result.setNewObject(head);
+    //    return result;
+    return SpObjectResult(head);
+}
+
+// init Message Handler
+void SpBaseArray::init()
+{
+    SpValue SymDepth(new SpSymbol("depth"));
+    SpValue PrimDepth(new SpPrim1(getDepth));
+    ArrayMsgHandler.append(SymDepth, PrimDepth);
+
+    SpValue SymDimension(new SpSymbol("dimension"));
+    SpValue PrimDimension(new SpPrim1(getDimension));
+    ArrayMsgHandler.append(SymDimension, PrimDimension);
+}
+
+
+/*
+ * class SpObjectArray
+ */
+
+SpObjectArray::SpObjectArray(SpValue& t, uintvec& v)
+  : SpArray(v), typ(t)
+{
+//    depth = dimension.size();
+    int allsize = 1;
+    uintvec::iterator it;
+    it = dimension.begin();
+    for(; it != dimension.end(); it++){
+        allsize *= *it;
+    }
+    pvec = new SpValueVector(allsize);
+}
+
+SpValue& SpObjectArray::toString()
+{
+    SpString* str;
+    char buf[128];
+
+    str = new SpString();
+    *str = "Array:";
+    if(!typ.isNil()){
+        *str += typ;
+    }
+    *str += " (";
+
+    uintvec::iterator it;
+    it = dimension.begin();
+#ifdef HAVE_ITOA
+    *str += itoa(*it, buf, 10);
+#else
+    sprintf(buf, "%d", *it);
+    *str += buf;
+#endif
+    it++;
+    for(; it != dimension.end(); it++){
+        *str += ",";
+#ifdef HAVE_ITOA
+        *str += itoa(*it, buf, 10);
+#else
+    sprintf(buf, "%d", *it);
+    *str += buf;
+#endif
+    }
+
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+SpValue& SpObjectArray::operator[](SpValue& tuple)
+{
+    if(tuple.isTuple()){
+        SpTuple* t = dynamic_cast<SpTuple*>(tuple.getObject());
+        if((SpInt)depth != t->length()){
+            throw SpException("array depth mismatch");
+        }
+        uintvec::iterator uit;
+        SpValueVector::iterator tit;
+        uit = dimension.begin();
+        tit = t->begin();
+        unsigned int offset = 0;
+        unsigned int times = 1;
+        for(; uit != dimension.end(); uit++, tit++){
+            SpValue v = tit->eval();
+            if(!v.isInt()){
+                throw SpException("not int (access array)");
+            }
+            unsigned int index = v.getInt();
+            if((*uit - 1) < index){
+                throw SpException("too large index (access array)");
+            }
+            offset += times * index;
+            times *= *uit;
+        }
+        return (*pvec)[offset];
+
+    }else{ // not tuple
+        SpValue v = tuple.eval();
+        if(!v.isInt()){
+            throw SpException("not int (access array)");
+        }
+        if(depth != 1){
+            throw SpException("depth not match (access array)");
+        }
+        unsigned int index = v.getInt();
+        if((dimension[0] - 1) < index){
+            throw SpException("over range (access array)");
+        }
+        return (*pvec)[index];
+    }
+}
+
+void SpObjectArray::set(SpValue& tuple, SpValue& value)
+{
+    (*this)[tuple] = value;
+}
+
+SpValue& SpObjectArray::onMessage(SpValue& rec, SpValue& msg)
+{
+    if(ArrayMsgHandler.hasMessage(msg)){
+        return ArrayMsgHandler(rec, msg);
+    }
+    SpValue val = msg.eval();
+    if(val.isInt()){
+        return operator[](val);
+    }
+    if(val.isTuple()){
+        return operator[](val);
+    }
+
+    // Error
+    static char buf[256];
+    strncpy(buf, rec.toCStringWithEncoder(), 255);
+    buf[255] = '\0';
+    static char buf2[256];
+    strncpy(buf2, msg.toCStringWithEncoder(), 255);
+    buf2[255] = '\0';
+    throw SpNoMethodException("no such a feature", buf, buf2);
+}
+
+
+/*
+ * class SpByteArray
+ */
+
+SpByteArray::SpByteArray(uintvec& v)
+  : SpBaseArray(v)
+{
+    int allsize = 1;
+    uintvec::iterator it;
+    it = dimension.begin();
+    for(; it != dimension.end(); it++){
+        allsize *= *it;
+    }
+//    buf = new char(allsize);
+    buf = (unsigned char*)malloc(allsize);
+    if(buf == NULL){
+        throw SpException("out of memory");
+    }
+}
+
+SpValue& SpByteArray::toString()
+{
+    SpString* str;
+    char buf[128];
+
+    str = new SpString();
+    *str = "Array:byte (";
+
+    uintvec::iterator it;
+    it = dimension.begin();
+#ifdef HAVE_ITOA
+    *str += itoa(*it, buf, 10);
+#else
+    sprintf(buf, "%d", *it);
+    *str += buf;
+#endif
+    it++;
+    for(; it != dimension.end(); it++){
+        *str += ",";
+#ifdef HAVE_ITOA
+        *str += itoa(*it, buf, 10);
+#else
+    sprintf(buf, "%d", *it);
+    *str += buf;
+#endif
+    }
+
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+unsigned char& SpByteArray::operator[](SpValue& tuple)
+{
+    if(tuple.isTuple()){
+        SpTuple* t = dynamic_cast<SpTuple*>(tuple.getObject());
+        if((SpInt)depth != t->length()){
+            throw SpException("array depth mismatch");
+        }
+        uintvec::iterator uit;
+        SpValueVector::iterator tit;
+        uit = dimension.begin();
+        tit = t->begin();
+        unsigned int offset = 0;
+        unsigned int times = 1;
+        for(; uit != dimension.end(); uit++, tit++){
+            SpValue v = tit->eval();
+            if(!v.isInt()){
+                throw SpException("not int (access array)");
+            }
+            unsigned int index = v.getInt();
+            if((*uit - 1) < index){
+                throw SpException("too large index (access array)");
+            }
+            offset += times * index;
+            times *= *uit;
+        }
+        return buf[offset];
+
+    }else{ // not tuple
+        SpValue v = tuple.eval();
+        if(!v.isInt()){
+            throw SpException("not int (access array)");
+        }
+        if(depth != 1){
+            throw SpException("depth not match (access array)");
+        }
+        unsigned int index = v.getInt();
+        if((dimension[0] - 1) < index){
+            throw SpException("over range (access array)");
+        }
+        return buf[index];
+    }
+}
+
+SpValue& SpByteArray::getFeatureType()
+{
+    return SymByte;
+}
+
+SpValue& SpByteArray::onMessage(SpValue& rec, SpValue& msg)
+{
+  //    static SpValue result;
+
+    if(ArrayMsgHandler.hasMessage(msg)){
+        return ArrayMsgHandler(rec, msg);
+    }
+    SpValue val = msg.eval();
+    if(val.isInt()){
+      //        result.setInt(operator[](val));
+      //        return result;
+      return SpIntResult(operator[](val));
+    }
+    if(val.isTuple()){
+      //        result.setInt(operator[](val));
+      //        return result;
+      return SpIntResult(operator[](val));
+    }
+
+    // Error
+    static char buf[256];
+    strncpy(buf, rec.toCStringWithEncoder(), 255);
+    buf[255] = '\0';
+    static char buf2[256];
+    strncpy(buf2, msg.toCStringWithEncoder(), 255);
+    buf2[255] = '\0';
+    throw SpNoMethodException("no such a feature", buf, buf2);
+}
+
+
+/*
+ * class MakeArray
+ */
+
+SpValue& MakeArray::eval()
+{
+    uintvec intVec; // int vector
+    SpTuple* tuple = vec.asTuple();
+    SpValueVector::iterator it;
+    it = tuple->begin();
+    for(; it != tuple->end(); it++){
+        SpValue v = it->eval();;
+        if(!v.isInt()){ throw SpException("not int (make array)"); }
+        intVec.push_back(v.getInt());
+    }
+
+    //    static SpValue result;
+    if(typ == SymByte){
+      //        result.setNewObject(new SpByteArray(intVec));
+      return SpObjectResult(new SpByteArray(intVec));
+    }else{
+      //        result.setNewObject(new SpObjectArray(typ, intVec));
+      return SpObjectResult(new SpObjectArray(typ, intVec));
+    }
+    //    return result;
+}
+
+SpValue& MakeArray::toString()
+{
+    SpString* str;
+    //char buf[128];
+
+    str = new SpString();
+    *str = "MakeArray:";
+    if(!typ.isNil()){
+        *str += typ;
+    }
+    *str += " (";
+
+    SpTuple* tuple = vec.asTuple();
+    SpValueVector::iterator it;
+    it = tuple->begin();
+    *str += *it;
+    it++;
+    for(; it != tuple->end(); it++){
+        *str += ",";
+        *str += *it;
+    }
+
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
diff --git a/src/Assign.cpp b/src/Assign.cpp
new file mode 100644 (file)
index 0000000..0915bab
--- /dev/null
@@ -0,0 +1,482 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Assign.cpp,v 1.24 2004/03/25 13:25:48 randy Exp $
+ */
+
+
+#include "soopy.h"
+
+/*
+ * class SpAssign
+ */
+
+SpAssign::~SpAssign()
+{
+#ifdef TEST
+    *spout << ":destroy Assign:" << "\n";
+#endif
+}
+
+SpValue& SpAssign::eval()
+{
+    SpValue v0 = getCurrentNS();
+    SpNameSpace* ns = dynamic_cast<SpNameSpace*>(v0.getObject());
+    //    static SpValue v;
+    SpValue v, temp;
+
+    v = val.eval();
+    SpValue p(new NSVar(place));
+    ns->setValue(p, v, ns);
+    //    return v;
+    return SpValueResult(v);
+}
+
+SpValue& SpAssign::toString()
+{
+    SpString* str;
+    SpValue v1, v2;
+
+    str = new SpString();
+    *str += place.toString();
+    *str += " = ";
+    *str += val.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+bool SpAssign::operator==(SpObject& obj)
+{
+    SpAssign* ptr = dynamic_cast<SpAssign*>(&obj);
+    if(ptr != NULL){
+        return (place == ptr->place) &&
+                (val == ptr->val);
+    }
+    return false;
+}
+
+bool SpAssign::operator<(SpObject& obj)
+{
+    SpAssign* ptr = dynamic_cast<SpAssign*>(&obj);
+    if(ptr != NULL){
+        if(place != ptr->place){
+            return place < ptr->place;
+        }
+        return val < ptr->val;
+    }
+    return SpObject::operator<(obj);
+}
+
+
+/*
+ * class SpAssignS
+ */
+
+SpAssignS::~SpAssignS()
+{
+#ifdef TEST
+    *spout << ":destroy AssignS:" << "\n";
+#endif
+}
+
+SpValue& SpAssignS::eval()
+{
+    SpValue v0 = getCurrentNS();
+    SpNameSpace* ns = dynamic_cast<SpNameSpace*>(v0.getObject());
+    //    static SpValue values;
+    //    static SpValue v;
+    SpValue values;
+    SpValue v;
+
+    values = val.eval();
+    if(!values.isObject()){
+        throw SpException("not tuple in let");
+    }
+    SpTuple* tuple = dynamic_cast<SpTuple*>(values.getObject());
+    if(tuple == NULL){
+        throw SpException("not tuple in let");
+    }
+    if(tuple->length() != (SpInt)places.size()){
+        throw SpException("arg length mismatch in let");
+    }
+    SpValueVector::iterator dist = places.begin();
+    SpValueVector::iterator src = tuple->begin();
+    for(; dist != places.end(); src++, dist++){
+        SpValue p;
+        p.setNewObject(new NSVar(*dist));
+        v = *src;
+        ns->setValue(p, v, ns);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+SpValue& SpAssignS::toString()
+{
+    SpString* str;
+    SpValue v1, v2;
+
+    str = new SpString();
+    *str = "AssignS(";
+    SpValueVector::iterator it = places.begin();
+    *str += it->toString();
+    it++;
+    for(; it != places.end(); it++){
+        *str += ",";
+        *str += it->toString();
+    }
+    *str += " <= ";
+    *str += val.toString();
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+bool SpAssignS::operator==(SpObject& obj)
+{
+    SpAssignS* ptr = dynamic_cast<SpAssignS*>(&obj);
+    if(ptr != NULL){
+        if(places.size() != ptr->places.size()){
+            return false;
+        }
+        SpValueVector::iterator it1, it2;
+        it1 = places.begin();
+        it2 = ptr->places.begin();
+        for(; it1 != places.end(); it1++, it2++){
+            if(*it1 != *it2){
+                return false;
+            }
+        }
+        return true;
+    }
+    return false;
+}
+
+bool SpAssignS::operator<(SpObject& obj)
+{
+    SpAssignS* ptr = dynamic_cast<SpAssignS*>(&obj);
+    if(ptr != NULL){
+        if(places.size() != ptr->places.size()){
+            return places.size() < ptr->places.size();
+        }
+        SpValueVector::iterator it1, it2;
+        it1 = places.begin();
+        it2 = ptr->places.begin();
+        for(; it1 != places.end(); it1++, it2++){
+            if(*it1 != *it2){
+                return *it1 < *it2;
+            }
+        }
+        return val < ptr->val;
+    }
+    return SpObject::operator<(obj);
+}
+
+/*
+ * class SpAssignSM
+ */
+
+SpAssignSM::~SpAssignSM()
+{
+#ifdef TEST
+    *spout << ":destroy AssignSM:" << "\n";
+#endif
+}
+
+SpValue& SpAssignSM::eval()
+{
+    //    static SpValue v;
+    SpValue v;
+
+    SpSendMsg* ptr = dynamic_cast<SpSendMsg*>(place.getObject());
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    SpValue nspace = ptr->receiver.eval();
+    SpValue feature = ptr->message;
+    if(nspace.isByteArray()){
+        SpByteArray* ary = dynamic_cast<SpByteArray*>(nspace.getObject());
+        v = val.eval();
+        CheckType(SymInt, v);
+        SpValue index = feature.eval();
+        (*ary)[index] = (unsigned char)v.getInt();
+    }else if(nspace.isArray()){
+        SpArray* ary = dynamic_cast<SpArray*>(nspace.getObject());
+        v = val.eval();
+        CheckType(ary->getFeatureType(), v);
+        SpValue index = feature.eval();
+        ary->set(index, v);
+    }else if(nspace.isNameSpace()){
+        SpNameSpace* ns = dynamic_cast<SpNameSpace*>(nspace.getObject());
+        SpValue curNS = getCurrentNS();
+        SpNameSpace* cur_ns = curNS.asNameSpace();
+        SpValue p2(new NSVar(feature));
+        v = val.eval();
+        ns->setValue(p2, v, cur_ns);
+#ifdef USE_DATABASE
+    }else if(nspace.isDatabase()){
+        SpDatabase* db = dynamic_cast<SpDatabase*>(nspace.getObject());
+        v = val.eval();
+        db->setRoot(feature, v);
+#endif
+    }else if(nspace.isDate()){
+        SpDate* date = dynamic_cast<SpDate*>(nspace.getObject());
+        v = val.eval();
+        date->assign(feature, v);
+    }else if(nspace.isTime()){
+        SpTime* time = dynamic_cast<SpTime*>(nspace.getObject());
+        v = val.eval();
+        time->assign(feature, v);
+    }else if(nspace.isDateTime()){
+        SpDateTime* dt = dynamic_cast<SpDateTime*>(nspace.getObject());
+        v = val.eval();
+        dt->assign(feature, v);
+    }else{
+        throw SpException("not namespace (assign)");
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+SpValue& SpAssignSM::toString()
+{
+    SpString* str;
+    SpValue v1, v2;
+
+    str = new SpString();
+    *str = "Assign(";
+    *str += place.toString();
+    *str += " <= ";
+    *str += val.toString();
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+bool SpAssignSM::operator==(SpObject& obj)
+{
+    SpAssignSM* ptr = dynamic_cast<SpAssignSM*>(&obj);
+    if(ptr != NULL){
+        return (place == ptr->place) &&
+                (val == ptr->val);
+    }
+    return false;
+}
+
+bool SpAssignSM::operator<(SpObject& obj)
+{
+    SpAssignSM* ptr = dynamic_cast<SpAssignSM*>(&obj);
+    if(ptr != NULL){
+        if(place != ptr->place){
+            return place < ptr->place;
+        }
+        return val < ptr->val;
+    }
+    return SpObject::operator<(obj);
+}
+
+/*
+ * class SpAssignList
+ */
+
+SpAssignList::~SpAssignList()
+{
+#ifdef TEST
+    *spout << ":destroy AssignList:" << "\n";
+#endif
+}
+
+SpValue& SpAssignList::eval()
+{
+    SpValue v0 = getCurrentNS();
+    SpNameSpace* ns = dynamic_cast<SpNameSpace*>(v0.getObject());
+    //    static SpValue values;
+    //    static SpValue v;
+    SpValue values;
+    SpValue v;
+
+    values = val.eval();
+    if(!values.isObject()){
+        throw SpException("not list in let");
+    }
+    SpList* list = dynamic_cast<SpList*>(values.getObject());
+    if(list == NULL){
+        throw SpException("not list in let");
+    }
+
+    SpNameSpace dammy;
+    SpValueVector::iterator dist = places.begin();
+    SpList* src = list;
+    for(; dist != places.end(); src = src->next(), dist++){
+        if(src == NULL){
+            throw SpException("arg length mismatch in let list");
+        }
+        v = src->value();
+        dammy.internVar(*dist, v);
+    }
+    if(src != NULL){
+        throw SpException("arg length mismatch in let list");
+    }
+    // copy dammy to current NameSpace
+    *ns += dammy;
+    //    return v;
+    return SpValueResult(v);
+}
+
+SpValue& SpAssignList::toString()
+{
+    SpString* str;
+    SpValue v1, v2;
+
+    str = new SpString();
+    *str = "AssignList(";
+    SpValueVector::iterator it = places.begin();
+    *str += it->toString();
+    it++;
+    for(; it != places.end(); it++){
+        *str += ",";
+        *str += it->toString();
+    }
+    *str += " <= ";
+    *str += val.toString();
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+bool SpAssignList::operator==(SpObject& obj)
+{
+    SpAssignList* ptr = dynamic_cast<SpAssignList*>(&obj);
+    if(ptr != NULL){
+        if(places.size() != ptr->places.size()){
+            return false;
+        }
+        SpValueVector::iterator it1, it2;
+        it1 = places.begin();
+        it2 = ptr->places.begin();
+        for(; it1 != places.end(); it1++, it2++){
+            if(*it1 != *it2){
+                return false;
+            }
+        }
+        return true;
+    }
+    return false;
+}
+
+bool SpAssignList::operator<(SpObject& obj)
+{
+    SpAssignList* ptr = dynamic_cast<SpAssignList*>(&obj);
+    if(ptr != NULL){
+        if(places.size() != ptr->places.size()){
+            return places.size() < ptr->places.size();
+        }
+        SpValueVector::iterator it1, it2;
+        it1 = places.begin();
+        it2 = ptr->places.begin();
+        for(; it1 != places.end(); it1++, it2++){
+            if(*it1 != *it2){
+                return *it1 < *it2;
+            }
+        }
+        return val < ptr->val;
+    }
+    return SpObject::operator<(obj);
+}
+
+/*
+ * class SpAssignHT (Head & Tail)
+ */
+
+SpAssignHT::~SpAssignHT()
+{
+#ifdef TEST
+    *spout << ":destroy AssignHT:" << "\n";
+#endif
+}
+
+SpValue& SpAssignHT::eval()
+{
+    SpValue v0 = getCurrentNS();
+    SpNameSpace* ns = dynamic_cast<SpNameSpace*>(v0.getObject());
+    SpValue values = val.eval();
+    if(!values.isList()){
+        throw SpException("not list in let");
+    }
+    SpList* list = values.asList();
+
+    //    ns->internVar(head, list->value());
+    SpValue temp;
+    temp = list->value();
+    ns->internVar(head, temp);
+    //    static SpValue v;
+    SpValue v;
+    v = list->nextList();
+    v = v.eval();
+    ns->internVar(tail, v);
+
+    //    return v;
+    return SpValueResult(v);
+}
+
+SpValue& SpAssignHT::toString()
+{
+    SpString* str;
+    SpValue v1, v2;
+
+    str = new SpString();
+    *str = "let ";
+    *str += head.toString();
+    *str += "::";
+    *str += tail.toString();
+    *str += " = ";
+    *str += val.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+bool SpAssignHT::operator==(SpObject& obj)
+{
+    SpAssignHT* ptr = dynamic_cast<SpAssignHT*>(&obj);
+    if(ptr != NULL){
+        if(head != ptr->head){
+            return false;
+        }
+        if(tail != ptr->tail){
+            return false;
+        }
+        return val == ptr->val;
+    }
+    return false;
+}
+
+bool SpAssignHT::operator<(SpObject& obj)
+{
+    SpAssignHT* ptr = dynamic_cast<SpAssignHT*>(&obj);
+    if(ptr != NULL){
+        if(head != ptr->head){
+            return head < ptr->head;
+        }
+        if(tail != ptr->tail){
+            return tail < ptr->tail;
+        }
+        return val < ptr->val;
+    }
+    return SpObject::operator<(obj);
+}
+
diff --git a/src/Base64.cpp b/src/Base64.cpp
new file mode 100644 (file)
index 0000000..71dc847
--- /dev/null
@@ -0,0 +1,405 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Base64.cpp,v 1.7 2004/03/24 13:45:51 randy Exp $
+ */
+
+#include <stdio.h>
+#include "soopy.h"
+
+const char* BASE64TBL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+/*
+ * Class Base64Reader
+ */
+
+SpChar Base64ReadEncoder::readCh()
+{
+    char c;
+    int src;
+
+    switch(count){
+      case 1:
+      case 2:
+      case 3:
+        return results[count++];
+      default:
+        // read 3 chars
+        c = reader->ReadChar();
+        if(eof()){ return (SpChar)NULL; }
+        src = (c & 0xff) << 16;
+        c = reader->ReadChar();
+        if(eof()){
+            c = 0;
+        }
+        src = src | ((c & 0xff) << 8);
+        c = reader->ReadChar();
+        if(eof()){
+            c = 0;
+        }
+        src = src | (c & 0xff);
+        // split to 4 chars
+        results[0] = MakeSpChar(CodeJIS, BASE64TBL[(src >> 18) & 0x3F]);
+        results[1] = MakeSpChar(CodeJIS, BASE64TBL[(src >> 12) & 0x3F]);
+        results[2] = MakeSpChar(CodeJIS, BASE64TBL[(src >> 6) & 0x3F]);
+        results[3] = MakeSpChar(CodeJIS, BASE64TBL[src & 0x3F]);
+        if(eof()){
+            if((src & 0x3F) == 0){
+                results[3] = '=';
+                if(((src >> 6) & 0x3F) == 0){
+                    results[2] = '=';
+                }
+            }
+        }
+        // set count
+        count = 1;
+    }
+
+    return results[0];
+}
+
+/*
+ * Class Base64WriteEncoder
+ */
+
+//void Base64WriteEncoder::writeCh(unsigned char c)
+void Base64WriteEncoder::WriteChar(SpChar c)
+{
+    switch(count){
+      case 0:
+        src = (c & 0xff) << 16;
+        count++;
+        break;
+      case 1:
+        src = src | ((c & 0xff) << 8);
+        count++;
+        break;
+      case 2:
+        src = src | (c & 0xff);
+        count = 0;
+        // split to 4 chars
+        writer->WriteChar(BASE64TBL[(src >> 18) & 0x3F]);
+        writer->WriteChar(BASE64TBL[(src >> 12) & 0x3F]);
+        writer->WriteChar(BASE64TBL[(src >> 6) & 0x3F]);
+        writer->WriteChar(BASE64TBL[src & 0x3F]);
+        break;
+    }
+}
+
+void Base64WriteEncoder::flush()
+{
+    if(count != 0){
+        count = 0;
+        // split to 4 chars
+        writer->WriteChar(BASE64TBL[(src >> 18) & 0x3F]);
+        writer->WriteChar(BASE64TBL[(src >> 12) & 0x3F]);
+        if((src & 0x3F) == 0){
+            if(((src >> 6) & 0x3F) == 0){
+                writer->WriteChar('=');
+                writer->WriteChar('=');
+            }else{
+                writer->WriteChar(BASE64TBL[(src >> 6) & 0x3F]);
+                writer->WriteChar('=');
+            }
+        }else{
+            writer->WriteChar(BASE64TBL[(src >> 6) & 0x3F]);
+            writer->WriteChar(BASE64TBL[src & 0x3F]);
+        }
+    }
+    writer->flush();
+}
+
+/*
+ * Class Base64Reader
+ */
+
+static bool isBase64Char(char c)
+{
+    if(isdigit(c)){
+        return true;
+    }
+    if(isalpha(c)){
+        return true;
+    }
+    if((c == '+') ||
+       (c == '/') ||
+       (c == '='))
+    {
+        return true;
+    }
+    return false;
+}
+
+static int decodeChar(int c)
+{
+    int result;
+    if(isupper(c)){
+        result = c - 'A';
+    }else if(islower(c)){
+        result = c - 'a' + 26;
+    }else if(isdigit(c)){
+        result = c - '0' + 52;
+    }else{
+        switch(c){
+          case '+':
+            result = 62;
+            break;
+          case '/':
+            result = 63;
+            break;
+          case '=':
+            result = 0;
+            break;
+        }
+    }
+    return result;
+}
+
+SpChar Base64ReadDecoder::readCh()
+{
+    char c;
+    int ch1, ch2, ch3, ch4;
+    bool p = false;
+
+    switch(count){
+      case 1:
+      case 2:
+        return results[count++];
+      default:
+        // read 4 chars
+        while(true){
+            c = reader->ReadChar();
+            if(eof()){ return (SpChar)NULL; }
+            if(isBase64Char(c)){
+                break;
+            }
+        }
+        ch1 = c & 0xff;
+        while(true){
+            c = reader->ReadChar();
+            if(eof()){ return (SpChar)NULL; }
+            if(isBase64Char(c)){
+                break;
+            }
+        }
+        ch2 = c & 0xff;
+        while(true){
+            c = reader->ReadChar();
+            if(eof()){ return (SpChar)NULL; }
+            if(isBase64Char(c)){
+                break;
+            }
+        }
+        if(c == '='){
+            p = true;
+        }else{
+            ch3 = c & 0xff;
+        }
+        while(true){
+            c = reader->ReadChar();
+            if(eof()){ return (SpChar)NULL; }
+            if(isBase64Char(c)){
+                break;
+            }
+        }
+        if(c == '='){
+            p = true;
+        }else{
+            ch4 = c & 0xff;
+        }
+
+        // decode
+        int i;
+        i = decodeChar(ch1) << 18;
+        i = i | (decodeChar(ch2) << 12);
+        i = i | (decodeChar(ch3) << 6);
+        i = i | decodeChar(ch4);
+        // set results
+        results[0] = MakeSpChar(CodeJIS, (i >> 16) & 0xFF);
+        if(p){
+            if((i & 0xFF) == 0){
+                if(((i >> 8) & 0xFF) == 0){
+                    results[1] = (SpChar)NULL;
+                    results[2] = (SpChar)NULL;
+                }else{
+                    results[1] = MakeSpChar(CodeJIS, (i >> 8) & 0xFF);
+                    results[2] = (SpChar)NULL;
+                }
+            }else{
+                results[1] = MakeSpChar(CodeJIS, (i >> 8) & 0xFF);
+                results[2] = MakeSpChar(CodeJIS, i & 0xFF);
+            }
+        }else{
+            results[1] = MakeSpChar(CodeJIS, (i >> 8) & 0xFF);
+            results[2] = MakeSpChar(CodeJIS, i & 0xFF);
+        }
+
+        // set count
+        count = 1;
+    }
+
+    return results[0];
+}
+
+/*
+ * Class Base64WriteDecoder
+ */
+
+//void Base64WriteDecoder::writeCh(unsigned char c)
+void Base64WriteDecoder::WriteChar(SpChar c)
+{
+    if(!isBase64Char(c)){
+        return;
+    }
+    switch(count){
+      case 0:
+        src = decodeChar(c) << 18;
+        count++;
+        break;
+      case 1:
+        src = src | (decodeChar(c) << 12);
+        count++;
+        break;
+      case 2:
+        if(c != '='){
+            src = src | (decodeChar(c) << 6);
+        }else{
+            eof = true;
+        }
+        count++;
+        break;
+      case 3:
+        if(c != '='){
+            src = src | decodeChar(c);
+        }else{
+            eof = true;
+        }
+        count = 0;
+        // split to 3 chars
+        writer->WriteChar((src >> 16) & 0xFF);
+        if(eof){
+            if((src & 0xFF) == 0){
+                if(((src >> 8) & 0xFF) != 0){
+                    writer->WriteChar((src >> 8) & 0xFF);
+                }
+            }else{
+                writer->WriteChar((src >> 8) & 0xFF);
+                writer->WriteChar(src & 0xFF);
+            }
+        }else{
+            writer->WriteChar((src >> 8) & 0xFF);
+            writer->WriteChar(src & 0xFF);
+        }
+        break;
+    }
+}
+
+void Base64WriteDecoder::flush()
+{
+    if(count != 0){
+        count = 0;
+        // split to 3 chars
+        writer->WriteChar((src >> 16) & 0xFF);
+        if(eof){
+            if((src & 0xFF) == 0){
+                if(((src >> 8) & 0xFF) != 0){
+                    writer->WriteChar((src >> 8) & 0xFF);
+                }
+            }else{
+                writer->WriteChar((src >> 8) & 0xFF);
+                writer->WriteChar(src & 0xFF);
+            }
+        }else{
+            writer->WriteChar((src >> 8) & 0xFF);
+            writer->WriteChar(src & 0xFF);
+        }
+    }
+    writer->flush();
+}
+
+/*
+ * Base64
+ */
+
+SpValue& base64_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (Base64.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new Base64ReadEncoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& base64_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (Base64.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new Base64WriteEncoder(writer);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& base64_decoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (Base64.decoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new Base64ReadDecoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& base64_decoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (Base64.decoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new Base64WriteDecoder(writer);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+// init
+void initBase64()
+{
+    SpValue SymBase64(new SpSymbol("base64"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSBase64(ns);
+    PMainNameSpace->internConst(SymBase64, NSBase64);
+
+    SpValue PrimEncoderIn(new SpPrim1(&base64_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+    SpValue PrimDecoderIn(new SpPrim1(&base64_decoderIn));
+    ns->internConst(SymDecoderIn, PrimDecoderIn);
+
+    SpValue PrimEncoderOut(new SpPrim1(&base64_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+    SpValue PrimDecoderOut(new SpPrim1(&base64_decoderOut));
+    ns->internConst(SymDecoderOut, PrimDecoderOut);
+}
+
diff --git a/src/Bool.cpp b/src/Bool.cpp
new file mode 100644 (file)
index 0000000..32a7e2c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Bool.cpp,v 1.4 2002/12/05 12:28:58 randy Exp $
+ */
+
+#include "soopy.h"
+
+void initBool()
+{
+}
+
diff --git a/src/Byte.cpp b/src/Byte.cpp
new file mode 100644 (file)
index 0000000..6ed4da6
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002-2004 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Byte.cpp,v 1.16 2004/05/22 05:22:34 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * ByteFile
+ *   openIn, openOut, openAppend
+ */
+
+SpValue& byte_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (ByteFile.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+#ifdef __WIN32__
+    fin->open(filename, ios::binary);
+#else
+    fin->open(filename);
+#endif
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    return SpObjectResult(sr);
+}
+
+SpValue& byte_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (ByteFile.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary);
+#else
+    fout->open(filename);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    return SpObjectResult(sw);
+}
+
+SpValue& byte_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Byte.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    return SpObjectResult(sw);
+}
+
+void initByteFile()
+{
+    SpValue SymByteFile(new SpSymbol("byte"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSByteFile(ns);
+    PMainNameSpace->internConst(SymByteFile, NSByteFile);
+
+    SpValue PrimOpenIn(new SpPrim1(&byte_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&byte_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&byte_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+}
+
+
diff --git a/src/CR_LF.cpp b/src/CR_LF.cpp
new file mode 100644 (file)
index 0000000..f0ac95c
--- /dev/null
@@ -0,0 +1,942 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: CR_LF.cpp,v 1.11 2004/05/22 05:22:34 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * CRLF -> LF
+ */
+
+/*
+ * Class CRLF2LFReadEncoder
+ */
+
+SpChar CRLF2LFReadEncoder::readCh()
+{
+    SpChar c;
+
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+    SpChar c2 = SpCharGetChar(c);
+    if(c2 == CR){
+        SpChar ch = reader->ReadChar();
+        SpChar ch2 = SpCharGetChar(ch);
+        if(ch2 == LF){
+            return MakeSpChar(CodeJIS, LF);
+        }else{
+            reader->UnreadChar(ch);
+            return c;
+        }
+    }
+    return c;
+}
+
+/*
+ * Class CRLF2LFWriter
+ */
+
+void CRLF2LFWriteEncoder::WriteChar(SpChar ch)
+{
+    SpChar c = SpCharGetChar(ch);
+
+    if(prevCR){
+        prevCR = false;
+        if(c == LF){
+            writer->WriteChar(MakeSpChar(CodeJIS, LF));
+            return;
+        }else{
+            writer->WriteChar(MakeSpChar(CodeJIS, CR));
+        }
+    }
+
+    if(c == CR){
+        prevCR = true;
+    }else{
+        writer->WriteChar(ch);
+    }
+}
+
+
+/*
+ * CRLF2LFFile
+ *   openIn, openOut
+ */
+
+SpValue& crlf2lf_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CRLF2LF.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+    fin->open(filename);
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new CRLF2LFReadEncoder(sr);
+    return SpObjectResult(encoder);
+}
+
+SpValue& crlf2lf_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CRLF2LF.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+    fout->open(filename);
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new CRLF2LFWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& crlf2lf_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CRLF2LF.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new CRLF2LFWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& crlf2lf_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (CRLF2LF.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new CRLF2LFReadEncoder(reader);
+    return SpObjectResult(encoder);
+}
+
+SpValue& crlf2lf_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (CRLF2LF.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new CRLF2LFWriteEncoder(writer);
+    return SpObjectResult(encoder);
+}
+
+// init
+void initCRLF2LF()
+{
+    SpValue SymCRLF2LF(new SpSymbol("crlf2lf"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSCRLF2LF(ns);
+    PMainNameSpace->internConst(SymCRLF2LF, NSCRLF2LF);
+
+    SpValue PrimOpenIn(new SpPrim1(&crlf2lf_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&crlf2lf_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&crlf2lf_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&crlf2lf_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+
+    SpValue PrimEncoderOut(new SpPrim1(&crlf2lf_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+}
+
+/*
+ * CRLF -> CR
+ */
+
+/*
+ * Class CRLF2CRReadEncoder
+ */
+
+SpChar CRLF2CRReadEncoder::readCh()
+{
+    SpChar c;
+
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+    SpChar c2 = SpCharGetChar(c);
+    if(c2 == CR){
+        SpChar ch = reader->ReadChar();
+        SpChar ch2 = SpCharGetChar(ch);
+        if(ch2 == LF){
+            return MakeSpChar(CodeJIS, CR);
+        }else{
+            reader->UnreadChar(ch);
+            return c;
+        }
+    }
+    return c;
+}
+
+/*
+ * Class CRLF2CRWriter
+ */
+
+void CRLF2CRWriteEncoder::WriteChar(SpChar ch)
+{
+    SpChar c = SpCharGetChar(ch);
+
+    if(prevCR){
+        prevCR = false;
+        if(c == LF){
+            writer->WriteChar(MakeSpChar(CodeJIS, CR));
+            return;
+        }else{
+            writer->WriteChar(MakeSpChar(CodeJIS, CR));
+        }
+    }
+
+    if(c == CR){
+        prevCR = true;
+    }else{
+        writer->WriteChar(ch);
+    }
+}
+
+
+/*
+ * CRLF2CRFile
+ *   openIn, openOut
+ */
+
+SpValue& crlf2cr_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CRLF2CR.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+    fin->open(filename);
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new CRLF2CRReadEncoder(sr);
+    return SpObjectResult(encoder);
+}
+
+SpValue& crlf2cr_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CRLF2CR.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+    fout->open(filename);
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new CRLF2CRWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& crlf2cr_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CRLF2CR.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new CRLF2CRWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& crlf2cr_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (CRLF2CR.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new CRLF2CRReadEncoder(reader);
+    return SpObjectResult(encoder);
+}
+
+SpValue& crlf2cr_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (CRLF2CR.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new CRLF2CRWriteEncoder(writer);
+    return SpObjectResult(encoder);
+}
+
+// init
+void initCRLF2CR()
+{
+    SpValue SymCRLF2CR(new SpSymbol("crlf2cr"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSCRLF2CR(ns);
+    PMainNameSpace->internConst(SymCRLF2CR, NSCRLF2CR);
+
+    SpValue PrimOpenIn(new SpPrim1(&crlf2cr_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&crlf2cr_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&crlf2cr_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&crlf2cr_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+
+    SpValue PrimEncoderOut(new SpPrim1(&crlf2cr_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+}
+
+/*
+ * LF -> CRLF
+ */
+
+/*
+ * Class LF2CRLFReadEncoder
+ */
+
+SpChar LF2CRLFReadEncoder::readCh()
+{
+    SpChar c;
+
+    if(prevLF){
+        prevLF = false;
+        return MakeSpChar(CodeJIS, LF);
+    }else{
+        if(eof()){ return (SpChar)NULL; }
+        c = reader->ReadChar();
+        if(SpCharGetChar(c) == LF){
+            prevLF = true;
+            return MakeSpChar(CodeJIS, CR);
+        }
+    }
+    return c;
+}
+
+/*
+ * Class LF2CRLFWriter
+ */
+
+void LF2CRLFWriteEncoder::WriteChar(SpChar ch)
+{
+    SpChar c = SpCharGetChar(ch);
+    if(c == LF){
+        writer->WriteChar(MakeSpChar(CodeJIS, CR));
+        writer->WriteChar(MakeSpChar(CodeJIS, LF));
+    }else{
+        writer->WriteChar(ch);
+    }
+}
+
+
+/*
+ * LF2CRLFFile
+ *   openIn, openOut
+ */
+
+SpValue& lf2crlf_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (LF2CRLF.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+    fin->open(filename);
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new LF2CRLFReadEncoder(sr);
+    return SpObjectResult(encoder);
+}
+
+SpValue& lf2crlf_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (LF2CRLF.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+    fout->open(filename);
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new LF2CRLFWriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& lf2crlf_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (LF2CRLF.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new LF2CRLFWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& lf2crlf_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (LF2CRLF.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new LF2CRLFReadEncoder(reader);
+    return SpObjectResult(encoder);
+}
+
+SpValue& lf2crlf_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (LF2CRLF.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new LF2CRLFWriteEncoder(writer);
+    return SpObjectResult(encoder);
+}
+
+// init
+void initLF2CRLF()
+{
+    SpValue SymLF2CRLF(new SpSymbol("lf2crlf"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSLF2CRLF(ns);
+    PMainNameSpace->internConst(SymLF2CRLF, NSLF2CRLF);
+
+    SpValue PrimOpenIn(new SpPrim1(&lf2crlf_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&lf2crlf_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&lf2crlf_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&lf2crlf_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+
+    SpValue PrimEncoderOut(new SpPrim1(&lf2crlf_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+}
+
+/*
+ * CR -> CRLF
+ */
+
+/*
+ * Class CR2CRLFReadEncoder
+ */
+
+SpChar CR2CRLFReadEncoder::readCh()
+{
+    SpChar c;
+
+    if(prevCR){
+        prevCR = false;
+        return MakeSpChar(CodeJIS, LF);
+    }else{
+        c = reader->ReadChar();
+        if(eof()){ return (SpChar)NULL; }
+        if(SpCharGetChar(c) == CR){
+            prevCR = true;
+            return MakeSpChar(CodeJIS, CR);
+        }
+    }
+    return c;
+}
+
+/*
+ * Class CR2CRLFWriter
+ */
+
+void CR2CRLFWriteEncoder::WriteChar(SpChar ch)
+{
+    SpChar c = SpCharGetChar(ch);
+    if(c == CR){
+        writer->WriteChar(MakeSpChar(CodeJIS, CR));
+        writer->WriteChar(MakeSpChar(CodeJIS, LF));
+    }else{
+        writer->WriteChar(ch);
+    }
+}
+
+
+/*
+ * CR2CRLFFile
+ *   openIn, openOut
+ */
+
+SpValue& cr2crlf_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CR2CRLF.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+    fin->open(filename);
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new CR2CRLFReadEncoder(sr);
+    return SpObjectResult(encoder);
+}
+
+SpValue& cr2crlf_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CR2CRLF.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+    fout->open(filename);
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new CR2CRLFWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& cr2crlf_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CR2CRLF.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new CR2CRLFWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& cr2crlf_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (CR2CRLF.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new CR2CRLFReadEncoder(reader);
+    return SpObjectResult(encoder);
+}
+
+SpValue& cr2crlf_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (CR2CRLF.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new CR2CRLFWriteEncoder(writer);
+    return SpObjectResult(encoder);
+}
+
+// init
+void initCR2CRLF()
+{
+    SpValue SymCR2CRLF(new SpSymbol("cr2crlf"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSCR2CRLF(ns);
+    PMainNameSpace->internConst(SymCR2CRLF, NSCR2CRLF);
+
+    SpValue PrimOpenIn(new SpPrim1(&cr2crlf_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&cr2crlf_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&cr2crlf_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&cr2crlf_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+
+    SpValue PrimEncoderOut(new SpPrim1(&cr2crlf_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+}
+
+/*
+ * CR -> LF
+ */
+
+/*
+ * Class CR2LFReadEncoder
+ */
+
+SpChar CR2LFReadEncoder::readCh()
+{
+    if(eof()){ return (SpChar)NULL; }
+    SpChar c = reader->ReadChar();
+    if(SpCharGetChar(c) == CR){
+        return MakeSpChar(CodeJIS, LF);
+    }
+    return c;
+}
+
+/*
+ * Class CR2LFWriter
+ */
+
+void CR2LFWriteEncoder::WriteChar(SpChar ch)
+{
+    SpChar c = SpCharGetChar(ch);
+    if(c == CR){
+        writer->WriteChar(MakeSpChar(CodeJIS, LF));
+    }else{
+        writer->WriteChar(ch);
+    }
+}
+
+
+/*
+ * CR2LFFile
+ *   openIn, openOut
+ */
+
+SpValue& cr2lf_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CR2LF.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+    fin->open(filename);
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new CR2LFReadEncoder(sr);
+    return SpObjectResult(encoder);
+}
+
+SpValue& cr2lf_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CR2LF.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+    fout->open(filename);
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new CR2LFWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& cr2lf_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (CR2LF.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new CR2LFWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& cr2lf_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (CR2LF.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new CR2LFReadEncoder(reader);
+    return SpObjectResult(encoder);
+}
+
+SpValue& cr2lf_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (CR2LF.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new CR2LFWriteEncoder(writer);
+    return SpObjectResult(encoder);
+}
+
+// init
+void initCR2LF()
+{
+    SpValue SymCR2LF(new SpSymbol("cr2lf"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSCR2LF(ns);
+    PMainNameSpace->internConst(SymCR2LF, NSCR2LF);
+
+    SpValue PrimOpenIn(new SpPrim1(&cr2lf_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&cr2lf_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&cr2lf_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&cr2lf_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+
+    SpValue PrimEncoderOut(new SpPrim1(&cr2lf_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+}
+
+/*
+ * LF -> CR
+ */
+
+/*
+ * Class LF2CRReadEncoder
+ */
+
+SpChar LF2CRReadEncoder::readCh()
+{
+    if(eof()){ return (SpChar)NULL; }
+    SpChar c = reader->ReadChar();
+    if(SpCharGetChar(c) == LF){
+        return MakeSpChar(CodeJIS, CR);
+    }
+    return c;
+}
+
+/*
+ * Class LF2CRWriter
+ */
+
+void LF2CRWriteEncoder::WriteChar(SpChar ch)
+{
+    SpChar c = SpCharGetChar(ch);
+    if(c == LF){
+        writer->WriteChar(MakeSpChar(CodeJIS, CR));
+    }else{
+        writer->WriteChar(ch);
+    }
+}
+
+
+/*
+ * LF2CRFile
+ *   openIn, openOut
+ */
+
+SpValue& lf2cr_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (LF2CR.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+    fin->open(filename);
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new LF2CRReadEncoder(sr);
+    return SpObjectResult(encoder);
+}
+
+SpValue& lf2cr_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (LF2CR.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+    fout->open(filename);
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new LF2CRWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& lf2cr_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (LF2CR.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new LF2CRWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& lf2cr_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (LF2CR.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new LF2CRReadEncoder(reader);
+    return SpObjectResult(encoder);
+}
+
+SpValue& lf2cr_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (LF2CR.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new LF2CRWriteEncoder(writer);
+    return SpObjectResult(encoder);
+}
+
+// init
+void initLF2CR()
+{
+    SpValue SymLF2CR(new SpSymbol("lf2cr"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSLF2CR(ns);
+    PMainNameSpace->internConst(SymLF2CR, NSLF2CR);
+
+    SpValue PrimOpenIn(new SpPrim1(&lf2cr_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&lf2cr_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&lf2cr_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&lf2cr_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+
+    SpValue PrimEncoderOut(new SpPrim1(&lf2cr_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+}
+
diff --git a/src/Char.cpp b/src/Char.cpp
new file mode 100644 (file)
index 0000000..ae5d931
--- /dev/null
@@ -0,0 +1,423 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Char.cpp,v 1.23 2004/03/21 05:48:06 randy Exp $
+ */
+
+#include "soopy.h"
+
+//
+// SpChar Util routines
+//
+//const char* spCharToCString(SpChar ch, Writer& writer)
+const char* spCharToCString(SpChar ch, WriteEncoder& writer)
+{
+    ostringstream ost;
+    StreamWriter sw(&ost);
+    Writer* old = writer.getWriter();
+    writer.setWriter(&sw);
+    writer.WriteChar(ch);
+    writer.setWriter(old);
+
+    static string str;
+    str = ost.str();
+    return str.c_str();
+}
+
+bool isEOF(SpChar c)
+{
+    return c == (SpChar)NULL;
+}
+
+bool isEOL(SpChar c)
+{
+    switch(c){
+#ifdef __WIN32__
+    case JIS('\n'):
+#else
+    case JIS('\r'):
+    case JIS(10):
+#endif
+    case 0: // EOF
+        return true;
+    }
+    return false;
+}
+
+bool isWhiteSpace(SpChar c)
+{
+    switch(c){
+    case JIS(' '):
+    case JIS('\t'):
+    case JIS(8):
+    case JIS(13):
+    case JIS(10):
+      //case JIS('\n'):
+      //case JIS('\r'):
+        return true;
+    }
+    return false;
+}
+
+bool isAlpha(SpChar c)
+{
+    if((JIS('a') <= c) && (c <= JIS('z')) ||
+       (JIS('A') <= c) && (c <= JIS('Z')))
+    {
+      return true;
+    }else{
+      return false;
+    }
+}
+
+bool isDIGIT(SpChar c)
+{
+    switch(c){
+    case JIS('0'):
+    case JIS('1'):
+    case JIS('2'):
+    case JIS('3'):
+    case JIS('4'):
+    case JIS('5'):
+    case JIS('6'):
+    case JIS('7'):
+    case JIS('8'):
+    case JIS('9'):
+        return true;
+    }
+    return false;
+}
+
+int toINT(SpChar c)
+{
+    switch(c){
+    case JIS('0'):
+        return 0;
+    case JIS('1'):
+        return 1;
+    case JIS('2'):
+        return 2;
+    case JIS('3'):
+        return 3;
+    case JIS('4'):
+        return 4;
+    case JIS('5'):
+        return 5;
+    case JIS('6'):
+        return 6;
+    case JIS('7'):
+        return 7;
+    case JIS('8'):
+        return 8;
+    case JIS('9'):
+        return 9;
+    }
+    throw SpException("not digit");
+}
+
+SpChar Zenkaku2Hankaku(SpChar ch)
+{
+    if(0x2330 <=ch && ch <= 0x2339)
+    {
+        // '0' - '9'
+//cout << " digit\n";
+        ch = ch - 0x2330 + '0';
+    }else if(0x2341 <=ch && ch <= 0x235A)
+    {
+        // 'A' - 'Z'
+//cout << " A-Z\n";
+        ch = ch - 0x2341 + 'A';
+    }else if(0x2361 <=ch && ch <= 0x237A)
+    {
+        // 'a' - 'z'
+//cout << " a-z\n";
+        ch = ch - 0x2361 + 'a';
+    }else{
+        switch(ch){
+        case 0x2121: ch = ' '; break;
+        case 0x212a: ch = '!'; break;
+        case 0x2149: ch = '"'; break;
+        case 0x2174: ch = '#'; break;
+        case 0x2170: ch = '$'; break;
+        case 0x2173: ch = '%'; break;
+        case 0x2175: ch = '&'; break;
+        case 0x2147: ch = '\''; break;
+        case 0x214a: ch = '('; break;
+        case 0x214b: ch = ')'; break;
+        case 0x2176: ch = '*'; break;
+        case 0x215c: ch = '+'; break;
+        case 0x2122: ch = ','; break;
+        case 0x2124: ch = ','; break;
+        case 0x215d: ch = '-'; break;
+        case 0x2125: ch = '.'; break;
+        case 0x2123: ch = '.'; break;
+        case 0x213f: ch = '/'; break;
+        case 0x2160: ch = '/'; break;
+        case 0x2127: ch = ':'; break;
+        case 0x2128: ch = ';'; break;
+        case 0x2152: ch = '<'; break;
+        case 0x2163: ch = '<'; break;
+        case 0x2161: ch = '='; break;
+        case 0x2153: ch = '>'; break;
+        case 0x2164: ch = '>'; break;
+        case 0x2129: ch = '?'; break;
+        case 0x2177: ch = '@'; break;
+        case 0x214e: ch = '['; break;
+        case 0x2140: ch = '\\'; break;
+        case 0x216f: ch = '\\'; break;
+        case 0x214f: ch = ']'; break;
+        case 0x2130: ch = '^'; break;
+        case 0x2132: ch = '_'; break;
+        case 0x2150: ch = '{'; break;
+        case 0x2143: ch = '|'; break;
+        case 0x2151: ch = '}'; break;
+        case 0x2141: ch = '~'; break;
+        case 0x2131: ch = '~'; break;
+        }
+    }
+//cout << "conv: " << hex << ch << endl;
+    return ch;
+}
+
+SpChar toHankakuLower(SpChar c)
+{
+    if(EqualCharCode(c, CodeJIS)){
+//cout << "spch: " << hex << c << endl;
+        SpChar ch = SpCharGetChar(c);
+        ch = Zenkaku2Hankaku(ch);
+        if(('A' <= ch) && (ch <= 'Z')){
+            return MakeSpChar(CodeJIS, ch - ('A' - 'a'));
+        }
+        return MakeSpChar(CodeJIS, ch);
+    }
+    return c;
+}
+
+
+/*
+ * Message Handler
+ */
+
+//
+// Primitives
+//
+SpValue& char_lower(SpValue& v)
+{
+    SpChar c = v.getChar();
+    c = SpChar2Lower(c);
+    //    static SpValue res;
+    //    res.setSpChar(c);
+    //    return res;
+    return SpCharResult(c);
+}
+
+SpValue& char_upper(SpValue& v)
+{
+    SpChar c = v.getChar();
+    c = SpChar2Upper(c);
+    //    static SpValue res;
+    //    res.setSpChar(c);
+    //    return res;
+    return SpCharResult(c);
+}
+
+SpValue& char_pred(SpValue& v)
+{
+    SpChar c = v.getChar();
+    //    static SpValue res;
+    //    res.setSpChar(--c);
+    //    return res;
+    return SpCharResult(--c);
+}
+
+SpValue& char_succ(SpValue& v)
+{
+    SpChar c = v.getChar();
+    //    static SpValue res;
+    //    res.setSpChar(++c);
+    //    return res;
+    return SpCharResult(++c);
+}
+
+SpValue& char_toInt(SpValue& v)
+{
+    SpChar c = v.getChar();
+    //    static SpValue res;
+    //    res.setSpChar(c);
+    //    res.typ = TypeInt;
+    //    return res;
+    return SpIntResult((SpInt)c);
+}
+
+SpValue& char_toString(SpValue& v)
+{
+    SpString* str = new SpString;
+    str->addSpChar(v.getChar());
+    //    static SpValue res;
+    //    res.setNewObject(str);
+    //    return res;
+    return SpObjectResult(str);
+}
+
+SpValue& char_isAlpha(SpValue& v)
+{
+    SpChar c = v.getChar();
+    if(isAlpha(c)){
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+SpValue& char_isDigit(SpValue& v)
+{
+    SpChar c = v.getChar();
+    if(isDIGIT(c)){
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+SpValue& char_isAlphaNum(SpValue& v)
+{
+    SpChar c = v.getChar();
+    if(isAlpha(c) || isDIGIT(c)){
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+SpValue& char_isHexDigit(SpValue& v)
+{
+    SpChar c = v.getChar();
+    if(isDIGIT(c)){
+      return TrueObject;
+    }else if((JIS('a') <= c) && (c <= JIS('f')) ||
+              (JIS('A') <= c) && (c <= JIS('F')))
+    {
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+SpValue& char_isSpace(SpValue& v)
+{
+    SpChar c = v.getChar();
+    if(isWhiteSpace(c)){
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+SpValue& char_isLower(SpValue& v)
+{
+    SpChar c = v.getChar();
+    if(isLower(c)){
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+SpValue& char_isUpper(SpValue& v)
+{
+    SpChar c = v.getChar();
+    if(isUpper(c)){
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+SpValue& char_isDoubleByte(SpValue& v)
+{
+    SpChar c = v.getChar();
+    c = SpCharGetChar(c);
+    if(0x0100 <= c && c <= 0xFFFF){
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+SpValue& char_isWide(SpValue& v)
+{
+    SpChar c = v.getChar();
+    c = SpCharGetChar(c);
+    if(0x0100 <= c){
+      return TrueObject;
+    }else{
+      return FalseObject;
+    }
+}
+
+// init Message Handler
+void initChar()
+{
+    CharMsgHandler.append(SymIsChar, PrimTrue);
+
+    SpValue PrimLower(new SpPrim1(char_lower));
+    CharMsgHandler.append(SymLower, PrimLower);
+
+    SpValue PrimUpper(new SpPrim1(char_upper));
+    CharMsgHandler.append(SymUpper, PrimUpper);
+
+    SpValue PrimPred(new SpPrim1(char_pred));
+    CharMsgHandler.append(SymPred, PrimPred);
+
+    SpValue PrimSucc(new SpPrim1(char_succ));
+    CharMsgHandler.append(SymSucc, PrimSucc);
+
+    SpValue PrimToInt(new SpPrim1(char_toInt));
+    CharMsgHandler.append(SymToInt, PrimToInt);
+
+    SpValue PrimToString(new SpPrim1(char_toString));
+    CharMsgHandler.append(SymToString, PrimToString);
+
+    SpValue SymIsAlpha(new SpSymbol("isalpha?"));
+    SpValue PrimIsAlpha(new SpPrim1(char_isAlpha));
+    CharMsgHandler.append(SymIsAlpha, PrimIsAlpha);
+
+    SpValue SymIsDigit(new SpSymbol("isdigit?"));
+    SpValue PrimIsDigit(new SpPrim1(char_isDigit));
+    CharMsgHandler.append(SymIsDigit, PrimIsDigit);
+
+    SpValue SymIsAlphaNum(new SpSymbol("isalphanum?"));
+    SpValue PrimIsAlphaNum(new SpPrim1(char_isAlphaNum));
+    CharMsgHandler.append(SymIsAlphaNum, PrimIsAlphaNum);
+
+    SpValue SymIsHexDigit(new SpSymbol("ishexdigit?"));
+    SpValue PrimIsHexDigit(new SpPrim1(char_isHexDigit));
+    CharMsgHandler.append(SymIsHexDigit, PrimIsHexDigit);
+
+    SpValue SymIsSpace(new SpSymbol("isspace?"));
+    SpValue PrimIsSpace(new SpPrim1(char_isSpace));
+    CharMsgHandler.append(SymIsSpace, PrimIsSpace);
+
+    SpValue SymIsUpper(new SpSymbol("isupper?"));
+    SpValue PrimIsUpper(new SpPrim1(char_isUpper));
+    CharMsgHandler.append(SymIsUpper, PrimIsUpper);
+
+    SpValue SymIsLower(new SpSymbol("islower?"));
+    SpValue PrimIsLower(new SpPrim1(char_isLower));
+    CharMsgHandler.append(SymIsLower, PrimIsLower);
+
+    SpValue SymIsDoubleByte(new SpSymbol("isdoublebytechar?"));
+    SpValue PrimIsDoubleByte(new SpPrim1(char_isDoubleByte));
+    CharMsgHandler.append(SymIsDoubleByte, PrimIsDoubleByte);
+
+    SpValue SymIsWide(new SpSymbol("iswidechar?"));
+    SpValue PrimIsWide(new SpPrim1(char_isWide));
+    CharMsgHandler.append(SymIsWide, PrimIsWide);
+}
diff --git a/src/Closure.cpp b/src/Closure.cpp
new file mode 100644 (file)
index 0000000..ea5df7c
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Closure.cpp,v 1.15 2004/03/24 11:53:44 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * Closure
+ */
+
+SpClosure::SpClosure(SpValue& f, SpValue& aNS)
+    : func(f), ns(aNS)
+{
+    SpFunc* f2 = dynamic_cast<SpFunc*>(func.getObject());
+    argLen = f2->argLen;
+}
+
+SpValue& SpClosure::operator()(SpValue& arg)
+{
+    //    static SpValue result;
+    SpValue result;
+    SpFunc* f2 = dynamic_cast<SpFunc*>(func.getObject());
+    pushCurrentNS(ns);
+    try{
+        result = (*f2)(arg);
+    }catch(...){
+      popCurrentNS();
+      throw;
+    }
+    popCurrentNS();
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpClosure::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<Closure: ";
+    *str += ns.toString();
+    *str += ">";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * Closure: arg length  1
+ */
+
+SpValue& SpClosureP2::operator()(SpValue& arg2)
+{
+    //    static SpValue result;
+    SpValue result;
+
+    pushCurrentNS(ns);
+    try{
+        SpPrim2* f = dynamic_cast<SpPrim2*>(func.getObject());
+        result = (*f)(arg, arg2);
+    }catch(...){
+      popCurrentNS();
+      throw;
+    }
+    popCurrentNS();
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpClosureP2::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<Closure: arg length 1>";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+
+// SpClosureP3
+SpValue& SpClosureP3_1::operator()(SpValue& arg2)
+{
+    //    static SpValue result;
+    SpValue result;
+
+    pushCurrentNS(ns);
+    try{
+        SpPrim3* f = dynamic_cast<SpPrim3*>(func.getObject());
+        result = (*f)(arg, arg2);
+    }catch(...){
+      popCurrentNS();
+      throw;
+    }
+    popCurrentNS();
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpClosureP3_1::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<Closure: arg length 1>";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+SpValue& SpClosureP3_2::operator()(SpValue& arg3)
+{
+    //    static SpValue result;
+    SpValue result;
+
+    pushCurrentNS(ns);
+    try{
+        SpPrim3* f = dynamic_cast<SpPrim3*>(func.getObject());
+        result = (*f)(arg1, arg2, arg3);
+    }catch(...){
+      popCurrentNS();
+      throw;
+    }
+    popCurrentNS();
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpClosureP3_2::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<Closure: arg length 1>";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * Closure: arg length N
+ */
+
+SpClosureN::SpClosureN(SpValue& f, SpValue& a, SpValue& aNS)
+    : func(f), ns(aNS)
+{
+    SpFunc* f2 = dynamic_cast<SpFunc*>(func.getObject());
+    if(a.isTuple()){
+        SpTuple* t = dynamic_cast<SpTuple*>(a.getObject());
+        argLen = f2->argLen - t->length();
+        args = a;
+    }else{
+        argLen = f2->argLen - 1;
+        args.setNewObject(new SpTuple(a));
+    }
+}
+
+SpValue& SpClosureN::operator()(SpValue& arg2)
+{
+    //    static SpValue result;
+    SpValue result;
+
+    SpTuple* t = dynamic_cast<SpTuple*>(args.getObject());
+    SpTuple* tuple = new SpTuple(t->vec);
+    SpValue a(tuple);
+    SpFunc* f = dynamic_cast<SpFunc*>(func.getObject());
+
+    if(arg2.isTuple()){
+        SpTuple* t2 = dynamic_cast<SpTuple*>(arg2.getObject());        
+        SpValueVector::iterator it;
+        it = t2->begin();
+        for(; it != t2->end(); it++){
+            tuple->append(*it);
+        }
+    }else{
+        tuple->append(arg2);
+    }
+
+    if((SpInt)f->argLen > tuple->length()){
+        result.setNewObject(new SpClosureN(func, a, ns));
+    }else if((SpInt)f->argLen == tuple->length()){
+        pushCurrentNS(ns);
+        try{
+            result = (*f)(a);
+        }catch(...){
+          popCurrentNS();
+          throw;
+        }
+        popCurrentNS();
+    }else{
+        throw SpException("too many args");
+    }
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpClosureN::toString()
+{
+    SpString* str;
+    SpValue i((int)argLen);
+
+    str = new SpString();
+    *str = "#<ClosureN: arg length ";
+    *str += i;
+    *str += ">";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
diff --git a/src/DBBase.cpp b/src/DBBase.cpp
new file mode 100644 (file)
index 0000000..1c2248e
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: DBBase.cpp,v 1.1 2003/09/09 11:13:41 randy Exp $
+ */
+
+#ifdef USE_DATABASE
+
+#ifdef __WIN32__
+#include <io.h>
+#else
+#include <unistd.h>
+#include <stdio.h>
+#endif
+
+#include "soopy.h"
+
+
+DBRoot* findRoot(SpValue& name)
+{
+}
+
+DBRoot* createRoot(SpValue& name)
+{
+}
+
+void setObject(DBRoot* root, SpValue& obj)
+{
+}
+
+
+
+
+
+void DB::open()
+{
+    if(access(filename, 0) == 0){
+        file = fopen(filename, "r+b");
+    }else{
+        file = fopen(filename, "w+b");
+    }
+    if(file == NULL){
+        throw SpException("can't open database");
+    }
+    closed = false;
+}
+
+void DB::close()
+{
+    if((file != NULL) && (!closed)){
+        //save();
+        fclose(file);
+        closed = true;
+    }
+}
+
+void DB::setRoot(SpValue& name, SpValue& obj)
+{
+    if(closed){
+        throw SpException("database closed");
+    }
+
+    DBRoot* root = findRoot(name);
+    if(root == NULL){
+        root = createRoot(name);
+    }
+    setObject(root, obj);
+}
+
+SpValue& DB::getRoot(SpValue& name)
+{
+    if(closed){
+        throw SpException("database closed");
+    }
+
+    throw SpNoMethodException("not imple", "no", "no");
+}
+
+
+#endif /* USE_DATABASE */
diff --git a/src/Database.cpp b/src/Database.cpp
new file mode 100644 (file)
index 0000000..33a95a0
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Database.cpp,v 1.2 2004/03/21 05:48:06 randy Exp $
+ */
+
+#ifdef USE_DATABASE
+
+#include "soopy.h"
+
+SpDatabase::SpDatabase(char* name)
+{
+    database = new DB(name);
+}
+
+SpDatabase::~SpDatabase()
+{
+    // \96¾\8e¦\93I\82É\83N\83\8d\81[\83Y\82µ\82È\82­\82Ä\82à\81Asoopy\8fI\97¹\8e\9e\82É
+    // \8aJ\82¢\82Ä\82¢\82é\83f\81[\83^\83x\81[\83X\82Í\82·\82×\82Ä\83N\83\8d\81[\83Y\82·\82é\81B
+    database->close();
+}
+
+void SpDatabase::open()
+{
+    database->open();
+}
+
+void SpDatabase::close()
+{
+    database->close();
+}
+
+void SpDatabase::setRoot(SpValue& name, SpValue& obj)
+{
+    database->setRoot(name, obj);
+}
+
+SpValue& SpDatabase::getRoot(SpValue& name)
+{
+    return database->getRoot(name);
+}
+
+// Message Handler
+SpValue& SpDatabase::onMessage(SpValue& rec, SpValue& msg)
+{
+    try{
+        return getRoot(msg);
+    }catch(SpException& e){
+        try{
+            return DatabaseMsgHandler(rec, msg);
+        }catch(SpNoMethodException& e){
+            return NilObject;
+        }
+    }
+}
+
+SpValue& SpDatabase::toString()
+{
+    SpString* str = new SpString("<database>");
+    //    static SpValue val;
+    //    val.setNewObject(str);
+    //    return val;
+    return SpObjectResult(str);
+}
+
+SpValue& SpDatabase::prim_open(SpValue& filename)
+{
+    if(!filename.isString()){
+        throw SpException("not string. (database open)");
+    }
+    SpString* name = filename.asString();
+    SpDatabase* db = new SpDatabase((char*)name->toCStringWithEncoder());
+    db->open();
+
+    //    static SpValue result;
+    //    result.setNewObject(db);
+    //    return result;
+    return SpObjectResult(db);
+}
+
+SpValue& SpDatabase::prim_close(SpValue& self)
+{
+    SpDatabase* db = self.asDatabase();
+    db->close();
+    return TrueObject;
+}
+
+
+// init
+void SpDatabase::init()
+{
+    SpNameSpace* pDBNS = new SpNameSpace;
+    SpValue DBNS(pDBNS);
+    PMainNameSpace->internConst(SymDatabase, DBNS);
+
+    // for Class
+    SpValue PrimOpen(new SpPrim1(prim_open));
+    pDBNS->internFunc(SymOpen, PrimOpen);
+
+    // for Object
+    SpValue PrimClose(new SpPrim1(prim_close));
+    DatabaseMsgHandler.append(SymClose, PrimClose);
+/*
+    SpValue PrimSave(new SpPrim1(prim_save));
+    SpValue SymSave(new SpSymbol("save"));
+    DatabaseMsgHandler.append(SymSave, PrimSave);
+
+    SpValue PrimSetRoot(new SpPrim3(prim_setRoot));
+    SpValue SymSetRoot(new SpSymbol("setroot"));
+    DatabaseMsgHandler.append(SymSetRoot, PrimSetRoot);
+
+    SpValue PrimGetRoot(new SpPrim2(prim_getRoot));
+    SpValue SymGetRoot(new SpSymbol("getroot"));
+    DatabaseMsgHandler.append(SymGetRoot, PrimGetRoot);
+*/
+
+
+/*
+    SpValue PrimRename(new SpPrim2(rename));
+    DatabaseMsgHandler.append(SymRename, PrimRename);
+
+    SpValue SymEval(new SpSymbol("eval"));
+    SpValue PrimEval(new SpPrim1(make_func));
+    DatabaseMsgHandler.append(SymEval, PrimEval);
+
+    PrimAppend.setNewObject(new SpPrim3(prim_append));
+    DatabaseMsgHandler.append(SymAppend, PrimAppend);
+
+    SpValue PrimKeys(new SpPrim1(prim_keys));
+    DatabaseMsgHandler.append(SymKeys, PrimKeys);
+
+    SpValue PrimDelete(new SpPrim2(prim_delete));
+    DatabaseMsgHandler.append(SymDelete, PrimDelete);
+
+    SpValue SymLookup(new SpSymbol("lookup"));
+    SpValue PrimLookup(new SpPrim2(prim_lookup));
+    DatabaseMsgHandler.append(SymLookup, PrimLookup);
+*/
+}
+
+
+#endif /* USE_DATABASE */
diff --git a/src/Datatype.cpp b/src/Datatype.cpp
new file mode 100644 (file)
index 0000000..2c64c31
--- /dev/null
@@ -0,0 +1,318 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Datatype.cpp,v 1.10 2004/03/25 13:29:57 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * SpDataType
+ */
+
+void SpDataType::mapping2ns(SpValue& self, SpNameSpace* ns)
+{
+    // set datatype
+/*
+    SpValue v(new NSConst(symbol));
+    ns->intern(v, self);
+*/
+    ns->internConst(symbol, self);
+    // set constructors
+    SpValueVector::iterator it;
+    it = vec.begin();
+    for(; it != vec.end(); it++){
+        SpConstructor* con = it->asConstructor();
+/*
+        v.setNewObject(new NSConst(con->symbol));
+        ns->intern(v, *it);
+*/
+        ns->internConst(con->symbol, *it);
+    }
+}
+
+SpValue& SpDataType::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += "datatype ";
+    *str += symbol;
+    *str += " = ";
+    SpValueVector::iterator it;
+    it = vec.begin();
+    *str += *it;
+    it++;
+    for(; it != vec.end(); it++){
+        *str += " | ";
+        *str += *it;
+    }
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * SpConstructor
+ */
+
+SpValue& SpConstructor::eval()
+{
+    //    static SpValue result;
+    SpValue result;
+    if(argLen == 0){
+        result.setNewObject(new SpDType(this, symbol, ns));
+    }else{
+        result.setObject(this);
+    }
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpConstructor::operator()(SpValue& arg)
+{
+    //    static SpValue result;
+    SpValue result, temp, temp2;
+    SpNameSpace* assoc = new SpNameSpace(ns);
+    SpValue v_ns(assoc);
+    SpValue v_f(this);
+
+    if(argLen == 0){
+        if(!arg.isNil()){
+            throw SpException("too much args");
+        }
+        result.setNewObject(new SpDType(this, symbol, ns));
+       //        return result;
+       return SpValueResult(result);
+    }else if(argLen == 1){
+        SpTuple* ptr = args.asTuple();
+        //SpArg* p = ((*ptr)[0]).asArg();
+        temp = ((*ptr)[0]);
+        SpArg* p = temp.asArg();
+        temp = arg.eval();
+        CheckType(p->typ, temp);
+        //assoc->internVar(p->getVarName(), temp);
+       temp2 = p->getVarName();
+        assoc->internVar(temp2, temp);
+    }else{
+        if(!arg.isTuple()){
+            result.setNewObject(new SpClosureN(v_f, arg, v_ns));
+           //            return result;
+           return SpValueResult(result);
+        }else{
+            SpTuple* t = arg.asTuple();
+            if((SpInt)argLen != t->length()){
+                throw SpException("arg length mismatch");
+            }
+            // set args
+            SpTuple* ptr = args.asTuple();
+            SpValueVector::iterator it, it2;
+            it = ptr->begin();
+            it2 = t->begin();
+            for(; it != ptr->end(); it++, it2++){
+                SpArg* p = it->asArg();
+                temp = it2->eval();
+                CheckType(p->typ, temp);
+//                assoc->internVar(p->getVarName(), it2->eval());
+               temp2 = p->getVarName();
+                assoc->internVar(temp2, temp);
+            }
+        }
+
+    }
+//cout << "dtype ns: " << ns << endl;
+//cout << "dtype v_ns: " << v_ns << endl;
+    //    result.setNewObject(new SpDType(this, symbol, v_ns));
+    //    return result;
+    return SpObjectResult(new SpDType(this, symbol, v_ns));
+}
+
+SpValue& SpConstructor::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += "con ";
+    *str += symbol;
+    if(!args.isNil()){
+        *str += "(";
+        SpTuple* t = args.asTuple();
+        SpValueVector::iterator it;
+        it = t->begin();
+        *str += *it;
+        it++;
+        for(; it != t->end(); it++){
+            *str += ",";
+            *str += *it;
+        }
+        *str += ")";
+    }
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * SpDType
+ */
+
+SpValue& SpDType::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += symbol;
+    //if(!ns.isNil()){
+    if(!con->args.isNil()){
+        *str += "(";
+        SpNameSpace* assoc = ns.asNameSpace();
+        SpTuple* t = con->args.asTuple();
+        SpValueVector::iterator it = t->begin();
+        SpArg* arg = it->asArg();
+        //SpValue v = assoc->lookup(arg->getVarName());
+        SpValue v = arg->getVarName();
+        v = assoc->lookup(v);
+        *str += v.toString();
+        it++;
+        for(; it != t->end(); it++){
+            *str += ",";
+            arg = it->asArg();
+            //v = assoc->lookup(arg->getVarName());
+            v = arg->getVarName();
+            v = assoc->lookup(v);
+            *str += v.toString();
+        }
+        *str += ")";
+    }
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+SpValue& SpDType::onMessage(SpValue&, SpValue& msg)
+{
+    if(ns.isNil()){
+        throw SpException("no such a feature (datatype)");
+    }
+    SpNameSpace* assoc = ns.asNameSpace();
+//    try{
+    return assoc->lookup(msg);
+//    }catch(SpException& e){
+//        return DTypeMsgHandler(rec, msg);
+//    }
+}
+
+SpValue& SpDType::eq(SpValue&, SpValue& e2)
+{
+    if(e2.isDType()){
+        SpDType* ptr = e2.asDType();
+        if(con != ptr->con){
+            return FalseObject;
+        }
+        if(symbol != ptr->symbol){
+            return FalseObject;
+        }
+        if(ns == ptr->ns){
+            return TrueObject;
+        }
+//        return ns.eq(ptr->ns);
+    }
+    return FalseObject;
+}
+
+/*
+bool SpDType::match(SpValue& self, SpValue& val, SpNameSpace* ns)
+{
+}
+*/
+
+/*
+ * class SpPatternCon
+ */
+
+SpValue& SpPatternCon::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += symbol;
+    *str += "(";
+    SpTuple* t = tuple.asTuple();
+    SpValueVector::iterator it;
+    it = t->begin();
+    *str += *it;
+    it++;
+    for(; it != t->end(); it++){
+        *str += ",";
+        *str += *it;
+    }
+    *str += ")";
+    //    static SpValue v;
+    //    v.setNewObject(str);
+    //    return v;
+    return SpObjectResult(str);
+}
+
+bool SpPatternCon::match(SpValue&, SpValue& val, SpNameSpace* ns)
+{
+    if(!val.isDType()){
+        return false;
+    }
+    SpDType* dt = val.asDType();
+    if(symbol != dt->symbol){
+        return false;
+    }
+    if(tuple.isNil()){
+        if(dt->ns.isNil()){
+            return true;
+        }else{
+            return false;
+        }
+    }
+    if(dt->ns.isNil()){
+        return false;
+    }
+
+    SpTuple* t = tuple.asTuple();
+    SpNameSpace* assoc = dt->ns.asNameSpace();
+    if(t->length() != assoc->size()){
+        return false;
+    }
+
+    if(dt->con->args.isNil()){
+        return true;
+    }
+    SpTuple* t2 = dt->con->args.asTuple();
+    SpValueVector::iterator it, it2;
+    it = t->begin();
+    it2 = t2->begin();
+    for(; it != t->end(); it++, it2++){
+        NSMap::iterator found;
+        SpArg* a = it2->asArg();
+        //NSVar* var = new NSVar(a->getVarName());
+        SpValue temp = a->getVarName();
+        NSVar* var = new NSVar(temp);
+        SpValue key(var);
+        found = assoc->aMap.find(key);
+        if(found == assoc->aMap.end()){
+            return false;
+        }
+        if(!it->match(found->second,ns)){
+            return false;
+        }
+    }
+
+    return true;
+}
+
+
diff --git a/src/Date.cpp b/src/Date.cpp
new file mode 100644 (file)
index 0000000..7fb83c4
--- /dev/null
@@ -0,0 +1,508 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Date.cpp,v 1.16 2004/07/04 12:32:36 randy Exp $
+ */
+
+#include <time.h>
+#include "soopy.h"
+
+static bool isLeapYear(SpInt year) // \89[\94N\82È\82ç\82Î\90^
+{
+    if((year % 100) == 0){
+        if((year % 400) == 0){
+            return true;
+        }
+    }else if((year % 4) == 0){
+        return true;
+    }
+    return false;
+}
+
+void SpDate::regular()
+{
+    // month
+    if(month <= 0){
+        while(month <= 0){
+            month += 12;
+            year--;
+        }
+    }else if(month > 12){
+        while(month > 12){
+            month -= 12;
+            year++;
+        }
+    }
+
+    // day
+    if(day <= 0){
+        while(day <= 0){
+            month--;
+            if(month == 0){
+                month = 12;
+                year--;
+            }
+            switch(month){
+              case 1:
+              case 3:
+              case 5:
+              case 7:
+              case 8:
+              case 10:
+              case 12:
+                day = day + 31;
+                break;
+              case 4:
+              case 6:
+              case 9:
+              case 11:
+                day = day + 30;
+                break;
+              case 2:
+                if(isLeapYear(year)){
+                    day = day + 29;
+                }else{
+                    day = day + 28;
+                }
+                break;
+              default:
+                goto day_end;
+            }
+        }
+    }else{
+        while(true){
+            switch(month){
+              case 1:
+              case 3:
+              case 5:
+              case 7:
+              case 8:
+              case 10:
+              case 12:
+                if(day > 31){
+                    day = day - 31;
+                    month++;
+                    if(month == 13){
+                        month = 1;
+                    }
+                }else{
+                    goto day_end;
+                }
+                break;
+              case 4:
+              case 6:
+              case 9:
+              case 11:
+                if(day > 30){
+                    day = day - 30;
+                    month++;
+                    if(month == 13){
+                        month = 1;
+                    }
+                }else{
+                    goto day_end;
+                }
+                break;
+              case 2:
+                if(isLeapYear(year)){
+                    if(day > 29){
+                        day = day - 29;
+                        month++;
+                        if(month == 13){
+                            month = 1;
+                        }
+                    }else{
+                        goto day_end;
+                    }
+                }else{
+                    if(day > 28){
+                        day = day - 28;
+                        month++;
+                        if(month == 13){
+                            month = 1;
+                        }
+                    }else{
+                        goto day_end;
+                    }
+                }
+                break;
+              default:
+                goto day_end;
+            }
+        }
+    }
+day_end:
+    return;
+}
+
+SpValue& SpDate::plus(SpValue& e1, SpValue& e2)
+{
+    SpDate* d1 = e1.asDate();
+    SpDate* date;
+    if(e2.isInt()){
+        SpInt i = e2.getInt();
+        date = new SpDate(d1->year,
+                          d1->month,
+                          d1->day + i);
+/*
+    }else if(e2.isDate()){
+        SpDate* d2 = e2.asDate();
+        date = new SpDate(d1->year  + d2->year,
+                          d1->month + d2->month,
+                          d1->day   + d2->day);
+*/
+    }else{
+        throw SpException("not int date::operator+");
+    }
+    date->regular();
+    return SpObjectResult(date);
+}
+
+SpValue& SpDate::minus(SpValue& e1, SpValue& e2)
+{
+    SpDate* d1 = e1.asDate();
+    SpDate* date;
+    if(e2.isInt()){
+        SpInt i = e2.getInt();
+        date = new SpDate(d1->year,
+                          d1->month,
+                          d1->day - i);
+/*
+    }else if(e2.isDate()){
+        SpDate* d2 = e2.asDate();
+        SpDate* date = new SpDate(d1->year  - d2->year,
+                                  d1->month - d2->month,
+                                  d1->day   - d2->day);
+*/
+    }else{
+        throw SpException("not int date::operator-");
+    }
+    date->regular();
+    return SpObjectResult(date);
+}
+
+SpValue& SpDate::eq(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDate()){
+        return SpBoolResult(false);
+    }
+    SpDate* t1 = e1.asDate();
+    SpDate* t2 = e2.asDate();
+    return SpBoolResult((t1->year == t2->year) && (t1->month == t2->month) && (t1->day == t2->day));
+}
+
+SpValue& SpDate::ne(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDate()){
+        return SpBoolResult(true);
+    }
+    SpDate* t1 = e1.asDate();
+    SpDate* t2 = e2.asDate();
+    return SpBoolResult((t1->year != t2->year) || (t1->month != t2->month) || (t1->day != t2->day));
+}
+
+SpValue& SpDate::gt(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDate()){
+        throw SpException("unmatch type (Date >)");
+    }
+    SpDate* t1 = e1.asDate();
+    SpDate* t2 = e2.asDate();
+    if(t1->year > t2->year){
+        return SpBoolResult(true);
+    }else if(t1->year == t2->year){
+        if(t1->month > t2->month){
+            return SpBoolResult(true);
+        }else if(t1->month == t2->month){
+            return SpBoolResult(t1->day > t2->day);
+        }
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpDate::ge(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDate()){
+        throw SpException("unmatch type (>=)");
+    }
+    SpDate* t1 = e1.asDate();
+    SpDate* t2 = e2.asDate();
+    if(t1->year > t2->year){
+        return SpBoolResult(true);
+    }else if(t1->year == t2->year){
+        if(t1->month > t2->month){
+            return SpBoolResult(true);
+        }else if(t1->month == t2->month){
+            return SpBoolResult(t1->day >= t2->day);
+        }
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpDate::lt(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDate()){
+        throw SpException("unmatch type (<)");
+    }
+    SpDate* t1 = e1.asDate();
+    SpDate* t2 = e2.asDate();
+    if(t1->year < t2->year){
+        return SpBoolResult(true);
+    }else if(t1->year == t2->year){
+        if(t1->month < t2->month){
+            return SpBoolResult(true);
+        }else if(t1->month == t2->month){
+            return SpBoolResult(t1->day < t2->day);
+        }
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpDate::le(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDate()){
+        throw SpException("unmatch type (<=)");
+    }
+    SpDate* t1 = e1.asDate();
+    SpDate* t2 = e2.asDate();
+    if(t1->year < t2->year){
+        return SpBoolResult(true);
+    }else if(t1->year == t2->year){
+        if(t1->month < t2->month){
+            return SpBoolResult(true);
+        }else if(t1->month == t2->month){
+            return SpBoolResult(t1->day <= t2->day);
+        }
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpDate::toString()
+{
+    char buf[10];
+    SpString* str = new SpString;
+    sprintf(buf, "%d", year);
+    *str += buf;
+    sprintf(buf, "-%d", month);
+    *str += buf;
+    sprintf(buf, "-%d", day);
+    *str += buf;
+    //    static SpValue val;
+    //    val.setNewObject(str);
+    //    return val;
+    return SpObjectResult(str);
+}
+
+void SpDate::assign(SpValue& feature, SpValue& value)
+{
+    SpValue v;
+
+    if(feature == SymYear){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign date)");
+        }
+        year = v.getInt();
+    }else if(feature == SymMonth){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign date)");
+        }
+        month = v.getInt();
+    }else if(feature == SymDay){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign date)");
+        }
+        day = v.getInt();
+    }else{
+        throw SpException("no such a feature(assign date)");
+    }
+}
+
+// primitives
+SpValue& SpDate::prim_today()
+{
+    SpInt y, m, d;
+    time_t t;
+    struct tm* area;
+
+    t = time(NULL);
+    area = localtime(&t);
+    y = area->tm_year + 1900;
+    m = area->tm_mon+1;
+    d = area->tm_mday;
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpDate(y, m, d));
+    //    return result;
+    return SpObjectResult(new SpDate(y, m, d));
+}
+
+SpValue& SpDate::prim_new(SpValue& v1, SpValue& v2, SpValue& v3)
+{
+    SpInt y, m, d;
+
+    if(!v1.isInt()){
+        throw SpException("not int (Date.new)");
+    }
+    if(!v2.isInt()){
+        throw SpException("not int (Date.new)");
+    }
+    if(!v3.isInt()){
+        throw SpException("not int (Date.new)");
+    }
+    y = v1.getInt();
+    m = v2.getInt();
+    d = v3.getInt();
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpDate(y, m, d));
+    //    return result;
+    return SpObjectResult(new SpDate(y, m, d));
+}
+
+SpValue& SpDate::prim_fromString(SpValue& date_str)
+{
+    SpInt y, m, d;
+    SpValue temp;
+    SpString* str = date_str.asString();
+
+    SpValue v = str->split(MakeSpChar(CodeJIS, '-'));
+    SpCons* list = (SpCons*)v.asList();
+    if(list->length() != 3){
+        throw SpException("illegal date format");
+    }
+
+    //y = int_fromString(list->value().asString());
+    temp = list->value();
+    y = int_fromString(temp.asString());
+    temp = list->nextList();
+    list = (SpCons*)temp.asList();
+    //m = int_fromString(list->value().asString());
+    temp = list->value();
+    m = int_fromString(temp.asString());
+    temp = list->nextList();
+    list = (SpCons*)temp.asList();
+    //d = int_fromString(list->value().asString());
+    temp = list->value();
+    d = int_fromString(temp.asString());
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpDate(y, m, d));
+    //    return result;
+    return SpObjectResult(new SpDate(y, m, d));
+}
+
+SpValue& SpDate::prim_succ(SpValue& self)
+{
+    SpInt y, m, d;
+    SpDate* date = self.asDate();
+
+    y = date->year;
+    m = date->month;
+    d = date->day;
+    SpDate* date2 = new SpDate(y, m, d+1);
+    date2->regular();
+
+    //    static SpValue result;
+    //    result.setNewObject(date2);
+    //    return result;
+    return SpObjectResult(date2);
+}
+
+SpValue& SpDate::prim_pred(SpValue& self)
+{
+    SpInt y, m, d;
+    SpDate* date = self.asDate();
+
+    y = date->year;
+    m = date->month;
+    d = date->day;
+    SpDate* date2 = new SpDate(y, m, d-1);
+    date2->regular();
+
+    //    static SpValue result;
+    //    result.setNewObject(date2);
+    //    return result;
+    return SpObjectResult(date2);
+}
+
+SpValue& SpDate::prim_getYear(SpValue& self)
+{
+    SpDate* p = self.asDate();
+    //    static SpValue result;
+    //    result.setInt(p->year);
+    //    return result;
+    return SpIntResult(p->year);
+}
+
+SpValue& SpDate::prim_getMonth(SpValue& self)
+{
+    SpDate* p = self.asDate();
+    //    static SpValue result;
+    //    result.setInt(p->month);
+    //    return result;
+    return SpIntResult(p->month);
+}
+
+SpValue& SpDate::prim_getDay(SpValue& self)
+{
+    SpDate* p = self.asDate();
+    //    static SpValue result;
+    //    result.setInt(p->day);
+    //    return result;
+    return SpIntResult(p->day);
+}
+
+// Message Handler
+SpValue& SpDate::onMessage(SpValue& rec, SpValue& msg)
+{
+    return DateMsgHandler(rec, msg);
+}
+
+// init
+void SpDate::init()
+{
+    SpNameSpace* pDateNS = new SpNameSpace;
+    SpValue DateNS(pDateNS);
+    PMainNameSpace->internConst(SymDate, DateNS);
+
+    // for Class
+    SpValue SymToday(new SpSymbol("today"));
+    SpValue PrimToday(new SpPrim0(prim_today));
+    pDateNS->internPrimProperty(SymToday, NilObject, PrimToday, NilObject);
+
+    SpValue SymNew(new SpSymbol("new"));
+    SpValue PrimNew(new SpPrim3(prim_new));
+    pDateNS->internConst(SymNew, PrimNew);
+
+    SpValue SymFromString(new SpSymbol("fromstring"));
+    SpValue PrimFromString(new SpPrim1(prim_fromString));
+    pDateNS->internConst(SymFromString, PrimFromString);
+
+    // for Object
+    SpValue GetYear(new SpPrim1(prim_getYear));
+    DateMsgHandler.append(SymYear, GetYear);
+
+    SpValue GetMonth(new SpPrim1(prim_getMonth));
+    DateMsgHandler.append(SymMonth, GetMonth);
+
+    SpValue GetDay(new SpPrim1(prim_getDay));
+    DateMsgHandler.append(SymDay, GetDay);
+
+    SpValue PrimSucc(new SpPrim1(prim_succ));
+    DateMsgHandler.append(SymSucc, PrimSucc);
+
+    SpValue PrimPred(new SpPrim1(prim_pred));
+    DateMsgHandler.append(SymPred, PrimPred);
+}
+
+
diff --git a/src/DateTime.cpp b/src/DateTime.cpp
new file mode 100644 (file)
index 0000000..427b7e2
--- /dev/null
@@ -0,0 +1,447 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: DateTime.cpp,v 1.9 2004/07/04 12:32:36 randy Exp $
+ */
+
+#include <time.h>
+#include "soopy.h"
+
+void SpDateTime::regular()
+{
+    // time
+    SpInt i = 0;
+    SpTime* t = time.asTime();
+    t->regular();
+    if(t->hour < 0){
+        while(t->hour < 0){
+            t->hour += 24;
+            i--;
+        }
+    }else if(t->hour > 24){
+        while(t->hour > 24){
+            t->hour -= 24;
+            i++;
+        }
+    }
+    // date
+    SpDate* d = date.asDate();
+    d->day += i;
+    d->regular();
+}
+
+SpValue& SpDateTime::plus(SpValue& e1, SpValue& e2)
+{
+    SpDateTime* dt = e1.asDateTime();
+    SpDateTime* date;
+    if(e2.isInt()){
+        SpDate* d1 = dt->date.asDate();
+        SpTime* t1 = dt->time.asTime();
+        SpInt i = e2.getInt();
+        date = new SpDateTime(d1->year,
+                              d1->month,
+                              d1->day,
+                              t1->hour,
+                              t1->minute,
+                              t1->second + i);
+/*
+    }else if(e2.isDateTime()){
+        SpDateTime* dt2 = e2.asDateTime();
+        SpDate* d1 = dt->date.asDate();
+        SpTime* t1 = dt->time.asTime();
+        SpDate* d2 = dt2->date.asDate();
+        SpTime* t2 = dt2->time.asTime();
+        date = new SpDateTime(d1->year   + d2->year,
+                              d1->month  + d2->month,
+                              d1->day    + d2->day,
+                              t1->hour   + t2->hour,
+                              t1->minute + t2->minute,
+                              t1->second + t2->second);
+*/
+    }else{
+        throw SpException("not int datetime::operator+");
+    }
+    date->regular();
+    //    static SpValue result;
+    //    result.setNewObject(date);
+    //    return result;
+    return SpObjectResult(date);
+}
+
+SpValue& SpDateTime::minus(SpValue& e1, SpValue& e2)
+{
+    SpDateTime* dt = e1.asDateTime();
+    SpDateTime* date;
+    if(e2.isInt()){
+        SpDate* d1 = dt->date.asDate();
+        SpTime* t1 = dt->time.asTime();
+        SpInt i = e2.getInt();
+        date = new SpDateTime(d1->year,
+                              d1->month,
+                              d1->day,
+                              t1->hour,
+                              t1->minute,
+                              t1->second - i);
+/*
+    }else if(e2.isDateTime()){
+        SpDateTime* dt2 = e2.asDateTime();
+        SpDate* d1 = dt->date.asDate();
+        SpTime* t1 = dt->time.asTime();
+        SpDate* d2 = dt2->date.asDate();
+        SpTime* t2 = dt2->time.asTime();
+        date = new SpDateTime(d1->year   - d2->year,
+                              d1->month  - d2->month,
+                              d1->day    - d2->day,
+                              t1->hour   - t2->hour,
+                              t1->minute - t2->minute,
+                              t1->second - t2->second);
+*/
+    }else{
+        throw SpException("not int datetime::operator-");
+    }
+    date->regular();
+    return SpObjectResult(date);
+}
+
+SpValue& SpDateTime::eq(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDateTime()){
+        return SpBoolResult(false);
+    }
+    SpDateTime* t1 = e1.asDateTime();
+    SpDateTime* t2 = e2.asDateTime();
+    return boolAnd(t1->date.eq(t2->date), t1->time.eq(t2->time));
+}
+
+SpValue& SpDateTime::ne(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDateTime()){
+        return SpBoolResult(true);
+    }
+    SpDateTime* t1 = e1.asDateTime();
+    SpDateTime* t2 = e2.asDateTime();
+    return boolOr(t1->date.ne(t2->date), t1->time.ne(t2->time));
+}
+
+SpValue& SpDateTime::gt(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDateTime()){
+        throw SpException("unmatch type (DateTime >)");
+    }
+    SpDateTime* t1 = e1.asDateTime();
+    SpDateTime* t2 = e2.asDateTime();
+    if(t1->date.gt(t2->date).isTrue()){
+        return SpBoolResult(true);
+    }else if(t1->date.eq(t2->date).isTrue()){
+        return t1->time.gt(t2->time);
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpDateTime::ge(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDateTime()){
+        throw SpException("unmatch type (>=)");
+    }
+    SpDateTime* t1 = e1.asDateTime();
+    SpDateTime* t2 = e2.asDateTime();
+    if(t1->date.gt(t2->date).isTrue()){
+        return SpBoolResult(true);
+    }else if(t1->date.eq(t2->date).isTrue()){
+        return t1->time.ge(t2->time);
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpDateTime::lt(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDateTime()){
+        throw SpException("unmatch type (<)");
+    }
+    SpDateTime* t1 = e1.asDateTime();
+    SpDateTime* t2 = e2.asDateTime();
+    if(t1->date.lt(t2->date).isTrue()){
+        return SpBoolResult(true);
+    }else if(t1->date.eq(t2->date).isTrue()){
+        return t1->time.lt(t2->time);
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpDateTime::le(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isDateTime()){
+        throw SpException("unmatch type (<=)");
+    }
+    SpDateTime* t1 = e1.asDateTime();
+    SpDateTime* t2 = e2.asDateTime();
+    if(t1->date.lt(t2->date).isTrue()){
+        return SpBoolResult(true);
+    }else if(t1->date.eq(t2->date).isTrue()){
+        return t1->time.le(t2->time);
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpDateTime::toString()
+{
+    char buf[10];
+    SpDate* d1 = date.asDate();
+    SpTime* t1 = time.asTime();
+    SpString* str = new SpString;
+    sprintf(buf, "%d", d1->year);
+    *str += buf;
+    sprintf(buf, "-%02d", d1->month);
+    *str += buf;
+    sprintf(buf, "-%02d ", d1->day);
+    *str += buf;
+    sprintf(buf, "%02d", t1->hour);
+    *str += buf;
+    sprintf(buf, ":%02d", t1->minute);
+    *str += buf;
+    sprintf(buf, ":%02d", t1->second);
+    *str += buf;
+    //    static SpValue val;
+    //    val.setNewObject(str);
+    //    return val;
+    return SpObjectResult(str);
+}
+
+void SpDateTime::assign(SpValue& feature, SpValue& value)
+{
+    SpValue v;
+
+    if(feature == SymYear){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign datetime)");
+        }
+        SpDate* d1 = date.asDate();
+        d1->year = v.getInt();
+    }else if(feature == SymMonth){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign datetime)");
+        }
+        SpDate* d1 = date.asDate();
+        d1->month = v.getInt();
+    }else if(feature == SymDay){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign datetime)");
+        }
+        SpDate* d1 = date.asDate();
+        d1->day = v.getInt();
+    }else if(feature == SymHour){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign time)");
+        }
+        SpTime* t1 = time.asTime();
+        t1->hour = v.getInt();
+    }else if(feature == SymMinute){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign time)");
+        }
+        SpTime* t1 = time.asTime();
+        t1->minute = v.getInt();
+    }else if(feature == SymSecond){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign time)");
+        }
+        SpTime* t1 = time.asTime();
+        t1->second = v.getInt();
+    }else{
+        throw SpException("no such a feature(assign datetime)");
+    }
+}
+
+// primitives
+
+SpValue& SpDateTime::prim_now()
+{
+    SpInt y, m, d, h, min, s;
+    time_t t;
+    struct tm* area;
+
+    t = ::time(NULL);
+    area = localtime(&t);
+    y = area->tm_year + 1900;
+    m = area->tm_mon+1;
+    d = area->tm_mday;
+    h = area->tm_hour;
+    min = area->tm_min;
+    s = area->tm_sec;
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpDateTime(y, m, d, h, min, s));
+    //    return result;
+    return SpObjectResult(new SpDateTime(y, m, d, h, min, s));
+}
+
+SpValue& SpDateTime::prim_new(SpValue& date, SpValue& time)
+{
+    if(!date.isDate()){
+        throw SpException("not date datetime::new");
+    }
+    if(!time.isTime()){
+        throw SpException("not time datetime::new");
+    }
+    SpDate* d = date.asDate();
+    SpTime* t = time.asTime();
+    /*
+    static SpValue result;
+    result.setNewObject(new SpDateTime(d->year,
+                                       d->month,
+                                       d->day,
+                                       t->hour,
+                                       t->minute,
+                                       t->second));
+    return result;
+    */
+    return SpObjectResult(new SpDateTime(d->year,
+                                        d->month,
+                                        d->day,
+                                        t->hour,
+                                        t->minute,
+                                        t->second));
+}
+
+SpValue& SpDateTime::prim_getYear(SpValue& self)
+{
+    SpDateTime* dt = self.asDateTime();
+    SpDate* p = dt->date.asDate();
+    //    static SpValue result;
+    //    result.setInt(p->year);
+    //    return result;
+    return SpIntResult(p->year);
+}
+
+SpValue& SpDateTime::prim_getMonth(SpValue& self)
+{
+    SpDateTime* dt = self.asDateTime();
+    SpDate* p = dt->date.asDate();
+    //    static SpValue result;
+    //    result.setInt(p->month);
+    //    return result;
+    return SpIntResult(p->month);
+}
+
+SpValue& SpDateTime::prim_getDay(SpValue& self)
+{
+    SpDateTime* dt = self.asDateTime();
+    SpDate* p = dt->date.asDate();
+    //    static SpValue result;
+    //    result.setInt(p->day);
+    //    return result;
+    return SpIntResult(p->day);
+}
+
+SpValue& SpDateTime::prim_getHour(SpValue& self)
+{
+    SpDateTime* dt = self.asDateTime();
+    SpTime* p = dt->time.asTime();
+    //    static SpValue result;
+    //    result.setInt(p->hour);
+    //    return result;
+    return SpIntResult(p->hour);
+}
+
+SpValue& SpDateTime::prim_getMinute(SpValue& self)
+{
+    SpDateTime* dt = self.asDateTime();
+    SpTime* p = dt->time.asTime();
+    //    static SpValue result;
+    //    result.setInt(p->minute);
+    //    return result;
+    return SpIntResult(p->minute);
+}
+
+SpValue& SpDateTime::prim_getSecond(SpValue& self)
+{
+    SpDateTime* dt = self.asDateTime();
+    SpTime* p = dt->time.asTime();
+    //    static SpValue result;
+    //    result.setInt(p->second);
+    //    return result;
+    return SpIntResult(p->second);
+}
+
+SpValue& SpDateTime::prim_getDate(SpValue& self)
+{
+    SpDateTime* dt = self.asDateTime();
+    SpDate* p = dt->date.asDate();
+    //    static SpValue result;
+    //    result.setObject(p);
+    //    return result;
+    return SpObjectResult(p);
+}
+
+SpValue& SpDateTime::prim_getTime(SpValue& self)
+{
+    SpDateTime* dt = self.asDateTime();
+    SpTime* p = dt->time.asTime();
+    //    static SpValue result;
+    //    result.setObject(p);
+    //    return result;
+    return SpObjectResult(p);
+}
+
+// Message Handler
+SpValue& SpDateTime::onMessage(SpValue& rec, SpValue& msg)
+{
+    return DateTimeMsgHandler(rec, msg);
+}
+
+// init
+void SpDateTime::init()
+{
+    SpValue SymDateTime(new SpSymbol("datetime"));
+    SpNameSpace* pDateTimeNS = new SpNameSpace;
+    SpValue DateTimeNS(pDateTimeNS);
+    PMainNameSpace->internConst(SymDateTime, DateTimeNS);
+
+    // for Class
+    SpValue SymNow(new SpSymbol("now"));
+    SpValue PrimNow(new SpPrim0(prim_now));
+    pDateTimeNS->internPrimProperty(SymNow, NilObject, PrimNow, NilObject);
+
+    SpValue SymNew(new SpSymbol("new"));
+    SpValue PrimNew(new SpPrim2(prim_new));
+    pDateTimeNS->internConst(SymNew, PrimNew);
+
+    // for Object
+    SpValue GetYear(new SpPrim1(prim_getYear));
+    DateTimeMsgHandler.append(SymYear, GetYear);
+
+    SpValue GetMonth(new SpPrim1(prim_getMonth));
+    DateTimeMsgHandler.append(SymMonth, GetMonth);
+
+    SpValue GetDay(new SpPrim1(prim_getDay));
+    DateTimeMsgHandler.append(SymDay, GetDay);
+
+    SpValue GetHour(new SpPrim1(prim_getHour));
+    DateTimeMsgHandler.append(SymHour, GetHour);
+
+    SpValue GetMinute(new SpPrim1(prim_getMinute));
+    DateTimeMsgHandler.append(SymMinute, GetMinute);
+
+    SpValue GetSecond(new SpPrim1(prim_getSecond));
+    DateTimeMsgHandler.append(SymSecond, GetSecond);
+
+    SpValue GetDate(new SpPrim1(prim_getDate));
+    DateTimeMsgHandler.append(SymDate, GetDate);
+
+    SpValue GetTime(new SpPrim1(prim_getTime));
+    DateTimeMsgHandler.append(SymTime, GetTime);
+}
+
diff --git a/src/Dir.cpp b/src/Dir.cpp
new file mode 100644 (file)
index 0000000..77032ec
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Dir.cpp,v 1.16 2004/05/15 11:17:50 randy Exp $
+ */
+
+#ifdef __WIN32__
+#include <dir.h>
+#endif
+#ifndef __WIN32__
+
+#include <unistd.h>
+
+#endif /* __WIN32__ */
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#ifdef _MBCS
+#include <direct.h>
+#else
+#include <dirent.h>
+#endif
+#include "soopy.h"
+
+
+SpValue& SpDir::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<dir>";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+SpValue& SpDir::onMessage(SpValue& rec, SpValue& msg)
+{
+    return DirMsgHandler(rec, msg);
+}
+
+// primitives
+
+SpValue& SpDir::Chdir(SpValue&, SpValue& path)
+{
+    if(!path.isString()){
+        throw SpException("not string (Dir.chdir)");
+    }
+#ifdef _MBCS
+    if(_chdir(path.toCStringWithEncoder()) != 0){
+#else
+    if(chdir(path.toCStringWithEncoder()) != 0){
+#endif
+        throw SpException("can't change dir");
+    }
+    return TrueObject;
+}
+
+SpValue& SpDir::Mkdir(SpValue&, SpValue& path)
+{
+    if(!path.isString()){
+        throw SpException("not string (Dir.mkdir)");
+    }
+#ifdef __WIN32__
+    if(mkdir(path.toCStringWithEncoder()) != 0){
+#else
+    if(mkdir(path.toCStringWithEncoder(), 0777) != 0){
+#endif
+        if(errno == EACCES){
+            throw SpException("can't make dir. permission denied.");
+        }
+        if(errno == ENOENT){
+            throw SpException("can't make dir. no such a entry.");
+        }
+        throw SpException("can't make dir.");
+    }
+    return TrueObject;
+}
+
+SpValue& SpDir::Rmdir(SpValue&, SpValue& path)
+{
+    if(!path.isString()){
+        throw SpException("not string (Dir.rmdir)");
+    }
+    if(rmdir(path.toCStringWithEncoder()) != 0){
+        if(errno == EACCES){
+            throw SpException("can't rmdir. permission denied.");
+        }
+        if(errno == ENOENT){
+            throw SpException("can't rmdir. no such a directory.");
+        }
+        throw SpException("can't remove dir.");
+    }
+    return TrueObject;
+}
+
+SpValue& SpDir::List(SpValue&, SpValue& path)
+{
+    if(!path.isString()){
+        throw SpException("not string (Dir.list)");
+    }
+    DIR* dir = opendir(path.toCStringWithEncoder());
+    struct dirent* ent;
+    if(dir == NULL){
+        if(errno == ENOENT){
+            throw SpException("can't open directory. no such a directory. (Dir.list)");
+        }
+        throw SpException("can't open dir. (Dir.list)");
+    }
+    ent = readdir(dir);
+    if(ent == NULL){
+        return NilObject;
+    }
+    SpValue temp(new SpString(ent->d_name));
+    SpCons* head = new SpCons(temp);
+    SpCons* ptr = head;
+    try{
+        while((ent = readdir(dir)) != NULL){
+            temp.setNewObject(new SpString(ent->d_name));
+            ptr->append(temp);
+            ptr = (SpCons*)ptr->next();
+        }
+    }catch(...){
+        closedir(dir);
+        throw;
+    }
+    closedir(dir);
+
+    //    static SpValue result;
+    //    result.setNewObject(head);
+    //    return result;
+    return SpObjectResult(head);
+}
+
+SpValue& SpDir::Pwd(SpValue&)
+{
+    char buf[MAXPATH];
+    if(getcwd(buf, MAXPATH) == NULL){
+        throw SpException("can't get working directory name");
+    }
+    SpString* str = new SpString(buf);
+    //    static SpValue result;
+    //    result.setNewObject(str);
+    //    return result;
+    return SpObjectResult(str);
+}
+
+// Dir.glob
+SpValue& SpDir::prim_glob(SpValue&, SpValue& p)
+{
+    if(!p.isString()){
+        throw SpException("not string (Dir.glob)");
+    }
+    SpString* str = p.asString();
+    SpTuple* tuple = str->split_path_file();
+    SpValue taker(tuple);
+    SpString* path = (*tuple)[0].asString();
+    SpString* glob = (*tuple)[1].asString();
+    DIR* dir = opendir(path->toCStringWithEncoder());
+    struct dirent* ent;
+    if(dir == NULL){
+        if(errno == ENOENT){
+            throw SpException("can't open directory. no such a directory. (Dir.glob)");
+        }
+        throw SpException("can't open dir. (Dir.glob)");
+    }
+    SpValue temp;
+    SpCons* head = NULL;
+    SpCons* ptr = NULL;
+    try{
+        while((ent = readdir(dir)) != NULL){
+            SpString* fname;
+            SpValue taker;
+#ifdef EUC_JP
+            fname = new SpString(ent->d_name, *eucjpin);
+#else
+            fname = new SpString(ent->d_name, *sjisin);
+#endif
+            taker.setNewObject(fname);
+            if(fname->match_glob(glob)){
+                if(head == NULL){
+                    temp.setNewObject(new SpString(ent->d_name));
+                    head = new SpCons(temp);
+                    ptr = head;
+                }else{
+                    temp.setNewObject(new SpString(ent->d_name));
+                    ptr->append(temp);
+                    ptr = (SpCons*)ptr->next();
+                }
+            }
+        }
+    }catch(...){
+        closedir(dir);
+        throw;
+    }
+    closedir(dir);
+
+    if(head == NULL){
+        return NilObject;
+    }
+    //    static SpValue result;
+    //    result.setNewObject(head);
+    //    return result;
+    return SpObjectResult(head);
+}
+
+
+
+// init Message Handler
+void SpDir::init()
+{
+    SpValue ObjDir(new SpDir);
+    PMainNameSpace->internConst(SymDir, ObjDir);
+
+    SpValue SymChdir(new SpSymbol("chdir"));
+    SpValue PrimChdir(new SpPrim2(Chdir));
+    DirMsgHandler.append(SymChdir, PrimChdir);
+
+    SpValue SymMkdir(new SpSymbol("mkdir"));
+    SpValue PrimMkdir(new SpPrim2(Mkdir));
+    DirMsgHandler.append(SymMkdir, PrimMkdir);
+
+    SpValue SymRmdir(new SpSymbol("rmdir"));
+    SpValue PrimRmdir(new SpPrim2(Rmdir));
+    DirMsgHandler.append(SymRmdir, PrimRmdir);
+
+    SpValue SymList(new SpSymbol("list"));
+    SpValue PrimList(new SpPrim2(List));
+    DirMsgHandler.append(SymList, PrimList);
+
+    SpValue SymPwd(new SpSymbol("pwd"));
+    SpValue PrimPwd(new SpPrim1(Pwd));
+    DirMsgHandler.append(SymPwd, PrimPwd);
+
+    SpValue SymGlob(new SpSymbol("glob"));
+    SpValue PrimGlob(new SpPrim2(prim_glob));
+    DirMsgHandler.append(SymGlob, PrimGlob);
+}
+
diff --git a/src/EucJPRW.cpp b/src/EucJPRW.cpp
new file mode 100644 (file)
index 0000000..05bb99c
--- /dev/null
@@ -0,0 +1,280 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: EucJPRW.cpp,v 1.27 2004/05/22 05:22:34 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * Class EucJPReader
+ */
+
+#include <stdio.h>
+
+SpChar EucJPReadEncoder::readCh()
+{
+    SpChar c;
+    int ch, ku, ten;
+
+    if(count >= 0){
+        return buf[count--];
+    }
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+    if(isEOF(c)){ return (SpChar)NULL; }
+
+    if(!EqualCharCode(c, CodeJIS)){
+        return c;
+    }
+    ch  = SpCharGetChar(c);
+    ku  = (ch >> 8);
+    ten = (ch & 0xFF);
+    if(ku == 0){
+        return ten;
+    }else{
+        // first byte
+        ku  += 0xA0 - 0x20;
+        // second byte
+        ten += 0xA0 - 0x20;
+        buf[0] = ten;
+        count = 0;
+    }
+    return ku;
+}
+
+SpChar EucJPReadDecoder::readCh()
+{
+    char c;
+    int ch1, ch2;
+
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+    if(isEOF(c)){ return (SpChar)NULL; }
+    ch1 = c & 0xff;
+    if(0xA1 <= ch1 && ch1 <= 0xFE){ // JIS X 0208
+        c = reader->ReadChar();
+        ch2 = c & 0xff;
+        ch1 = ch1 - 0xA0 + 0x20;
+        ch2 = ch2 - 0xA0 + 0x20;
+        return MakeSpChar(CodeJIS, (ch1<<8) | ch2);
+    }
+    return MakeSpChar(CodeJIS, c);
+}
+
+/*
+ * Class EucJPWriteEncoder
+ */
+
+void EucJPWriteEncoder::WriteChar(SpChar c)
+{
+    int ch, ku, ten;
+
+    if(!EqualCharCode(c, CodeJIS)){
+        writeTextTronCode(c);
+        return;
+    }
+    ch  = SpCharGetChar(c);
+    ku  = (ch >> 8);
+    ten = (ch & 0xFF);
+    if(ku == 0){
+        writer->WriteChar((char)ten);
+    }else{
+        ku  += 0xA0 - 0x20;
+        ten += 0xA0 - 0x20;
+        // put first byte
+        writer->WriteChar((char)ku);
+        // put second byte
+        writer->WriteChar((char)ten);
+    }
+}
+
+/*
+ * Class EucJPWriteDecoder
+ */
+
+void EucJPWriteDecoder::WriteChar(SpChar c)
+{
+    int ch2;
+
+    if(count == 0){
+        if(c > 0xFF){ // not jis
+            if(isEOL(c)){
+                writer->WriteChar(c);
+            }else{
+                writeTextTronCode(c);
+            }
+        }else if(0xA1 <= c && c <= 0xFE){ // JIS X 0208
+            /*
+            if(0xA1 <= ch1 && ch1 <= 0xDF){ // when hankaku KANA
+                // write Zenkaku KANA
+            }
+            */
+            ch1 = c;
+            count++;
+        }else{
+            writer->WriteChar(c);
+        }
+        return;
+    }
+    // count == 1
+    count = 0;
+    ch2 = c;
+    ch1 = ch1 - 0xA0 + 0x20;
+    ch2 = ch2 - 0xA0 + 0x20;
+    writer->WriteChar(MakeSpChar(CodeJIS, (ch1<<8) | ch2));
+}
+
+/*
+ * EucJPFile
+ *   openIn, openOut
+ */
+
+SpValue& eucjp_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (EucJP.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+#ifdef __WIN32__
+    fin->open(filename, ios::binary);
+#else
+    fin->open(filename);
+#endif
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new EucJPReadDecoder(sr);
+    return SpObjectResult(encoder);
+}
+
+SpValue& eucjp_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (EucJP.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary);
+#else
+    fout->open(filename);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new EucJPWriteEncoder(sw);
+    return SpObjectResult(encoder);
+}
+
+SpValue& eucjp_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (EucJP.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new EucJPWriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& eucjp_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (EucJP.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new EucJPReadEncoder(reader);
+    return SpObjectResult(encoder);
+}
+
+SpValue& eucjp_decoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (EucJP.decoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new EucJPReadDecoder(reader);
+    return SpObjectResult(encoder);
+}
+
+SpValue& eucjp_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (EucJP.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new EucJPWriteEncoder(writer);
+    return SpObjectResult(encoder);
+}
+
+SpValue& eucjp_decoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (EucJP.decoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new EucJPWriteDecoder(writer);
+    return SpObjectResult(encoder);
+}
+
+// init
+void initEucJPFile()
+{
+    SpValue SymEucJP(new SpSymbol("eucjp"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSEucJP(ns);
+    PMainNameSpace->internConst(SymEucJP, NSEucJP);
+
+    SpValue PrimOpenIn(new SpPrim1(&eucjp_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&eucjp_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+    SpValue PrimDecoderIn(new SpPrim1(&eucjp_decoderIn));
+    ns->internConst(SymDecoderIn, PrimDecoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&eucjp_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+    SpValue PrimOpenAppend(new SpPrim1(&eucjp_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+    SpValue PrimEncoderOut(new SpPrim1(&eucjp_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+    SpValue PrimDecoderOut(new SpPrim1(&eucjp_decoderOut));
+    ns->internConst(SymDecoderOut, PrimDecoderOut);
+}
+
diff --git a/src/Except.cpp b/src/Except.cpp
new file mode 100644 (file)
index 0000000..010de2b
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Except.cpp,v 1.10 2004/03/24 11:53:44 randy Exp $
+ */
+
+#include <stdio.h>
+#include "soopy.h"
+
+// SpException
+const char* SpException::what() const throw()
+{
+    static char buf[256];
+    sprintf(buf, "%s,  file '%s', line %d", str, file, line);
+    return buf;
+}
+
+// SpIllegalMessageException
+const char* SpIllegalMessageException::what() const throw()
+{
+  static char buf[256];
+#ifdef _MBCS
+  _snprintf(buf, 255, "Illegal message. <%s> is not symbol.", ((SpValue)msg).toCString());
+#else
+  snprintf(buf, 255, "Illegal message. <%s> is not symbol.", ((SpValue)msg).toCString());
+#endif
+  return buf;
+}
+
+// SpSystemError
+const char* SpSystemError::what() const throw()
+{
+    static char buf[2048];
+    sprintf(buf, "%s, file '%s:%d', source '%s:%d'", str, file, line, filename, lineno);
+    return buf;
+}
+
+// SpNoMethodException
+const char* SpNoMethodException::what() const throw()
+{
+    static char buf[2048];
+    sprintf(buf, "%s, receiver=%s, message=%s, file '%s', line %d", str, receiver, message, file, line);
+    return buf;
+}
+
+// SpKeyException
+const char* SpKeyException::what() const throw()
+{
+    static char buf[2048];
+    sprintf(buf, "%s, %s, file '%s', line %d", str, key, file, line);
+    return buf;
+}
+
+// SpTypeException
+const char* SpTypeException::what() const throw()
+{
+    static char buf[2048];
+    sprintf(buf, "%s. declare type '%s' but value type '%s', file '%s', line %d",
+            str, rtype, vtype, file, line);
+    return buf;
+}
+
diff --git a/src/Expr.cpp b/src/Expr.cpp
new file mode 100644 (file)
index 0000000..d78ab55
--- /dev/null
@@ -0,0 +1,516 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Expr.cpp,v 1.12 2004/03/24 11:53:44 randy Exp $
+ */
+
+#include "soopy.h"
+
+SpValue& SpQuote::toString(){
+    SpString* str = new SpString("$");
+    *str += expr;
+    //    static SpValue v;
+    //    v.setNewObject(str);
+    //    return v;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprUMinus
+ */
+SpValue& ExprUMinus::eval()
+{
+    //    static SpValue result;
+    //    result = expr.eval().uminus();
+    //    return result;
+
+    //return SpValueResult(expr.eval().uminus());
+    SpValue temp;
+    temp = expr.eval();
+    return SpValueResult(temp.uminus());
+}
+
+SpValue& ExprUMinus::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "-";
+    *str += expr.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+
+/*
+ * class ExprPlus
+ */
+
+SpValue& ExprPlus::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.plus(v2);
+    //    return result;
+    return SpValueResult(v1.plus(v2));
+}
+
+SpValue& ExprPlus::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " + ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprMinus
+ */
+
+SpValue& ExprMinus::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.minus(v2);
+    //    return result;
+    return SpValueResult(v1.minus(v2));
+}
+
+SpValue& ExprMinus::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " - ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprTimes
+ */
+
+SpValue& ExprTimes::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.times(v2);
+    //    return result;
+    return SpValueResult(v1.times(v2));
+}
+
+SpValue& ExprTimes::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " * ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprDiv
+ */
+
+SpValue& ExprDiv::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.div(v2);
+    //    return result;
+    return SpValueResult(v1.div(v2));
+}
+
+SpValue& ExprDiv::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " / ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprMod
+ */
+
+SpValue& ExprMod::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.mod(v2);
+    //    return result;
+    return SpValueResult(v1.mod(v2));
+}
+
+SpValue& ExprMod::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " % ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprNOT
+ */
+SpValue& ExprNOT::eval()
+{
+    //    static SpValue result;
+    //    result = expr.eval().boolNot();
+    //    return result;
+
+    //return SpValueResult(expr.eval().boolNot());
+    SpValue temp;
+    temp = expr.eval();
+    return SpValueResult(temp.boolNot());
+}
+
+SpValue& ExprNOT::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "!";
+    *str += expr.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprAND
+ */
+
+SpValue& ExprAND::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.boolAnd(v2);
+    //    return result;
+    return SpValueResult(v1.boolAnd(v2));
+}
+
+SpValue& ExprAND::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " && ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprOR
+ */
+
+SpValue& ExprOR::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.boolOr(v2);
+    //    return result;
+    return SpValueResult(v1.boolOr(v2));
+}
+
+SpValue& ExprOR::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " || ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprEQ (==)
+ */
+
+SpValue& ExprEQ::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.eq(v2);
+    //    return result;
+    return SpValueResult(v1.eq(v2));
+}
+
+SpValue& ExprEQ::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " == ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprNE (!=)
+ */
+
+SpValue& ExprNE::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.ne(v2);
+    //    return result;
+    return SpValueResult(v1.ne(v2));
+}
+
+SpValue& ExprNE::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " != ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprGT (>)
+ */
+
+SpValue& ExprGT::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.gt(v2);
+    //    return result;
+    return SpValueResult(v1.gt(v2));
+}
+
+SpValue& ExprGT::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " > ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprGE
+ */
+
+SpValue& ExprGE::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.ge(v2);
+    //    return result;
+    return SpValueResult(v1.ge(v2));
+}
+
+SpValue& ExprGE::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " >= ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class Expr
+ */
+
+SpValue& ExprLT::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.lt(v2);
+    //    return result;
+    return SpValueResult(v1.lt(v2));
+}
+
+SpValue& ExprLT::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " < ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprLE
+ */
+
+SpValue& ExprLE::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.le(v2);
+    //    return result;
+    return SpValueResult(v1.le(v2));
+}
+
+SpValue& ExprLE::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " <= ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprWColon
+ */
+
+SpValue& ExprWColon::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.wcolon(v2);
+    //    return result;
+    return SpValueResult(v1.wcolon(v2));
+}
+
+SpValue& ExprWColon::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " :: ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class ExprAT
+ */
+
+SpValue& ExprAT::eval()
+{
+    SpValue v1, v2;
+    v1 = expr1.eval();
+    v2 = expr2.eval();
+    //    static SpValue result;
+    //    result = v1.at(v2);
+    //    return result;
+    return SpValueResult(v1.at(v2));
+}
+
+SpValue& ExprAT::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += expr1.toString();
+    *str += " @ ";
+    *str += expr2.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
diff --git a/src/File.cpp b/src/File.cpp
new file mode 100644 (file)
index 0000000..e5f11c0
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002-2004 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: File.cpp,v 1.28 2004/05/18 12:47:17 randy Exp $
+ */
+
+#include <sys/stat.h>
+#include <time.h>
+
+#ifdef __WIN32__
+
+#include <io.h>
+
+#else
+
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#endif /* __WIN32__ */
+
+#ifdef _MBCS
+#include <direct.h>
+#else
+#include <dirent.h>
+#endif
+
+#include "soopy.h"
+
+
+SpValue& SpFile::toString()
+{
+    return SpObjectResult(new SpString("#<file util>"));
+}
+
+SpValue& SpFile::onMessage(SpValue& rec, SpValue& msg)
+{
+    return FileMsgHandler(rec, msg);
+}
+
+// primitives
+
+SpValue& SpFile::prim_exists(SpValue&, SpValue& path)
+{
+    if(!path.isString()){
+        throw SpException("not string (File.exists)");
+    }
+    char* fname = (char*)path.toCStringWithEncoder();
+    if(access(fname, 04) == 0){
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+SpValue& SpFile::prim_delete(SpValue&, SpValue& path)
+{
+    if(!path.isString()){
+        throw SpException("not string (File.delete)");
+    }
+    char* fname = (char*)path.toCStringWithEncoder();
+    if(remove(fname) == 0){
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+SpValue& SpFile::prim_size(SpValue&, SpValue& path)
+{
+    struct stat statbuf;
+
+    if(!path.isString()){
+        throw SpException("not string (File.size)");
+    }
+    char* fname = (char*)path.toCStringWithEncoder();
+    if(stat(fname, &statbuf) != 0){
+        throw SpException("can't get file status");
+    }
+
+    return SpIntResult(statbuf.st_size);
+}
+
+SpValue& SpFile::prim_rename(SpValue&, SpValue& from, SpValue& to)
+{
+    if(!from.isString()){
+        throw SpException("not string (File.rename)");
+    }
+    if(!to.isString()){
+        throw SpException("not string (File.rename)");
+    }
+    char oldname[SP_NAME_MAX];
+    strncpy(oldname, (char*)from.toCStringWithEncoder(), SP_NAME_MAX-2);
+    oldname[SP_NAME_MAX-2] = '\0';
+    oldname[SP_NAME_MAX-1] = '\0';
+    char* newname = (char*)to.toCStringWithEncoder();
+    if(rename(oldname, newname) == 0){
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+SpValue& SpFile::prim_atime(SpValue&, SpValue& path)
+{
+    SpInt y, m, d, h, min, s;
+    struct tm* area;
+    struct stat statbuf;
+
+    if(!path.isString()){
+        throw SpException("not string (File.atime)");
+    }
+    char* fname = (char*)path.toCStringWithEncoder();
+    if(stat(fname, &statbuf) != 0){
+        throw SpException("can't get file status");
+    }
+
+    area = localtime(&statbuf.st_atime);
+    y = area->tm_year + 1900;
+    m = area->tm_mon+1;
+    d = area->tm_mday;
+    h = area->tm_hour;
+    min = area->tm_min;
+    s = area->tm_sec;
+
+    return SpObjectResult(new SpDateTime(y, m, d, h, min, s));
+}
+
+SpValue& SpFile::prim_ctime(SpValue&, SpValue& path)
+{
+    SpInt y, m, d, h, min, s;
+    struct tm* area;
+    struct stat statbuf;
+
+    if(!path.isString()){
+        throw SpException("not string (File.ctime)");
+    }
+    char* fname = (char*)path.toCStringWithEncoder();
+    if(stat(fname, &statbuf) != 0){
+        throw SpException("can't get file status");
+    }
+
+    area = localtime(&statbuf.st_ctime);
+    y = area->tm_year + 1900;
+    m = area->tm_mon+1;
+    d = area->tm_mday;
+    h = area->tm_hour;
+    min = area->tm_min;
+    s = area->tm_sec;
+
+    return SpObjectResult(new SpDateTime(y, m, d, h, min, s));
+}
+
+SpValue& SpFile::prim_mtime(SpValue&, SpValue& path)
+{
+    SpInt y, m, d, h, min, s;
+    struct tm* area;
+    struct stat statbuf;
+
+    if(!path.isString()){
+        throw SpException("not string (File.mtime)");
+    }
+    char* fname = (char*)path.toCStringWithEncoder();
+    if(stat(fname, &statbuf) != 0){
+        throw SpException("can't get file status");
+    }
+
+    area = localtime(&statbuf.st_mtime);
+    y = area->tm_year + 1900;
+    m = area->tm_mon+1;
+    d = area->tm_mday;
+    h = area->tm_hour;
+    min = area->tm_min;
+    s = area->tm_sec;
+
+    return SpObjectResult(new SpDateTime(y, m, d, h, min, s));
+}
+
+
+// init Message Handler
+void SpFile::init()
+{
+    SpValue SymFile(new SpSymbol("file"));
+    SpValue ObjFile(new SpFile);
+    PMainNameSpace->internConst(SymFile, ObjFile);
+
+    SpValue SymExists(new SpSymbol("exist?"));
+    SpValue PrimExists(new SpPrim2(prim_exists));
+    FileMsgHandler.append(SymExists, PrimExists);
+
+    SpValue SymDelete(new SpSymbol("delete"));
+    SpValue PrimDelete(new SpPrim2(prim_delete));
+    FileMsgHandler.append(SymDelete, PrimDelete);
+
+    SpValue SymSize(new SpSymbol("size"));
+    SpValue PrimSize(new SpPrim2(prim_size));
+    FileMsgHandler.append(SymSize, PrimSize);
+
+    SpValue SymRename(new SpSymbol("rename"));
+    SpValue PrimRename(new SpPrim3(prim_rename));
+    FileMsgHandler.append(SymRename, PrimRename);
+
+    SpValue PrimAtime(new SpPrim2(prim_atime));
+    FileMsgHandler.append(SymAtime, PrimAtime);
+
+    SpValue PrimCtime(new SpPrim2(prim_ctime));
+    FileMsgHandler.append(SymCtime, PrimCtime);
+
+    SpValue PrimMtime(new SpPrim2(prim_mtime));
+    FileMsgHandler.append(SymMtime, PrimMtime);
+}
+
diff --git a/src/Func.cpp b/src/Func.cpp
new file mode 100644 (file)
index 0000000..9ff0a78
--- /dev/null
@@ -0,0 +1,338 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Func.cpp,v 1.29 2004/03/25 13:29:57 randy Exp $
+ */
+
+
+#include "soopy.h"
+
+/*
+ * class SpArg
+ */
+
+SpValue& SpArg::toString()
+{
+    SpString* str;
+    SpValue v1, v2;
+
+    str = new SpString();
+    *str += name.toString();
+    *str += ":";
+    *str += typ.toString();
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class SpUsrFunc
+ */
+
+void SpUsrFunc::checkRequire()
+{
+    SpValue temp;
+    if(!requir.isList()){
+        //if(requir.eval().isFalse()){
+        temp = requir.eval();
+        if(temp.isFalse()){
+            throw SpRequireException("pre conditon error");
+        }
+        return;
+    }
+    SpValue v = requir;
+    while(!v.isNil()){
+        SpList* list = v.asList();
+        //if(list->value().eval().isFalse()){
+        temp = list->value();
+        temp = temp.eval();
+        if(temp.isFalse()){
+            throw SpRequireException("pre conditon error");
+        }
+        v = list->nextList();
+    }
+}
+
+void SpUsrFunc::checkEnsure()
+{
+    SpValue temp;
+    if(!ensure.isList()){
+        //if(ensure.eval().isFalse()){
+        temp = ensure.eval();
+        if(temp.isFalse()){
+            throw SpEnsureException("post conditon error");
+        }
+        return;
+    }
+    SpValue v = ensure;
+    while(!v.isNil()){
+        SpList* list = v.asList();
+        //if(list->value().eval().isFalse()){
+        temp = list->value();
+        temp = temp.eval();
+        if(temp.isFalse()){
+            throw SpEnsureException("post conditon error");
+        }
+        v = list->nextList();
+    }
+}
+
+// if retry, return true
+bool SpUsrFunc::doRescue()
+{
+    try{
+        if(!rescue.isList()){
+            rescue.eval();
+            return false;
+        }
+        SpValue v = rescue;
+        while(!v.isNil()){
+            SpList* list = v.asList();
+            //list->value().eval();
+            SpValue temp;
+            temp = list->value();
+            temp = temp.eval();
+            v = list->nextList();
+        }
+    }catch(SpRetryException& e){
+        return true;
+    }
+    return false;
+}
+
+SpValue& SpUsrFunc::operator()(SpValue& arg)
+{
+    //    static SpValue result;
+    SpValue result;
+    SpNameSpace* ns = new SpNameSpace(getCurrentNS());
+    SpValue v_ns(ns);
+    SpValue v_f(this);
+
+    // init args
+    if(argLen == 0){
+        if(!arg.isNil()){
+            throw SpException("too many args");
+        }
+    }else if(argLen == 1){
+        SpTuple* ptr = dynamic_cast<SpTuple*>(args.getObject());
+       //        SpArg* p = ((*ptr)[0]).asArg();
+       SpValue temp = (*ptr)[0];
+        SpArg* p = temp.asArg();
+        temp = arg.eval();
+        CheckType(p->typ, temp);
+       //        ns->internVar(p->getVarName(), temp);
+       SpValue temp2 = p->getVarName();
+        ns->internVar(temp2, temp);
+    }else{ // argLen >= 2
+        if(!arg.isTuple()){
+            result.setNewObject(new SpClosureN(v_f, arg, v_ns));
+           //            return result;
+           return SpValueResult(result);
+        }else{
+            SpTuple* t = dynamic_cast<SpTuple*>(arg.getObject());
+            if((SpInt)argLen != t->length()){
+
+
+
+                throw SpException("arg length mismatch");
+            }
+            // set args
+            SpTuple* ptr = dynamic_cast<SpTuple*>(args.getObject());
+            SpValueVector::iterator it, it2;
+            it = ptr->begin();
+            it2 = t->begin();
+            for(; it != ptr->end(); it++, it2++){
+                SpArg* p = it->asArg();
+                SpValue temp = it2->eval();
+                CheckType(p->typ, temp);
+//                ns->internVar(p->getVarName(), it2->eval());
+               SpValue temp2 = p->getVarName();
+                ns->internVar(temp2, temp);
+            }
+        }
+    }
+
+    // set locals
+    SpValue temp = vars;
+    if(temp.isSymbol()){
+        ns->internVar(temp, NilObject);
+    }else{
+        while(!temp.isNil()){
+            SpList* list = temp.asList();
+           //            ns->internVar(list->value(), NilObject);
+           temp = list->value();
+            ns->internVar(temp, NilObject);
+            temp = list->nextList();
+        }
+    }
+
+    /*
+     * Main
+     */
+    pushCurrentNS(v_ns);
+    try{
+        // check pre conditions
+        checkRequire();
+retry:
+        // do body
+        try{
+            result = doBody();
+        }catch(SpExitException& e){
+            if(e.symbol.isNil()){
+                result = e.val;
+            }else if(name == e.symbol){
+                result = e.val;
+            }else{
+                // throw;
+                if(!rescue.isNil()){
+                    if(doRescue()){ // doRescue() == true , then retry
+                        goto retry;
+                    }
+                }
+                throw SpException("uncaught exit");
+            }
+        }catch(SpException& e){
+            if(!rescue.isNil()){
+                if(doRescue()){ // doRescue() == true , then retry
+                    goto retry;
+                }
+            }
+            throw;
+        }
+        // check post conditions
+        try{
+            checkEnsure();
+        //}catch(SpEnsureException& e){
+        }catch(SpException& e){
+            if(!rescue.isNil()){
+                if(doRescue()){ // doRescue() == true , then retry
+                    goto retry;
+                }
+            }
+            throw;
+        }
+    }catch(...){
+      popCurrentNS();
+      throw;
+    }
+    popCurrentNS();
+
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpUsrFunc::doBody()
+{
+    //    static SpValue result;
+    SpValue result;
+    if(!body.isList()){
+        result = body.eval();
+       //        return result;
+       return SpValueResult(result);
+    }
+    // body is list.
+    SpValue L = body;
+    while(L.isList()){
+        SpList* list = dynamic_cast<SpList*>(L.getObject());
+        SpValue v = list->value();
+        result = v.eval();
+        L = list->nextList();
+    }
+
+    //    return result;
+    return SpValueResult(result);
+}
+
+/*
+SpValue& SpUsrFunc::onMessage(SpValue& rec, SpValue& msg)
+{
+    return (*this)(msg);
+}
+*/
+
+SpValue& SpUsrFunc::toString()
+{
+    SpString* str;
+    SpValue v1, v2;
+
+    str = new SpString();
+    *str = "fun ";
+    *str += name.toString();
+    *str += args.toString();
+    *str += "\n";
+/*
+    *str += "{\n";
+    *str += body.toString();
+    *str += "\n}\n";
+*/
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+SpUsrFunc* SpUsrFunc::fromNameSpace(SpNameSpace*ns)
+{
+    extern void checkAllSymbols(SpValue& list);
+    SpValue name, args, vars, require, body, ensure, rescue;
+
+    SpValue a = ns->lookup(SymArg);
+    checkAllSymbols(a);
+    if(a.isNil()){
+        args = NilObject;
+    }else if(a.isList()){
+        SpValueVector vec;
+        while(!a.isNil()){
+            SpList* ptr = a.asList();
+           //            SpValue v(new SpArg(ptr->value(), NilObject));
+           SpValue temp;
+           temp = ptr->value();
+            SpValue v(new SpArg(temp, NilObject));
+            vec.push_back(v);
+            a = ptr->nextList();
+        }
+        args.setNewObject(new SpTuple(vec));
+    }else{ // isSymbol
+        SpValueVector vec;
+        vec.push_back(a);
+        args.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+    }
+
+    name    = ns->lookup(SymName);
+    vars    = ns->lookup(SymVar);
+    checkAllSymbols(vars);
+    require = ns->lookup(SymRequire);
+    body    = ns->lookup(SymDo);
+    ensure  = ns->lookup(SymEnsure);
+    rescue  = ns->lookup(SymRescue);
+
+    return new SpUsrFunc(name,
+                          args,
+                          vars,
+                          require,
+                          body,
+                          ensure,
+                          rescue);
+}
+
+/*
+ * class SpRetry
+ */
+
+SpValue& SpRetry::toString()
+{
+    SpString* str;
+    str = new SpString("retry");
+    //    static SpValue v;
+    //    v.setNewObject(str);
+    //    return v;
+    return SpObjectResult(str);
+}
diff --git a/src/Handler.cpp b/src/Handler.cpp
new file mode 100644 (file)
index 0000000..2bb7030
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Handler.cpp,v 1.15 2004/03/28 02:30:35 randy Exp $
+ */
+
+#include "soopy.h"
+
+
+bool VVCmp::operator()(const SpValue& key1, const SpValue& key2) const
+{
+    return (SpValue&)key1 < (SpValue&)key2;
+}
+
+MsgHandler::~MsgHandler()
+{
+}
+
+void MsgHandler::append(SpValue& message, SpValue& handler)
+{
+//    VVMap::iterator it;
+//    it = aMap.find(message);
+//    if(it != aMap.end()){
+//        aMap.erase(it);
+//    }
+    aMap[message] = handler;
+}
+
+bool MsgHandler::hasMessage(SpValue& message)
+{
+    VVMap::iterator it;
+    it = aMap.find(message);
+    if(it == aMap.end()){
+        return false;
+    }
+    return true;
+}
+
+SpValue& MsgHandler::operator()(SpValue& receiver, SpValue& message)
+{
+    VVMap::iterator it;
+    it = aMap.find(message);
+    if(it == aMap.end()){
+        if(parent == NULL){
+            static char buf[256];
+            strncpy(buf, receiver.toCStringWithEncoder(), 255);
+            buf[255] = '\0';
+            static char buf2[256];
+            strncpy(buf2, message.toCStringWithEncoder(), 255);
+            buf2[255] = '\0';
+            throw SpNoMethodException("no such a feature", buf, buf2);
+        }
+        //        return (*parent)(receiver, message);
+        return SpValueResult((*parent)(receiver, message));
+    }
+    SpFunc* f = dynamic_cast<SpFunc*>(it->second.getObject());
+    if(f == NULL){ throw SpException("call not function"); }
+    //    return (*f)(receiver);
+    SpValue result = (*f)(receiver);
+    return SpValueResult(result);
+}
diff --git a/src/ISO2022JP.cpp b/src/ISO2022JP.cpp
new file mode 100644 (file)
index 0000000..06563da
--- /dev/null
@@ -0,0 +1,362 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: ISO2022JP.cpp,v 1.9 2004/05/22 05:22:34 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * Class ISO2022JPReadEncoder
+ */
+
+SpChar ISO2022JPReadEncoder::readCh()
+{
+    SpChar c;
+    int ch, ku, ten;
+
+    if(count >= 0){
+        return buf[count--];
+    }
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+    if(isEOF(c)){ return (SpChar)NULL; }
+
+    if(!EqualCharCode(c, CodeJIS)){
+        return c;
+    }
+
+    ch = SpCharGetChar(c);
+    ku = (ch >> 8);
+    ten = (ch & 0xFF);
+    if(ku == 0){
+        if(out_now != kCodeASCII){
+            out_now = kCodeASCII;
+            buf[3] = 0x1B;
+            buf[2] = 0x28;
+            buf[1] = 0x42;
+            buf[0] = ten;
+            count = 3;
+        }else{
+            buf[0] = ten;
+            count = 0;
+        }
+    }else{
+        if(out_now != kCodeJISX0208){
+            out_now = kCodeJISX0208;
+            buf[4] = 0x1B;
+            buf[3] = 0x24;
+            buf[2] = 0x42;
+            buf[1] = ku;
+            buf[0] = ten;
+            count = 4;
+        }else{
+            buf[1] = ku;
+            buf[0] = ten;
+            count = 1;
+        }
+    }
+    return buf[count--];
+}
+
+/*
+ * Class ISO2022JPReadDecoder
+ */
+
+SpChar ISO2022JPReadDecoder::readCh()
+{
+    SpChar c;
+    int ch1, ch2, ch3;
+    int ku, ten, base1, base2;
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+    if(isEOF(c)){ return (SpChar)NULL; }
+    ch1 = c & 0xff;
+    if(ch1 == 0x1B){
+        c = reader->ReadChar();
+        ch2 = c & 0xff;
+        c = reader->ReadChar();
+        ch3 = c & 0xff;
+        if(ch2 == '(' &&
+           (ch3 == 'B' || ch3 == 'J')){
+            in_now = kCodeASCII;
+        }else if(ch2 == '$' && ch3 == 'B'){
+            in_now = kCodeJISX0208;
+        }else{
+            in_now = kCodeUNKNOWN;
+        }
+        c = reader->ReadChar();
+        ch1 = c & 0xff;
+    }
+    if(in_now == kCodeASCII){ // ASCII( JIS X 0201 )
+        return MakeSpChar(CodeJIS, ch1);
+    }else if(in_now == kCodeJISX0208){
+        SpChar ku = ch1;
+        c = reader->ReadChar();
+        SpChar ten = c & 0xff;
+        return MakeSpChar(CodeJIS, (ku<<8) | ten);
+    }
+    return MakeSpChar(CodeJIS, c);
+}
+
+/*
+ * Class ISO2022JPWriteEncoder
+ */
+
+void ISO2022JPWriteEncoder::WriteChar(SpChar c)
+{
+    int ch, ku, ten;
+
+    if(!EqualCharCode(c, CodeJIS)){
+        if(out_now != kCodeASCII){
+            out_now = kCodeASCII;
+            writer->WriteChar(0x1B);
+            writer->WriteChar(0x28);
+            writer->WriteChar(0x42);
+        }
+        writeTextTronCode(c);
+        return;
+    }
+    ch = SpCharGetChar(c);
+    ku = (ch >> 8);
+    ten = (ch & 0xFF);
+    if(ku == 0){
+        if(out_now != kCodeASCII){
+            out_now = kCodeASCII;
+            writer->WriteChar(0x1B);
+            writer->WriteChar(0x28);
+            writer->WriteChar(0x42);
+        }
+        writer->WriteChar(ten);
+    }else{
+        if(out_now != kCodeJISX0208){
+            out_now = kCodeJISX0208;
+            writer->WriteChar(0x1B);
+            writer->WriteChar(0x24);
+            writer->WriteChar(0x42);
+        }
+        writer->WriteChar(ku);
+        writer->WriteChar(ten);
+    }
+}
+
+/*
+ * Class ISO2022JPWriteDecoder
+ *  ISO2022JP -> TronCode
+ */
+
+void ISO2022JPWriteDecoder::WriteChar(SpChar c)
+{
+    switch(count){
+    case 0:
+        if(ch1 == 0x1B){
+            ch1 = c;
+            in_now = kCodeESCAPE;
+            count++;
+        }else if(c > 0xFF){ // not jis
+            writer->WriteChar(c);
+        }else{
+            if(in_now == kCodeASCII){
+                writer->WriteChar(MakeSpChar(CodeJIS, c));
+            }else{
+                ch1 = c;
+                count++;
+            }
+        }
+        break;
+    case 1:
+        if(in_now == kCodeESCAPE){
+            ch2 = c;
+            count++;
+        }else{ // kCodeJISX0208
+            writer->WriteChar(MakeSpChar(CodeJIS, (ch1<<8) | c));
+            count = 0;
+        }
+        break;
+    case 2:
+        // kCodeESCAPE only
+        if(ch2 == '(' &&
+           (c == 'B' || c == 'J')){
+            in_now = kCodeASCII;
+        }else if(ch2 == '$' && c == 'B'){
+            in_now = kCodeJISX0208;
+        }else{
+            in_now = kCodeUNKNOWN;
+        }
+        count = 0;
+        break;
+    }
+}
+
+
+/*
+ * ISO2022JPFile
+ *   openIn, openOut
+ */
+
+SpValue& iso2022jp_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (ISO2022JP.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+#ifdef __WIN32__
+    fin->open(filename, ios::binary);
+#else
+    fin->open(filename);
+#endif
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new ISO2022JPReadDecoder(sr);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& iso2022jp_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (ISO2022JP.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary);
+#else
+    fout->open(filename);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new ISO2022JPWriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& iso2022jp_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (ISO2022JP.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new ISO2022JPWriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& iso2022jp_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (ISO2022JP.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new ISO2022JPReadEncoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& iso2022jp_decoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (ISO2022JP.decoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new ISO2022JPReadDecoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& iso2022jp_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (ISO2022JP.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new ISO2022JPWriteEncoder(writer);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& iso2022jp_decoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (ISO2022JP.decoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new ISO2022JPWriteDecoder(writer);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+// init
+void initISO2022JPFile()
+{
+    SpValue SymISO2022JP(new SpSymbol("iso2022jp"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSISO2022JP(ns);
+    PMainNameSpace->internConst(SymISO2022JP, NSISO2022JP);
+
+    SpValue PrimOpenIn(new SpPrim1(&iso2022jp_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&iso2022jp_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+    SpValue PrimDecoderIn(new SpPrim1(&iso2022jp_decoderIn));
+    ns->internConst(SymDecoderIn, PrimDecoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&iso2022jp_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+    SpValue PrimOpenAppend(new SpPrim1(&iso2022jp_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+    SpValue PrimEncoderOut(new SpPrim1(&iso2022jp_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+    SpValue PrimDecoderOut(new SpPrim1(&iso2022jp_decoderOut));
+    ns->internConst(SymDecoderOut, PrimDecoderOut);
+}
+
diff --git a/src/If.cpp b/src/If.cpp
new file mode 100644 (file)
index 0000000..8130a41
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: If.cpp,v 1.12 2004/03/21 05:48:06 randy Exp $
+ */
+
+#include "soopy.h"
+
+SpValue& SpIf::eval()
+{
+    SpValue condition = cond.eval();
+    SpNameSpace* ns = new SpNameSpace(getCurrentNS());
+    SpValue taker(ns);
+
+    SpTuple* tuple = assoc.asTuple();
+    SpValueVector::iterator it = tuple->begin();
+    for(; it != tuple->end(); it++){
+        NSPairAdaptor* adapt = dynamic_cast<NSPairAdaptor*>(it->getObject());
+        if(adapt == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+        NSPair* pair = adapt->pair;
+
+        ns->clear();
+        if(pair->first.match(condition, ns)){
+            //            static SpValue result;
+            SpValue result;
+            pushCurrentNS(taker);
+            try{
+                if(pair->second.isList()){
+                    // second is list.
+                    SpValue L = pair->second;
+                    while(L.isList()){
+                        SpList* list = dynamic_cast<SpList*>(L.getObject());
+                        SpValue v = list->value();
+                        result = v.eval();
+                        L = list->nextList();
+                    }
+                }else{ // not list
+                    result = pair->second.eval();
+                }
+            }catch(...){
+             popCurrentNS();
+             throw;
+            }
+            popCurrentNS();
+           //            return result;
+           return SpValueResult(result);
+        }
+    }
+    return NilObject; // not match
+}
+
+SpValue& SpIf::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += "if(";
+    *str += cond.toString();
+    *str += "){\n";
+
+    SpTuple* tuple = assoc.asTuple();
+    SpValueVector::iterator it = tuple->begin();
+    for(; it != tuple->end(); it++){
+        NSPairAdaptor* adapt = dynamic_cast<NSPairAdaptor*>(it->getObject());
+        if(adapt == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+        NSPair* pair = adapt->pair;
+
+        *str += "  ";
+        *str += pair->first;
+        *str += ": ";
+        *str += pair->second;
+        *str += ";\n";
+    }
+    *str += "}";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
diff --git a/src/Int.cpp b/src/Int.cpp
new file mode 100644 (file)
index 0000000..1022853
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Int.cpp,v 1.8 2004/03/21 05:48:06 randy Exp $
+ */
+
+#include "soopy.h"
+
+// primitives
+
+SpInt int_fromString(SpString* str)
+{
+  SpInt result = 0;
+
+  SpCharVector::iterator it;
+  for(it = str->begin(); it != str->end(); it++){
+    if(!isDIGIT(*it)){
+      throw SpException("not integer (int_fromString)");
+    }
+    result = (result * 10) + toINT(*it);
+  }
+
+  return result;
+}
+
+SpValue& int_toChar(SpValue& v)
+{
+    SpInt i = v.getInt();
+    /*
+    static SpValue res;
+    res.setInt(i);
+    res.typ = TypeChar;
+    return res;
+    */
+    return SpCharResult((SpChar)i);
+}
+
+SpValue& int_toReal(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal((SpReal)v.getInt());
+    //    return res;
+    return SpRealResult((SpReal)v.getInt());
+}
+
+SpValue& int_toString(SpValue& v)
+{
+    SpString* str = new SpString;
+    *str += v;
+    //    static SpValue res;
+    //    res.setNewObject(str);
+    //    return res;
+    return SpObjectResult(str);
+}
+
+SpValue& int_repeat(SpValue& self, SpValue& n)
+{
+    //    static SpValue result;
+    SpValue result;
+
+    if(!n.isNameSpace()){
+        throw SpException("not namespace in repeat");
+    }
+    SpNameSpace* ns = n.asNameSpace();
+    SpUsrFunc* func = SpUsrFunc::fromNameSpace(ns);
+    SpValue taker(func);
+    SpInt count = self.getInt();
+    for(int i=0; i < count; i++){
+        SpValue arg;
+        arg.setInt(i);
+        result = (*func)(arg);
+    }
+    //    return result;
+    return SpValueResult(result);
+}
+
+// init Message Handler
+void initInt()
+{
+    IntMsgHandler.append(SymIsInt, PrimTrue);
+
+    SpValue SymToChar(new SpSymbol("tochar"));
+    SpValue PrimToChar(new SpPrim1(int_toChar));
+    IntMsgHandler.append(SymToChar, PrimToChar);
+
+    SpValue SymToReal(new SpSymbol("toreal"));
+    SpValue PrimToReal(new SpPrim1(int_toReal));
+    IntMsgHandler.append(SymToReal, PrimToReal);
+
+    SpValue PrimToString(new SpPrim1(int_toString));
+    IntMsgHandler.append(SymToString, PrimToString);
+
+    SpValue SymRepeat(new SpSymbol("repeat"));
+    SpValue PrimRepeat(new SpPrim2(int_repeat));
+    IntMsgHandler.append(SymRepeat, PrimRepeat);
+}
diff --git a/src/Japanese.cpp b/src/Japanese.cpp
new file mode 100644 (file)
index 0000000..594cfc5
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Japanese.cpp,v 1.7 2004/03/21 05:48:06 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * Class JapaneseReadDecoder
+ */
+
+SpChar JapaneseReadDecoder::readCh()
+{
+    SpChar c;
+    int ch1, ch2;
+
+    if(encoder != NULL){
+        return encoder->ReadChar();
+    }
+
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+    if(isEOF(c)){ return (SpChar)NULL; }
+    ch1 = c & 0xff;
+    if(ch1 == 0x1B){
+        reader->UnreadChar(c);
+        setEncoder(new ISO2022JPReadDecoder(reader));
+        return encoder->ReadChar();
+    }else if(ch1 > 0x7F){
+        unsigned char s[3];
+        s[0] = c;
+        c = reader->ReadChar();
+        ch2 = c & 0xff;
+        s[1] = c;
+        s[2] = '\0';
+        istringstream is((char*)s);
+        StreamReader* r = new StreamReader(&is);
+        SpValue taker(r);
+        if((0xA1 <= ch1 && ch1 <= 0xFE) &&
+           (0xA1 <= ch2 && ch2 <= 0xFE)){ // Euc
+            EucJPReadDecoder euc_enc(r);
+            c = euc_enc.ReadChar();
+            setEncoder(new EucJPReadDecoder(reader));
+        }else{ // Sjis
+            SjisReadDecoder sjis_enc(r);
+            c = sjis_enc.ReadChar();
+            setEncoder(new SjisReadDecoder(reader));
+        }
+    }else{
+        c = MakeSpChar(CodeJIS, c);
+    }
+    return c;
+}
+
+/*
+ * JapaneseFile
+ *   openIn, openOut
+ */
+
+SpValue& japanese_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Japanese.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+    fin->open(filename);
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new JapaneseReadDecoder(sr);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& japanese_decoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (Japanese.decoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new JapaneseReadDecoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+// init
+void initJapaneseFile()
+{
+    SpValue SymJapanese(new SpSymbol("japanese"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSJapanese(ns);
+    PMainNameSpace->internConst(SymJapanese, NSJapanese);
+
+    SpValue PrimOpenIn(new SpPrim1(&japanese_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimDecoderIn(new SpPrim1(&japanese_decoderIn));
+    ns->internConst(SymDecoderIn, PrimDecoderIn);
+}
+
diff --git a/src/Lexer.cpp b/src/Lexer.cpp
new file mode 100644 (file)
index 0000000..96cc3a6
--- /dev/null
@@ -0,0 +1,582 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Lexer.cpp,v 1.31 2004/07/04 12:32:36 randy Exp $
+ */
+
+#include "soopy.h"
+#include "ytab.h"
+
+
+Lexer* Lexer::lexer = NULL;
+
+Lexer::Lexer(ReadEncoder& r)
+     : reader(&r)
+{
+    wdot_read = false;
+
+    // init reserved word table
+    //       true, false, nil
+    //       fun, property, const
+    //       if, loop, break, redo
+    //       retry, let, private, public
+    //       or, and
+    reserved[new SpString("true")] = TokTRUE;
+    reserved[new SpString("false")] = TokFALSE;
+    reserved[new SpString("nil")] = NIL;
+    reserved[new SpString("fun")] = FUN;
+    reserved[new SpString("property")] = PROPERTY;
+    reserved[new SpString("const")] = CONSTANT;
+    //reserved[new SpString("if")] = IF;
+    reserved[new SpString("match")] = MATCH;
+    reserved[new SpString("loop")] = LOOP;
+    reserved[new SpString("exit")] = EXIT;
+    reserved[new SpString("next")] = NEXT;
+    reserved[new SpString("retry")] = RETRY;
+    reserved[new SpString("let")] = LET;
+    reserved[new SpString("private")] = PRIVATE;
+    reserved[new SpString("public")] = PUBLIC;
+    reserved[new SpString("or")] = OR;
+    reserved[new SpString("and")] = AND;
+    reserved[new SpString("array")] = ARRAY;
+    reserved[new SpString("datatype")] = DATATYPE;
+}
+
+Lexer::~Lexer()
+{
+    KeywordMap::iterator it;
+    for(it = reserved.begin(); it != reserved.end(); it++){
+        delete it->first;
+    }
+    if(lexer){
+        delete lexer;
+    }
+}
+
+SpChar Lexer::skipWhiteSpace()
+{
+    SpChar c;
+    while(true){
+        c = reader->ReadAsLowerChar();
+        if(isEOL(c)){
+            lineno++;
+        }
+        if(!isWhiteSpace(c)){
+            break;
+        }
+    }
+    return c;
+}
+
+void Lexer::skipOneLine()
+{
+    SpChar c;
+    while(true){
+        c = reader->ReadAsLowerChar();
+        if(isEOL(c)){
+            lineno++;
+            break;
+        }
+    }
+}
+
+void Lexer::skipComment()
+{
+    SpChar c;
+    unsigned int depth = 1;
+    while(true){
+        c = reader->ReadAsLowerChar();
+        if(isEOL(c)){
+            lineno++;
+        }else if(c == JIS('*')){
+            c = reader->ReadAsLowerChar();
+            if(c == JIS('/')){
+                depth--;
+                if(depth == 0){
+                    break;
+                }
+            }
+        }else if(c == JIS('/')){
+            c = reader->ReadAsLowerChar();
+            if(c == JIS('*')){
+                depth++;
+            }
+        }
+    }
+}
+
+inline bool isBinDIGIT(SpChar c)
+{
+    if(JIS('0') <= c && c <= JIS('1')){
+        return true;
+    }
+    return false;
+}
+
+inline bool isOctDIGIT(SpChar c)
+{
+    if(JIS('0') <= c && c <= JIS('7')){
+        return true;
+    }
+    return false;
+}
+
+inline bool isHexDIGIT(SpChar c)
+{
+    if((JIS('0') <= c && c <= JIS('9')) ||
+       (JIS('a') <= c && c <= JIS('f'))){
+        return true;
+    }
+    return false;
+}
+
+int Lexer::lexBIN()
+{
+    SpInt i = 0;
+    SpChar c;
+
+    while(true){
+        c = reader->ReadAsLowerChar();
+        if(!isBinDIGIT(c)){
+            reader->UnreadAsLowerChar(c);
+            break;
+        }
+        i = (i * 2) + toINT(c);
+    }
+    yylval.setInt(i);
+    return INT;
+}
+
+int Lexer::lexOCT()
+{
+    SpInt i = 0;
+    SpChar c;
+
+    while(true){
+        c = reader->ReadAsLowerChar();
+        if(!isOctDIGIT(c)){
+            reader->UnreadAsLowerChar(c);
+            break;
+        }
+        i = (i * 8) + toINT(c);
+    }
+    yylval.setInt(i);
+    return INT;
+}
+
+int Lexer::lexHEX()
+{
+    SpInt i = 0;
+    SpChar c;
+
+    while(true){
+        c = reader->ReadAsLowerChar();
+        if(!isHexDIGIT(c)){
+            reader->UnreadAsLowerChar(c);
+            break;
+        }
+        if(isDIGIT(c)){
+            i = (i * 16) + toINT(c);
+        }else{
+            i = (i * 16) + (c - JIS('a') + 10);
+        }
+    }
+    yylval.setInt(i);
+    return INT;
+}
+
+int Lexer::lexZeroNumber()
+{
+    SpChar c = reader->ReadAsLowerChar();
+    switch(c){
+      case JIS('.'): // Real or '..'
+        integer = 0;
+        //        buf[0] = MakeSpChar(CodeJIS, '0');
+        //        buf[1] = MakeSpChar(CodeJIS, '.');
+        buf[0] = '0';
+        buf[1] = '.';
+        index = 2;
+        return lexReal();
+      case JIS('x'): // HEX. ex. 0x3e, 0xff
+        return lexHEX();
+      case JIS('b'): // BIN. ex. 0b1001 0b01011100
+        return lexBIN();
+      default:
+        if(isOctDIGIT(c)){ // OCT. ex. 0712
+            reader->UnreadAsLowerChar(c);
+            return lexOCT();
+        }else{
+            //throw SpException("illegal number format (bin, oct, hex)");
+            reader->UnreadAsLowerChar(c);
+            yylval.setInt(0);
+            return INT;
+        }
+    }
+}
+
+int Lexer::lexNumber()
+{
+//    bool isInteger = true;
+    SpChar c;
+
+    integer = 0;
+    index = 0;
+    while(true){
+        if(index >= MaxBuf){
+            throw SpException("too long num format");
+        }
+        c = reader->ReadAsLowerChar();
+        if(!isDIGIT(c)){
+            if(c == JIS('.')){
+//                isInteger = false;
+                //buf[index] = toHankakuLower(c);
+                buf[index] = c;
+                index++;
+                return lexReal();
+//                break;
+            }
+            reader->UnreadAsLowerChar(c);
+            break;
+        }
+        integer = (integer * 10) + toINT(c);
+        buf[index] = toHankakuLower(c);
+        index++;
+    }
+//    if(isInteger){
+        yylval.setInt(integer);
+        return INT;
+//    }
+}
+
+int Lexer::lexReal()
+{
+    SpChar c;
+    bool notHaveE = true;
+
+    // check '..'
+    c = reader->ReadAsLowerChar();
+    if(c == JIS('.')){
+        yylval.setInt(integer);
+        wdot_read = true;
+        return INT;
+    }
+    reader->UnreadAsLowerChar(c);
+    // Real
+    while(true){
+        if(index >= MaxBuf){
+            throw SpException("too long num format");
+        }
+        c = reader->ReadAsLowerChar();
+        if(!isDIGIT(c)){
+            if((c == JIS('e')) || (c == JIS('E'))){
+                notHaveE = false;
+                buf[index] = toHankakuLower(c);
+                index++;
+                break;
+            }
+            reader->UnreadAsLowerChar(c);
+            break;
+        }
+        buf[index] = toHankakuLower(c);
+        index++;
+    }
+    if(notHaveE){
+        buf[index] = '\0';
+        yylval.setReal(atof(buf));
+        return REAL;
+    }
+    // 000.000e...
+    c = reader->ReadAsLowerChar();
+    if((c == JIS('+')) || (c == JIS('-'))){
+        buf[index] = toHankakuLower(c);
+        index++;
+    }else if(isDIGIT(c)){
+        buf[index] = toHankakuLower(c);
+        index++;
+    }else{
+        throw SpException("illegal num format");
+    }
+    while(true){
+        if(index >= MaxBuf){
+            throw SpException("too long num format");
+        }
+        c = reader->ReadAsLowerChar();
+        if(!isDIGIT(c)){
+            reader->UnreadAsLowerChar(c);
+            break;
+        }
+        buf[index] = toHankakuLower(c);
+        index++;
+    }
+    buf[index] = '\0';
+    yylval.setReal(atof(buf));
+    return REAL;
+}
+
+SpChar Lexer::lexBackslashChar()
+{
+    SpChar c;
+
+    c = reader->ReadChar();
+    switch(c){
+      case JIS('r'): // CR
+        c = MakeSpChar(CodeJIS, 0x0d);
+        break;
+      case JIS('n'): // LF
+        c = MakeSpChar(CodeJIS, 0x0a);
+        break;
+//      default:
+//        if(JIS('a') <= c && c <= JIS('z')){ // control code
+//           c = MakeSpChar(CodeJIS, SpCharGetChar(c) - 'a');
+//        }
+    }
+    return c;
+}
+
+int Lexer::lexString()
+{
+    SpCharVector vec;
+    SpChar c;
+    while(true){
+        c = reader->ReadAsLowerChar();
+        if(c == JIS('"')){
+            break;
+        }
+        if(c == JIS('\\')){
+            //c = reader->ReadChar();
+            c = lexBackslashChar();
+        }else{
+            reader->UnreadAsLowerChar(c);
+            c = reader->ReadChar();
+        }
+        vec.push_back(c);
+    }
+    yylval.setNewObject(new SpString(vec));
+    return STRING;
+}
+
+int Lexer::lexChar()
+{
+    SpChar c = reader->ReadChar();
+    if(toHankakuLower(c) == JIS('\\')){
+        c = lexBackslashChar();
+    }
+    if(reader->ReadAsLowerChar() != JIS('\'')){
+        throw SpException("illegal char format");
+    }
+    yylval.setSpChar(c);
+    return CHAR;
+}
+
+int Lexer::isReserved(SpCharVector& vec)
+{
+    KeywordMap::iterator it;
+    SpString str(vec);
+    it = reserved.find(&str);
+    if(it != reserved.end()){
+        return it->second;
+    }
+    return 0; // not Reserved.
+}
+
+bool Lexer::isReservedKigou(SpChar c)
+{
+    switch(c){
+    case JIS('"'):
+    case JIS('\''):
+    case JIS('#'):
+    case JIS('$'):
+    case JIS('('):
+    case JIS(')'):
+    case JIS('['):
+    case JIS(']'):
+    case JIS('{'):
+    case JIS('}'):
+    case JIS(','):
+    case JIS('|'):
+    case JIS(';'):
+    case JIS('@'):
+    case JIS('='):
+    case JIS('+'):
+    case JIS('-'):
+    case JIS('*'):
+    case JIS('/'):
+    case JIS('%'):
+    case JIS('<'):
+    case JIS('>'):
+    case JIS('!'):
+    case JIS('.'):
+    case JIS(':'):
+        return true;
+    }
+    return false;
+}
+
+int Lexer::lex()
+{
+    SpChar c;
+
+    if(wdot_read){
+        wdot_read = false;
+        return WDOT;
+    }
+
+start:
+    c = skipWhiteSpace();
+    if(isEOF(c)){
+        return EndOfStream;
+    }
+
+    SpCharVector vec;
+    vec.push_back(c);
+    if(isDIGIT(c)){
+        if(c == JIS('0')){
+            return lexZeroNumber();
+        }else{
+            reader->UnreadAsLowerChar(c);
+            return lexNumber();
+        }
+    }
+    switch(c){
+    case JIS('"'):  // string
+        return lexString();
+    case JIS('\''): // char
+        return lexChar();
+    case JIS('#'):  // a line comment
+        skipOneLine();
+        goto start;
+    case JIS('$'):
+        return DOLL;
+    case JIS('('):
+        return LP;
+    case JIS(')'):
+        return RP;
+    case JIS('['):
+        return LB;
+    case JIS(']'):
+        return RB;
+    case JIS('{'):
+        return LC;
+    case JIS('}'):
+        return RC;
+    case JIS(','):
+        return COMMA;
+    case JIS('|'):
+        return BAR;
+    case JIS(';'):
+        return SEMI;
+    case JIS('@'):
+        return AT;
+    case JIS('='):
+        c = reader->ReadAsLowerChar();
+        if(c == JIS('=')){
+            return EQ;
+        }else{
+            reader->UnreadAsLowerChar(c);
+        }
+        return ASSIGN;
+    case JIS('+'):
+        return PLUS;
+    case JIS('-'):
+        return MINUS;
+    case JIS('*'):
+        return TIMES;
+    case JIS('/'): /* "/", "//" */
+        c = reader->ReadAsLowerChar();
+        if(c == JIS('/')){
+            return WSLASH;
+        }else if(c == JIS('*')){
+            skipComment();
+            goto start;
+        }else{
+            reader->UnreadAsLowerChar(c);
+        }
+        return DIV;
+    case JIS('%'):
+        return MOD;
+    case JIS('<'): /* "<", "<=", "<-" */
+        c = reader->ReadAsLowerChar();
+        if(c == JIS('=')){
+            return LE;
+        }else if(c == JIS('-')){
+            return LARROW;
+        }else{
+            reader->UnreadAsLowerChar(c);
+        }
+        return LT;
+    case JIS('>'): /* ">", ">=" */
+        c = reader->ReadAsLowerChar();
+        if(c == JIS('=')){
+            return GE;
+        }else{
+            reader->UnreadAsLowerChar(c);
+        }
+        return GT;
+    case JIS('!'): /* "!", "!=" */
+        c = reader->ReadAsLowerChar();
+        if(c == JIS('=')){
+            return NE;
+        }else{
+            reader->UnreadAsLowerChar(c);
+        }
+        return NOT;
+    case JIS('.'): /* ".", ".." */
+        c = reader->ReadAsLowerChar();
+        if(c == JIS('.')){
+            return WDOT;
+        }else{
+            reader->UnreadAsLowerChar(c);
+        }
+        return DOT;
+    case JIS(':'): /* ":", "::" */
+        c = reader->ReadAsLowerChar();
+        if(c == JIS(':')){
+            return WCOLON;
+        }else{
+            reader->UnreadAsLowerChar(c);
+        }
+        return COLON;
+    }
+
+    // lex SYMBOL
+    //  or Reserved
+    //       true, false, nil
+    //       fun, property, const
+    //       if, loop, break, redo
+    //       retry, let, private, publid
+    //       or, and
+    while(true){
+        c = reader->ReadAsLowerChar();
+        if(isWhiteSpace(c)){
+            break;
+        }
+        if(isReservedKigou(c)){
+            reader->UnreadAsLowerChar(c);
+            break;
+        }
+        vec.push_back(c);
+    }
+    int p = isReserved(vec);
+    if(p){
+        return p;
+    }
+    yylval.setNewObject(new SpSymbol(vec));
+    return SYMBOL;
+}
+
+// end -- class Lexer
+
+int yylex()
+{
+    Lexer* aLexer = Lexer::getLexer();
+    int i = aLexer->lex();
+//cout << "lex: " << i << endl;
+    return i;
+}
diff --git a/src/List.cpp b/src/List.cpp
new file mode 100644 (file)
index 0000000..2a067f4
--- /dev/null
@@ -0,0 +1,1602 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: List.cpp,v 1.61 2004/05/18 12:47:17 randy Exp $
+ */
+
+//
+// Soopy List Class
+//
+
+#include "soopy.h"
+
+/*
+ostream& operator<<(ostream& out, SpList* list)
+{
+  out << "[";
+  while(true){
+    out << list->value();
+    list = list->next();
+    if(list != NULL){
+      out << ", ";
+    }else{
+      break;
+    }
+  }
+  out << "]";
+
+  return out;
+}
+*/
+
+/*
+ * Message Handler
+ */
+
+SpValue& SpList::onMessage(SpValue& rec, SpValue& msg)
+{
+  //    return ListMsgHandler(rec, msg);
+    SpValue result = ListMsgHandler(rec, msg);
+    return SpValueResult(result);
+}
+
+bool SpList::match(SpValue& self, SpValue& val, SpNameSpace* ns)
+{
+    SpValue list, list2, temp, temp2;
+    list = self;
+    list2 = val;
+    while(list2.isList()){
+        SpList* ptr = dynamic_cast<SpList*>(list.getObject());
+        SpList* ptr2 = dynamic_cast<SpList*>(list2.getObject());
+
+        //if(!ptr->value().match(ptr2->value(), ns)){
+        temp = ptr->value();
+        temp2 = ptr2->value();
+        if(!temp.match(temp2, ns)){
+            return false;
+        }
+
+        list = ptr->nextList();
+        list2 = ptr2->nextList();
+        if(list.isNil()){
+            if(list2.isNil()){
+                return true;
+            }
+            break;
+        }
+    }
+    return false;
+}
+
+SpValue& SpList::eq(SpValue& e1, SpValue& e2)
+{
+    SpValue list, list2, temp, temp2;
+    list = e1;
+    list2 = e2;
+    while(list2.isList()){
+        SpList* ptr = list.asList();
+        SpList* ptr2 = list2.asList();
+
+        //if(ptr->value().eq(ptr2->value()).isFalse()){
+        temp = ptr->value();
+        temp2 = ptr2->value();
+        temp = temp.eq(temp2);
+        if(temp.isFalse()){
+            return FalseObject;
+        }
+
+        list = ptr->nextList();
+        list2 = ptr2->nextList();
+        if(list.isNil()){
+            if(list2.isNil()){
+                return TrueObject;
+            }
+            break;
+        }
+    }
+    return FalseObject;
+}
+
+SpList* SpList::nth(int i)
+{
+  SpList* ptr = this;
+  for(int j=0; j < i; j++){
+    //    static SpValue temp;
+    ptr = ptr->next();
+    if(ptr == NULL){
+      throw SpException("index is too big ( list.nth )");
+    }
+    //    temp.setObject(ptr);
+    SpObjectResult(ptr);
+  }
+  return ptr;
+}
+
+
+// list Primitives
+SpValue& SpList::prim_head(SpValue& list)
+{
+    SpList* ptr = dynamic_cast<SpList*>(list.getObject());
+    if(ptr == NULL){
+        throw SpException("not list (head)");
+    }
+    //    return ptr->value().eval();
+    SpValue result;
+    result = ptr->value();
+    result = result.eval();
+    return SpValueResult(result);
+}
+
+SpValue& SpList::prim_tail(SpValue& list)
+{
+    SpList* ptr = dynamic_cast<SpList*>(list.getObject());
+    if(ptr == NULL){
+        throw SpException("not list (tail)");
+    }
+    //    return ptr->nextList();
+
+    SpValue result = ptr->nextList();
+    return SpValueResult(result);
+}
+
+SpValue& SpList::prim_nth(SpValue& self, SpValue& index)
+{
+    if(!index.isInt()){ throw SpException("not int (list.nth)"); }
+    int i = index.getInt();
+    SpValue temp = self;
+    SpList* ptr = self.asList();
+    for(int j=0; j != i; j++){
+        temp = ptr->nextList();
+        if(temp.isNil()){
+            throw SpException("index is too big (list.nth)");
+        }
+        ptr = temp.asList();
+    }
+    //    static SpValue result;
+    //    result = ptr->value().eval();
+    //    return result;
+
+    //return SpValueResult(ptr->value().eval());
+    SpValue result;
+    result = ptr->value();
+    result = result.eval();
+    return SpValueResult(result);
+}
+
+SpValue& SpList::prim_each(SpValue& self, SpValue& func)
+{
+    SpValue taker;
+    SpFunc* f;
+    if(func.isNameSpace()){
+        SpNameSpace* ns = func.asNameSpace();
+        f = SpUsrFunc::fromNameSpace(ns);
+        //        taker.setNewObject(f);
+        taker.setObject(f);
+    }else if(func.isFunc()){
+        f = func.asFunc();
+    }else{
+        throw SpException("not function (list.each)");
+    }
+    SpList* ptr = self.asList();
+
+    while(ptr != NULL){
+        SpValue temp = ptr->value();
+        (*f)(temp);
+        ptr = ptr->next();
+    }
+
+    return NilObject;
+}
+
+SpValue& SpList::prim_map(SpValue& self, SpValue& func)
+{
+    SpValue temp;
+    SpValue taker;
+    SpFunc* f;
+
+    if(func.isNameSpace()){
+        SpNameSpace* ns = func.asNameSpace();
+        f = SpUsrFunc::fromNameSpace(ns);
+        //        taker.setNewObject(f);
+        taker.setObject(f);
+    }else if(func.isFunc()){
+        f = func.asFunc();
+    }else{
+        throw SpException("not function (list.map)");
+    }
+    SpList* ptr = self.asList();
+
+    temp = ptr->value();
+    //SpCons* head = new SpCons((*f)(temp));
+    temp = (*f)(temp);
+    SpCons* head = new SpCons(temp);
+    SpCons* p = head;
+    ptr = ptr->next();
+
+    while(ptr != NULL){
+        temp = ptr->value();
+        //        p->append((*f)(temp));
+        temp = (*f)(temp);
+        p->append(temp);
+        ptr = ptr->next();
+        p = (SpCons*)p->next();
+    }
+
+    //    static SpValue result;
+    //    result.setNewObject(head);
+    //    return result;
+    return SpObjectResult(head);
+}
+
+SpValue& SpList::prim_foldl(SpValue& self, SpValue& func)
+{
+
+    SpValue v1, v2;
+
+    SpValue taker;
+    SpFunc* f;
+    if(func.isNameSpace()){
+        SpNameSpace* ns = func.asNameSpace();
+        f = SpUsrFunc::fromNameSpace(ns);
+        //        taker.setNewObject(f);
+        taker.setObject(f);
+    }else if(func.isFunc()){
+        f = func.asFunc();
+    }else{
+        throw SpException("not function (list.foldl)");
+    }
+    SpList* ptr = self.asList();
+
+    v1 = ptr->value();
+    SpTuple* t = new SpTuple(v1);
+    t->append(NilObject);
+    SpValue arg(t);
+    ptr = ptr->next();
+    while(ptr != NULL){
+        v2 = ptr->value();
+        (*t)[0] = v1;
+        (*t)[1] = v2;
+        v1 = (*f)(arg);
+        ptr = ptr->next();
+    }
+
+    //    static SpValue result;
+    //    result = v1;
+    //    return result;
+    return SpValueResult(v1);
+}
+
+SpValue& SpList::sub_foldr(SpFunc* f,
+                           SpValue& v1,
+                           SpList* list)
+{
+    if(list == NULL){
+        return v1;
+    }
+    SpTuple* t = new SpTuple(v1);
+    //    SpValue& v2 = sub_foldr(f, list->value(), list->next());
+    SpValue temp;
+    temp = list->value();
+    SpValue& v2 = sub_foldr(f, temp, list->next());
+    t->append(v2);
+    SpValue arg(t);
+    //    static SpValue result;
+    //    result = (*f)(arg);
+    //    return result;
+    return SpValueResult((*f)(arg));
+}
+
+SpValue& SpList::prim_foldr(SpValue& self, SpValue& func)
+{
+
+    SpValue v1, v2;
+
+    SpValue taker;
+    SpFunc* f;
+    if(func.isNameSpace()){
+        SpNameSpace* ns = func.asNameSpace();
+        f = SpUsrFunc::fromNameSpace(ns);
+        //        taker.setNewObject(f);
+        taker.setObject(f);
+    }else if(func.isFunc()){
+        f = func.asFunc();
+    }else{
+        throw SpException("not function (list.foldr)");
+    }
+    SpList* ptr = self.asList();
+
+    v1 = ptr->value();
+    ptr = ptr->next();
+    //    static SpValue result;
+    //    result = sub_foldr(f, v1, ptr);
+    //    return result;
+    return SpValueResult(sub_foldr(f, v1, ptr));
+}
+
+SpValue& SpList::prim_member(SpValue& self, SpValue& value)
+{
+    SpValue v1, temp;
+    SpList* ptr = self.asList();
+    while(ptr != NULL){
+        //if(ptr->value().eq(value).isTrue()){
+        temp = ptr->value();
+        temp = temp.eq(value);
+        if(temp.isTrue()){
+            return TrueObject;
+        }
+        v1 = ptr->value();
+        ptr = ptr->next();
+    }
+    return FalseObject;
+}
+
+SpValue& SpList::prim_sort(SpValue& self)
+{
+    SpValue v1, temp;
+
+    if(!self.isCons()){
+        throw SpException("not cons (List.sort)");
+    }
+    SpCons* ptr = (SpCons*)self.asList();
+    SpCons* res = NULL;
+    while(ptr != NULL){
+        v1 = ptr->value();
+
+        // insert to result
+        if(res == NULL){
+            res = new SpCons(v1);
+        }else{
+            SpCons* prev = NULL;
+            SpCons* pos  = res;
+            while(pos != NULL){
+                //                if(v1 < pos->value()){
+                temp = pos->value();
+                if(v1 < temp){
+                    break;
+                }
+
+                prev = pos;
+                pos = (SpCons*)pos->next();
+            }
+            if(prev == NULL){
+              //                temp.setNewObject(res);
+                temp.setObject(res);
+                res = new SpCons(v1, temp);
+            }else{
+                if(pos == NULL){
+                    temp.setNewObject(new SpCons(v1));
+                }else{
+                    SpValue t2;
+                    //                    t2.setNewObject(pos);
+                    t2.setObject(pos);
+                    temp.setNewObject(new SpCons(v1, t2));
+                }
+                prev->setNext(temp);
+            }
+        }
+
+        ptr = (SpCons*)ptr->next();
+    }
+    //    static SpValue result;
+    //    result.setNewObject(res);
+    //    return result;
+    return SpObjectResult(res);
+}
+
+SpValue& SpList::prim_filter(SpValue& self, SpValue& func)
+{
+    SpValue temp;
+    SpValue taker;
+    SpFunc* f;
+    if(func.isNameSpace()){
+        SpNameSpace* ns = func.asNameSpace();
+        f = SpUsrFunc::fromNameSpace(ns);
+        taker.setNewObject(f);
+    }else if(func.isFunc()){
+        f = func.asFunc();
+    }else{
+        throw SpException("not function (list.filter)");
+    }
+    SpList* ptr = self.asList();
+
+    SpCons* head = NULL;
+    SpCons* p = NULL;
+    while(ptr != NULL){
+        SpValue cond;
+        temp = ptr->value();
+        cond = (*f)(temp);
+        if(cond.isTrue()){
+            if(p == NULL){
+                head = new SpCons(temp);
+                p = head;
+            }else{
+                p->append(temp);
+                p = (SpCons*)p->next();
+            }
+        }
+        ptr = ptr->next();
+    }
+
+    if(head == NULL){
+        return NilObject;
+    }
+    //    static SpValue result;
+    //    result.setNewObject(head);
+    //    return result;
+    return SpObjectResult(head);
+}
+
+SpValue& SpList::prim_length(SpValue& self)
+{
+    SpList* ptr = self.asList();
+    //    static SpValue result;
+    //    result.setInt(ptr->length());
+    //    return result;
+    return SpIntResult(ptr->length());
+}
+
+
+// init Message Handler
+void SpList::init()
+{
+    ListMsgHandler.append(SymIsList, PrimTrue);
+    ListMsgHandler.append(SymIsNil, PrimFalse);
+
+    SpValue PrimHead(new SpPrim1(prim_head));
+    ListMsgHandler.append(SymHead, PrimHead);
+
+    SpValue PrimTail(new SpPrim1(prim_tail));
+    ListMsgHandler.append(SymTail, PrimTail);
+
+    SpValue PrimNth(new SpPrim2(prim_nth));
+    ListMsgHandler.append(SymNth, PrimNth);
+
+    SpValue PrimEach(new SpPrim2(prim_each));
+    ListMsgHandler.append(SymEach, PrimEach);
+
+    SpValue PrimMap(new SpPrim2(prim_map));
+    ListMsgHandler.append(SymMap, PrimMap);
+
+    SpValue PrimFoldl(new SpPrim2(prim_foldl));
+    ListMsgHandler.append(SymFoldl, PrimFoldl);
+
+    SpValue PrimFoldr(new SpPrim2(prim_foldr));
+    ListMsgHandler.append(SymFoldr, PrimFoldr);
+
+    SpValue PrimMember(new SpPrim2(prim_member));
+    ListMsgHandler.append(SymMember, PrimMember);
+
+    SpValue PrimSort(new SpPrim1(prim_sort));
+    ListMsgHandler.append(SymSort, PrimSort);
+
+    SpValue PrimFilter(new SpPrim2(prim_filter));
+    ListMsgHandler.append(SymFilter, PrimFilter);
+
+    SpValue PrimLength(new SpPrim1(prim_length));
+    ListMsgHandler.append(SymLength, PrimLength);
+}
+
+
+SpValue& SpList::nextList()
+{
+    SpObject* obj = next();
+    if(obj == NULL){
+        return NilObject;
+    }
+    //    static SpValue v;
+    //    v.setNewObject(obj); // BUG!?
+    //    return v;
+    return SpObjectResult(obj);
+}
+
+SpValue& SpList::toString()
+{
+    SpString* str;
+    SpList* ptr = this;
+
+    str = new SpString();
+    *str = "[";
+    while(true){
+        //*str += ptr->value().toString();
+        SpValue temp;
+        temp = ptr->value();
+        *str += temp.toString();
+        ptr = ptr->next();
+        if(ptr != NULL){
+            *str += ", ";
+        }else{
+            break;
+        }
+    }
+    *str += "]";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+//
+// Soopy Cons Class
+//
+
+SpCons::~SpCons()
+{
+#ifdef TEST
+    *spout << ":destroy SpCons" << "\n";
+#endif
+}
+
+void SpCons::append(SpValue& val)
+{
+    if(cdr.isNil()){
+        SpCons* list = new SpCons(val);
+        cdr.setNewObject(list);
+    }else if(cdr.isObject()){
+        SpCons* list = dynamic_cast<SpCons*>(cdr.getObject());
+        list->append(val);
+    }
+}
+
+int SpCons::length()
+{
+    int i;
+    SpCons* ptr;
+
+    ptr = this;
+    for(i=0; ptr != NULL; i++){
+        ptr = dynamic_cast<SpCons*>(ptr->next());
+    }
+    return i;
+}
+
+bool SpCons::operator==(SpObject& obj)
+{
+    if(SpCons* p2 = dynamic_cast<SpCons*>(&obj)){
+        SpCons* p1 = this;
+        while(true){
+            if(p1 == NULL){
+                if(p2 == NULL){
+                    return true;
+                }
+                break;
+            }
+            if(p2 == NULL){
+                break;
+            }
+            if(p1->car != p2->car){
+                break;
+            }
+
+            // p1++, p2++
+            p1 = dynamic_cast<SpCons*>(p1->next());
+            p2 = dynamic_cast<SpCons*>(p2->next());
+        }
+    }
+    return false;
+}
+
+bool SpCons::operator<(SpObject& obj)
+{
+    if(SpCons* p2 = dynamic_cast<SpCons*>(&obj)){
+        SpCons* p1 = this;
+        while(true){
+            if(p1 == NULL){
+                if(p2 == NULL){
+                    return false;
+                }
+                return true;
+            }
+            if(p2 == NULL){
+                return false;
+            }
+            if(p1->car != p2->car){
+                return p1->car < p2->car;
+            }
+
+            // p1++, p2++
+            p1 = dynamic_cast<SpCons*>(p1->next());
+            p2 = dynamic_cast<SpCons*>(p2->next());
+        }
+    }
+    return SpObject::operator<(obj);
+}
+
+
+//
+// Soopy Range Class
+//
+
+SpRange::~SpRange()
+{
+#ifdef TEST
+    *spout << ":destroy SpRange(" << start << "," << end;
+    *spout << "," << step << ")" << "\n";
+#endif
+}
+
+SpList* SpRange::next()
+{
+    SpRange* range;
+
+    int i = start + step;
+    if(!infinity){
+        if(step >= 0){
+            if(i > end){
+                return NULL;
+            }
+        }else{ // step < 0
+            if(i < end){
+                return NULL;
+            }
+        }
+    }
+    range = new SpRange(i, end, step, infinity);
+    return range;
+}
+
+SpValue& SpRange::value()
+{
+    //    static SpValue i;
+    //    i = start;
+    //    return i;
+    return SpIntResult(start);
+}
+
+SpValue& SpRange::toString()
+{
+    SpString* str;
+    SpRange* ptr = this;
+//    SpValue v(ptr);
+    SpValue v;
+
+    str = new SpString();
+    *str = "[";
+    while(true){
+        //*str += ptr->value().toString();
+        SpValue temp;
+        temp = ptr->value();
+        *str += temp.toString();
+        ptr = (SpRange*)ptr->next();
+        //v = ptr;
+        v.setNewObject(ptr);
+        if(ptr != NULL){
+            *str += ", ";
+        }else{
+            break;
+        }
+    }
+    *str += "]";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+int SpRange::length()
+{
+    int i = 1;
+
+    if(infinity){
+        throw SpNoLengthException("can't calc length(infinity)");
+    }
+
+    if(step == 0){
+        throw SpNoLengthException("can't calc length(infinity)");
+    }else if(step > 0){
+        if(start < end){
+            i += (end - start) / step;
+        }
+    }else{ // step < 0
+        if(start > end){
+            i += (start - end) / (-step);
+        }
+    }
+
+    return i;
+}
+
+// class SpMakeRange
+
+SpValue& SpMakeRange::toString()
+{
+    SpString* str;
+    SpValue v;
+
+    str = new SpString();
+    *str += "[";
+    *str += vstart.toString();
+    *str += "..";
+    if(hasStep){
+        *str += vstep.toString();
+        *str += "..";
+    }
+    if(!infinity){
+        *str += vend.toString();
+    }
+    *str += "]";
+
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+SpValue& SpMakeRange::eval()
+{
+    SpValue temp;
+    SpRange* range;
+    int i;
+    int start;
+    int end;
+    int step;
+
+    temp = vstart.eval();
+    if(!temp.isInt()){
+        throw SpException("not int in range");
+    }
+    start = temp.getInt();
+
+    if(hasStep){
+        temp = vstep.eval();
+        if(!temp.isInt()){
+            throw SpException("not int in range");
+        }
+        i = temp.getInt();
+        step = i - start;
+        if(infinity){
+            range = new SpRange(start, 0, step, true);
+        }else{
+            temp = vend.eval();
+            if(!temp.isInt()){
+                throw SpException("not int in range");
+            }
+            end = temp.getInt();
+            range = new SpRange(start, end, step);
+        }
+    }else{
+        if(infinity){
+            range = new SpRange(start, 0, 1, true);
+        }else{
+            temp = vend.eval();
+            if(!temp.isInt()){
+                throw SpException("not int in range");
+            }
+            end = temp.getInt();
+            if(start <= end){
+                step = 1;
+            }else{
+                step = -1;
+            }
+            range = new SpRange(start, end, step);
+        }
+    }
+
+    //    static SpValue result;
+    //    result.setNewObject(range);
+    //    return result;
+    return SpObjectResult(range);
+}
+
+//
+// SpAppendedList
+//   first @ second
+//
+SpList* SpAppendedList::next()
+{
+  SpList* list = first.asList();
+  list = list->next();
+  if(list == NULL){
+    return second.asList();
+  }else{
+    SpValue temp;
+
+    temp.setObject(list);
+    list = new SpAppendedList(temp, second, environ);
+    return list;
+  }
+}
+
+SpValue& SpAppendedList::value()
+{
+  //  static SpValue result;
+  SpValue result;
+
+  pushCurrentNS(environ);
+  try {
+    SpList* list = first.asList();
+    result = list->value();
+  }catch(...){
+    popCurrentNS();
+    throw;
+  }
+  popCurrentNS();
+  //  return result;
+  return SpValueResult(result);
+}
+
+//
+// Soopy List Comprehension Class
+//
+
+// class SpListCreator
+SpValue& SpListCreator::toString()
+{
+    SpString* str;
+    SpValue v;
+
+    str = new SpString();
+    *str += symbol.toString();
+    *str += " <- ";
+    *str += list.toString();
+
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+
+// class SpListCompre
+SpListCompre::SpListCompre(SpValue& cur_val, SpValue& e, SpValue& c, SpValue& f, SpValueVector* v, SpValue& env)
+     : SpListCompreBase(cur_val, e, c, f, env)
+{
+  // set cur_creators
+  SpValueVector::iterator it;
+  it = v->begin();
+  for(; it != v->end(); it++){
+    cur_creators.push_back(*it);
+  }
+}
+
+/*
+int SpListCompre::length()
+{
+  int len = 0;
+  SpTuple* tpl = dynamic_cast<SpTuple*>(creators.getObject());
+  SpValueVector::iterator it;
+  it = tpl->begin();
+  for(; it != tpl->end(); it++){
+    SpListCreator* cre  = dynamic_cast<SpListCreator*>(it->getObject());
+    SpList*        list = cre->list.asList();
+    len += list->length();
+  }
+  return len;
+}
+*/
+
+// \82Ð\82Æ\82Â\8e\9f\82ÌListCompre\90\90¬\97p\82Ì\83p\83\89\83\81\81[\83^\82ð\8cv\8eZ\82·\82é
+//   \83\8a\83X\83g\82Ì\8fI\82í\82è\82Ì\82Æ\82«\82É\82Ífalse\82ð\95Ô\82·
+bool SpListCompre::calc_next_param(SpValue& org, SpValueVector* cur)
+{
+  SpValue temp;
+  SpTuple* tpl = dynamic_cast<SpTuple*>(org.getObject());
+  SpValueVector::reverse_iterator it1;
+  SpValueVector::reverse_iterator it2;
+  it1 = tpl->rbegin();
+  it2 = cur->rbegin();
+/*
+  if(tpl->length() != cur->size()){
+    throw SpException("System error: creator length not match with original (ListCompre)");
+  }
+*/
+  for(; ; it1++, it2++){
+    if(it2 == cur->rend()){
+      return false;
+    }
+    SpListCreator* cre  = dynamic_cast<SpListCreator*>(it2->getObject());
+    SpList*        list = cre->list.asList();
+    SpList*        next = list->next();
+    temp.setObject(next);
+    if(next == NULL){
+      *it2 = *it1;
+    }else{
+      //it2->setNewObject(new SpListCreator(cre->symbol, temp));
+      SpListCreator* ptr = new SpListCreator(cre->symbol, temp);
+      it2->setNewObject(ptr);
+      ptr->list = temp;
+      break;
+    }
+  }
+
+  return true;
+}
+
+// \97^\82¦\82ç\82ê\82½\83p\83\89\83\81\81[\83^\82Å\90\90¬\82µ\82½\92l\82ªfilters\82ð\92Ê\82é\82©\83e\83X\83g\82·\82é
+//   filters\82ð\92Ê\82ç\82È\82¢\82Æ\82«\82É\82Ífalse\82ð\95Ô\82·
+//   \8cv\8eZ\82µ\82½\92l\82Íresult\82É\95Ô\82·
+bool SpListCompre::calc_value(SpValue& result, SpValue& e, SpValue& f, SpValueVector* v, SpValue& env)
+{
+  bool boolean = true;
+  SpNameSpace* ns = new SpNameSpace(env);
+  SpValue v_ns(ns);
+
+  pushCurrentNS(v_ns);
+  try {
+    // List\82Ì\90\90¬\8e®(ex. x <- [1..3])\82©\82ç\95Ï\90\94\82É\92l\82ð\83Z\83b\83g\82·\82é
+    SpValueVector::iterator it;
+    it = v->begin();
+    for(; it != v->end(); it++){
+      SpValue temp;
+      SpListCreator* cre  = dynamic_cast<SpListCreator*>(it->getObject());
+      SpList*        list = cre->list.asList();
+      temp = list->value();
+      ns->internVar(cre->symbol, temp);
+    }
+
+    // filter \82Å check
+    if(!f.isNil()){
+      SpTuple* filter_list = f.asTuple();
+      it = filter_list->begin();
+      for(; it != filter_list->end(); it++){
+        SpValue p;
+        p = it->eval();
+        if(!p.isTrue()){
+          boolean = false;
+          break;
+        }
+      }
+    }
+
+    if(boolean){
+      result = e.eval();
+    }
+
+  }catch(...){
+    popCurrentNS();
+    throw;
+  }
+  popCurrentNS();
+
+  return boolean;
+}
+
+SpListCompre* SpListCompre::Create(SpValue& e, SpValue& c, SpValue& f)
+{
+  // \8c\8b\89Ê\82Æ\82µ\82Ä\8bó\83\8a\83X\83g\82Ì\8fê\8d\87\81ANull\82ð\95Ô\82·
+  //   ListCreator::list\82ª\82Ð\82Æ\82Â\82Å\82àNil\82Ì\82Æ\82«\82ÍNULL
+  SpTuple* tpl = dynamic_cast<SpTuple*>(c.getObject());
+  SpValueVector::iterator it;
+  it = tpl->begin();
+  for(; it != tpl->end(); it++){
+    SpListCreator* cre = dynamic_cast<SpListCreator*>(it->getObject());
+    cre->list = cre->expr.eval();
+    if(cre->list.isNil()){
+      return NULL;
+    }
+    if(!cre->list.isList()){
+      throw SpException("not list (list comprehension)");
+    }
+  }
+  return calc_next_list(e, c, f, getCurrentNS());
+}
+
+SpListCompre* SpListCompre::calc_next_list(SpValue& e, SpValue& c, SpValue& f, SpValue& env, SpValueVector* v)
+{
+  // \8c\8b\89Ê\82Æ\82µ\82Ä\8bó\83\8a\83X\83g\82Ì\8fê\8d\87\81ANull\82ð\95Ô\82·
+  //   Head\82Ì\92l\82ð\82 \82ç\82©\82\82ß\8cv\8eZ\82µ\82Ä\82¨\82­
+  //   \8b\81\82ß\82½\92l\82ª\81Afilter\82ð\92Ê\82ç\82È\82¢\82Æ\82«\82É\82Í
+  //   \82Â\82¬\82Ì\92l\82ð\8b\81\82ß\82é\81B\88È\89º\81A\93¯\97l\82É\8cJ\82è\95Ô\82·\81B
+  //   \8dÅ\8fI\93I\82É\81Afilter\82ð\92Ê\82é\92l\82ª\91\8dÝ\82µ\82È\82©\82Á\82½\8fê\8d\87\82É\82ÍNULL\82ð\95Ô\82·
+  SpListCompre* result;
+  SpValue val;
+  SpValue exp = e;
+  SpValue cre = c;
+  SpValue fil = f;
+  SpValueVector* vec;
+
+  if(v == NULL){
+    vec = new SpValueVector;
+    copy_tuple_to_valVec(vec, c);
+  }else{
+    vec = v;
+  }
+
+  bool hasValue = calc_value(val, exp, fil, vec, env);
+  while(!hasValue){
+    if(calc_next_param(cre, vec) == false){ // \8e\9f\82ª\82È\82¢\82Æ\82«\81i\83\8a\83X\83g\82Ì\8fI\82í\82è\81j
+      result = NULL;
+      goto end;
+    }
+    hasValue = calc_value(val, exp, fil, vec, env);
+  }
+  result = new SpListCompre(val, exp, cre, fil, vec, env);
+
+end:
+  if(v == NULL){
+    delete vec;
+  }
+  return result;
+}
+
+void SpListCompre::copy_tuple_to_valVec(SpValueVector* dst, SpValue& src)
+{
+  SpTuple* tpl = dynamic_cast<SpTuple*>(src.getObject());
+  SpValueVector::iterator it;
+  it = tpl->begin();
+  for(; it != tpl->end(); it++){
+    dst->push_back(*it);
+  }
+}
+
+void SpListCompre::copy_valVec_to_valVec(SpValueVector* dst, SpValueVector* src)
+{
+  SpValueVector::iterator sit;
+  sit = src->begin();
+  for(; sit != src->end(); sit++){
+    dst->push_back(*sit);
+  }
+}
+
+SpList* SpListCompre::next()
+{
+  SpValueVector* vec;
+
+  vec = new SpValueVector;
+  copy_valVec_to_valVec(vec, &cur_creators);
+  if(calc_next_param(creators, vec) == false){ // \8e\9f\82ª\82È\82¢\82Æ\82«\81i\83\8a\83X\83g\82Ì\8fI\82í\82è\81j
+    delete vec;
+    return NULL;
+  }
+
+  SpListCompre* result;
+  result = calc_next_list(expr, creators, filters, environ, vec);
+  delete vec;
+  return result;
+}
+
+
+// class SpListcompreCreator
+SpValue& SpListCompreCreator::eval()
+{
+  SpListCompre* list = SpListCompre::Create(expr, creators, filters);
+  if(list == NULL){
+    return NilObject;
+  }
+  //  static SpValue result;
+  //  result.setObject(list);
+  //  return result;
+  SpValue result;
+  result.setObject(list);
+  //  return SpObjectResult(list);
+  return SpValueResult(result);
+}
+
+SpValue& SpListCompreCreator::toString()
+{
+  SpString* str;
+
+  str = new SpString();
+  *str = "<list comprehension creator>";
+  //  static SpValue s;
+  //  s.setNewObject(str);
+  //  return s;
+  return SpObjectResult(str);
+}
+
+
+//
+// list comprehension (diagonalising)
+//   ex. [(x, y) // x <- [1..], y <- [1..]]
+//
+/*
+ * \91Î\8ap\90üZF\8e®\82ð\8eÀ\91\95\82·\82é\82½\82ß\82Ì\8dl\8e@
+ *
+
+\83\8a\83X\83g\82ª\82Q\82Â\82Ì\8fê\8d\87([ expr // x <- [0..3], y <- [0..3], ......])
+
+(0, 0)                      x + y = 0,    x >= 0, y >= 0, x <= 3, y <= 3
+(1, 0) (0, 1)               x + y = 1,    x >= 0, y >= 0, x <= 3, y <= 3
+(2, 0) (1, 1) (0, 2)        x + y = 2,    x >= 0, y >= 0, x <= 3, y <= 3
+(3, 0) (2, 1) (1, 2) (0, 3) x + y = 3,    x >= 0, y >= 0, x <= 3, y <= 3
+(3, 1) (2, 2) (1, 3)        x + y = 4,    x >= 0, y >= 0, x <= 3, y <= 3
+(3, 2) (2, 3)               x + y = 5,    x >= 0, y >= 0, x <= 3, y <= 3
+(3, 3)                      x + y = 6,    x >= 0, y >= 0, x <= 3, y <= 3
+
+
+\83\8a\83X\83g\82ª\82R\82Â\82Ì\8fê\8d\87([ expr // x <- [0..3], y <- [0..3], z <- [0..3], ......])
+
+(0, 0, 0)                      x + y + z = 0
+(1, 0, 0) (0, 1, 0) (0, 0, 1)  x + y + z = 1
+(2, 0, 0) (1, 1, 0) (1, 0, 1) (0, 2, 0) (0, 1, 1) (0, 0, 2)  x + y + z = 2
+.....
+(3, 3, 3)                      x + y + z = 9
+
+
+  \83\8a\83X\83g\90\90¬\8e®\81ix <- [1..] \82Ý\82½\82¢\82È\82â\82Â\81j\82ª\82\8e\8cÂ\82Ì\82Æ\82«\81A
+  \8ae\90\90¬\8e®\82Ì\89½\94Ô\96Ú\82Ì\92l\82ð\8eg\97p\82·\82é\82©\82Í,
+
+    A1 + A2 + A3 + ... + An = 0
+    A1 + A2 + A3 + ... + An = 1
+    A1 + A2 + A3 + ... + An = 2
+    A1 + A2 + A3 + ... + An = 3
+       ......
+    A1 + A2 + A3 + ... + An = \8dÅ\91å\92l
+
+  \82Ì\95û\92ö\8e®\82ð\96\9e\82½\82·\8e©\91R\90\94A1\82©\82çAn\82Ü\82Å\82ð\8f\87\82É\82·\82×\82Ä\8b\81\82ß\82ê\82Î\82æ\82¢\81B
+  (A1 \82©\82ç An \82Í\8ae\90\90¬\8e®\82Ì\89½\94Ô\96Ú\82©\82ð\95\\82·\81j)
+
+  \95û\92ö\8e®\82Ì\8dÅ\91å\92l\82Í\81u\8ae\83\8a\83X\83g\82Ì\92·\82³\82Ì\98a\81v\81|\81u\90\90¬\8e®\82Ì\90\94\81v\82É\93\99\82µ\82¢\81B
+  \82½\82¾\82µ\96³\8cÀ\83\8a\83X\83g\82ª\8aÜ\82Ü\82ê\82é\8fê\8d\87\82É\82Í\81A\8dÅ\91å\92l\82»\82Ì\82à\82Ì\82ª\91\8dÝ\82µ\82È\82¢\81B
+
+  \8eÀ\8dÛ\82Ì\83A\83\8b\83S\83\8a\83Y\83\80\93\99\81i\83A\83\8b\83S\83\8a\83Y\83\80\82Í\8eÀ\91\95\82µ\82â\82·\82¢\82à\82Ì\82ð\8dÌ\97p\82·\82é\81B\82½\82Æ\82¦\81A\82¢\82Ü\82¢\82¿\91Î\8ap\90ü\82Á\82Û\82­\82È\82­\82È\82Á\82½\82Æ\82µ\82Ä\82à\81j
+  \81@\89E\95Ó\82ªN\82Ì\82Æ\82«\81A
+  \81@\81@\82P\81DA1\82ðN\81A\91¼\82ð\82O\82É\82·\82é\81B
+  \81@\81@\82Q\81DA1 = A1 - 1, A2 = A2 + 1  \81i\82Ç\82±\82©\82ª\82P\8c¸\82é\82Æ\81A\82Ù\82©\82Ì\82Ç\82±\82©\82ª\82P\91\9d\82¦\82é\81j
+  \81@\81@\82R\81DA2 = A2 - 1, A3 = A3 + 1
+  \81@\81@\81@\81@\81@\88È\89º\81AAn\82Ü\82Å\93¯\97l\82É\8cJ\82è\95Ô\82·\81B
+  \81@\81@\82S\81D(A1 - 1) \82ª\82O\82Å\82È\82¢\8fê\8d\87\81A\82Q\82Ö
+  \81@\81@\82T\81DA1 = 0, A2\82ðN\81AA2\81`An\82ð\82O\82É\82·\82é\81B
+  \81@\81@\82U\81DA2 = A2 - 1, A3 = A3 + 1
+  \81@\81@\81@\81@\81@\88È\89º\81AAn\82Ü\82Å\93¯\97l\82É\8cJ\82è\95Ô\82·\81B
+  \81@\81@\82V\81DAn\82ªN\82É\82È\82é\82Ü\82Å\93¯\97l\82É\8cJ\82è\95Ô\82·\81B
+  \81@\81@\81i\82±\82ê\82Å\82¢\82¢\82Ì\82©\81H\81H\81j
+
+*/
+
+bool SpListCompreDiag::next_rval(int  max,
+                                 int& idx,
+                                 IntVector& rval,
+                                 IntVector& base,
+                                 IntVector& move,
+                                 int depth,
+                                 int* dimension)
+{
+  rval[idx]++;
+  // \83\8a\83X\83g\82Ì\8fI\82í\82è\82Ì\82Æ\82«\82É\82Í\81Afalse\82ð\95Ô\82·\81B
+  if((max >= 0) && (rval[idx] > max)){
+    return false;
+  }
+  base[idx] = 0;
+  move[idx] = 0;
+  dimension[0] = rval[idx];
+  for(int i=1; i < depth; i++){
+    dimension[i] = 0;
+  }
+  return true;
+}
+
+bool SpListCompreDiag::dec_idx(int  max,
+                               int& idx,
+                               IntVector& rval,
+                               IntVector& base,
+                               IntVector& move,
+                               int depth,
+                               int* dimension)
+{
+  while(idx > 0){
+    idx--;
+    if(dimension[base[idx]] > 0){
+      dimension[base[idx]]--;
+      move[idx] = base[idx] + 1;
+      dimension[move[idx]] = rval[idx] - dimension[base[idx]];
+      for(int i=move[idx]+1; i < depth; i++){
+        dimension[i] = 0;
+      }
+      if((idx < (depth - 2)) && (dimension[move[idx]] > 1)){
+        idx++;
+        rval[idx] = dimension[move[idx-1]];
+        base[idx] = move[idx-1];
+        move[idx] = base[idx];
+      }
+      break;
+    }else if(idx <= 0){  // dimension[base[idx]] <= 0
+      if(next_rval(max, idx, rval, base, move, depth, dimension) == false){
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+bool SpListCompreDiag::calc_next_param(IntVector& lengths,
+                                       int  max,
+                                       int& idx,
+                                       IntVector& rval,
+                                       IntVector& base,
+                                       IntVector& move,
+                                       int depth,
+                                       int* dimension)
+{
+  bool loop = true;
+
+  if(rval[idx] == 0){
+    return next_rval(max, idx, rval, base, move, depth, dimension);
+  }
+  while(loop){
+    if((move[idx] + 1) < depth){
+      dimension[move[idx]]--;
+      move[idx]++;
+      dimension[move[idx]]++;
+    }else{  // (move[idx] + 1) >= depth
+      if(dimension[base[idx]] == 1){
+        dimension[base[idx]] = 0;
+        base[idx]++;
+        if(base[idx] < depth){
+          move[idx] = base[idx];
+          dimension[base[idx]] = rval[idx];
+          for(int i=base[idx]+1; i < depth; i++){
+            dimension[i] = 0;
+          }
+        }else{ // base[idx] >= depth
+          if(next_rval(max, idx, rval, base, move, depth, dimension) == false){
+            return false;
+          }
+        }
+      }else if(dimension[base[idx]] == 0){
+        if(idx > 0){
+          if(dec_idx(max, idx, rval, base, move, depth, dimension) == false){
+            return false;
+          }
+        }else{
+          if(next_rval(max, idx, rval, base, move, depth, dimension) == false){
+            return false;
+          }
+        }
+      }else{ // dimension[base[idx]] != 1 or 0
+        if(base[idx] < (depth - 1)){
+          dimension[base[idx]]--;
+          move[idx] = base[idx] + 1;
+          dimension[move[idx]] = rval[idx] - dimension[base[idx]];
+          for(int i=move[idx]+1; i < depth; i++){
+            dimension[i] = 0;
+          }
+          if((idx < (depth - 2)) && (dimension[move[idx]] > 1)){
+            idx++;
+            rval[idx] = dimension[move[idx-1]];
+            base[idx] = move[idx-1];
+            move[idx] = base[idx];
+          }
+        }else{
+          if(idx > 0){
+            if(dec_idx(max, idx, rval, base, move, depth, dimension) == false){
+              return false;
+            }
+          }else{ // idx <= 0
+            if(next_rval(max, idx, rval, base, move, depth, dimension) == false){
+              return false;
+            }
+          }
+        }
+      }
+    }
+    // \8ae\83\8a\83X\83g\82Ì\92·\82³\82ð\92´\82¦\82Ä\82È\82¢\82©\83`\83F\83b\83N
+    for(int i=0; i < depth; i++){
+      loop = false;
+      if((lengths[i] >= 0) && (dimension[i] >= lengths[i])){
+        loop = true;
+        break;
+      }
+    }
+  }
+  return true;
+}
+
+// \97^\82¦\82ç\82ê\82½\83p\83\89\83\81\81[\83^\82Å\90\90¬\82µ\82½\92l\82ªfilters\82ð\92Ê\82é\82©\83e\83X\83g\82·\82é
+//   filters\82ð\92Ê\82ç\82È\82¢\82Æ\82«\82É\82Ífalse\82ð\95Ô\82·
+//   \8cv\8eZ\82µ\82½\92l\82Íresult\82É\95Ô\82·
+bool SpListCompreDiag::calc_value(SpValue& result, SpValue& e, SpValue& c, SpValue& f, SpValue& env, int* dimension)
+{
+  bool boolean = true;
+  SpNameSpace* ns = new SpNameSpace(env);
+  SpValue v_ns(ns);
+  SpTuple* tpl = c.asTuple();
+
+  pushCurrentNS(v_ns);
+  try {
+    // List\82Ì\90\90¬\8e®(ex. x <- [1..3])\82©\82ç\95Ï\90\94\82É\92l\82ð\83Z\83b\83g\82·\82é
+    SpValueVector::iterator it;
+    it = tpl->begin();
+    for(int i=0; it != tpl->end(); it++, i++){
+      SpValue temp;
+      SpListCreator* cre  = dynamic_cast<SpListCreator*>(it->getObject());
+      SpList*        list = cre->list.asList();
+      temp = list->nth(dimension[i])->value();
+      ns->internVar(cre->symbol, temp);
+    }
+
+    // filter \82Å check
+    if(!f.isNil()){
+      SpTuple* filter_list = f.asTuple();
+      it = filter_list->begin();
+      for(; it != filter_list->end(); it++){
+        SpValue p;
+        p = it->eval();
+        if(!p.isTrue()){
+          boolean = false;
+          break;
+        }
+      }
+    }
+
+    if(boolean){
+      result = e.eval();
+    }
+
+  }catch(...){
+    popCurrentNS();
+    throw;
+  }
+  popCurrentNS();
+
+  return boolean;
+}
+
+SpListCompreDiag* SpListCompreDiag::calc_next_list(IntVector& lengths,
+                                                   SpValue& e,
+                                                   SpValue& c,
+                                                   SpValue& f,
+                                                   SpValue& env,
+                                                   int  max,
+                                                   int& idx,
+                                                   IntVector& rval,
+                                                   IntVector& base,
+                                                   IntVector& move,
+                                                   int  depth,
+                                                   int* dimension)
+{
+  // \8c\8b\89Ê\82Æ\82µ\82Ä\8bó\83\8a\83X\83g\82Ì\8fê\8d\87\81ANull\82ð\95Ô\82·
+  //   Head\82Ì\92l\82ð\82 \82ç\82©\82\82ß\8cv\8eZ\82µ\82Ä\82¨\82­
+  //   \8b\81\82ß\82½\92l\82ª\81Afilter\82ð\92Ê\82ç\82È\82¢\82Æ\82«\82É\82Í
+  //   \82Â\82¬\82Ì\92l\82ð\8b\81\82ß\82é\81B\88È\89º\81A\93¯\97l\82É\8cJ\82è\95Ô\82·\81B
+  //   \8dÅ\8fI\93I\82É\81Afilter\82ð\92Ê\82é\92l\82ª\91\8dÝ\82µ\82È\82©\82Á\82½\8fê\8d\87\82É\82ÍNULL\82ð\95Ô\82·
+  SpListCompreDiag* result;
+  SpValue val;
+  SpValue exp = e;
+  SpValue cre = c;
+  SpValue fil = f;
+  int* ptr;
+
+  if(dimension == NULL){
+    ptr = new int[depth];
+    for(int i=0; i < depth; i++){
+      ptr[i] = 0;
+    }
+  }else{
+    ptr = dimension;
+  }
+
+  bool hasValue = calc_value(val, exp, cre, fil, env, ptr);
+  while(!hasValue){
+    if(calc_next_param(lengths, max, idx, rval, base, move, depth, ptr) == false){ // \8e\9f\82ª\82È\82¢\82Æ\82«\81i\83\8a\83X\83g\82Ì\8fI\82í\82è\81j
+      if(dimension == NULL){
+        delete[] ptr;
+      }
+      return NULL;
+    }
+    hasValue = calc_value(val, exp, cre, fil, env, ptr);
+  }
+  result = new SpListCompreDiag(val, exp, cre, fil, env, max, idx, rval, base, move, depth, ptr);
+  return result;
+}
+
+void SpListCompreDiag::calcLength()
+{
+  //  len = 1;
+  int len = 1;
+  SpTuple* tpl = dynamic_cast<SpTuple*>(creators.getObject());
+  SpValueVector::iterator it;
+  it = tpl->begin();
+  for(; it != tpl->end(); it++){
+    SpListCreator* cre  = dynamic_cast<SpListCreator*>(it->getObject());
+    SpList*        list = cre->list.asList();
+    try{
+      int j;
+      j = list->length();
+      if(len >= 0){
+        len *= j;
+      }
+      lengths.push_back(j);
+    }catch(SpNoLengthException& e){
+      len = -1;
+      lengths.push_back(-1);
+    }
+  }
+}
+
+SpListCompreDiag* SpListCompreDiag::Create(SpValue& e, SpValue& c, SpValue& f)
+{
+  // \8c\8b\89Ê\82Æ\82µ\82Ä\8bó\83\8a\83X\83g\82Ì\8fê\8d\87\81ANull\82ð\95Ô\82·
+  //   ListCreator::list\82ª\82Ð\82Æ\82Â\82Å\82àNil\82Ì\82Æ\82«\82ÍNULL
+  int max  = 0;
+  int index = 0;
+  IntVector rval;
+  IntVector base;
+  IntVector move;
+  IntVector lens;
+
+  SpTuple* tpl = dynamic_cast<SpTuple*>(c.getObject());
+  SpValueVector::iterator it;
+  it = tpl->begin();
+  for(; it != tpl->end(); it++){
+    SpListCreator* cre = dynamic_cast<SpListCreator*>(it->getObject());
+    cre->list = cre->expr.eval();
+    if(cre->list.isNil()){
+      return NULL;
+    }
+    if(!cre->list.isList()){
+      throw SpException("not list (list comprehension //)");
+    }
+    SpList* ptr = cre->list.asList();
+    int len;
+    try{
+      len = ptr->length();
+      if(max >= 0){
+        max += len;
+      }
+      lens.push_back(len);
+    }catch(SpNoLengthException& e){
+      max = -1;
+      lens.push_back(len);
+    }
+  }
+  if(max >= 0){
+    max -= tpl->length();
+  }
+  int i = tpl->length();
+  clearIntVector(rval, i);
+  clearIntVector(base, i);
+  clearIntVector(move, i);
+  return calc_next_list(lens, e, c, f, getCurrentNS(), max, index, rval, base, move, tpl->length());
+}
+
+SpList* SpListCompreDiag::next()
+{
+  IntVector rval;
+  IntVector base;
+  IntVector move;
+  int idx = index;
+  int* ptr;
+
+  copyIntVector(rval, rvalue);
+  copyIntVector(base, base_pos);
+  copyIntVector(move, move_pos);
+  ptr = new int[depth];
+  for(int i=0; i < depth; i++){
+    ptr[i] = dim[i];
+  }
+  if(calc_next_param(lengths, max, idx, rval, base, move, depth, ptr) == false){ // \8e\9f\82ª\82È\82¢\82Æ\82«\81i\83\8a\83X\83g\82Ì\8fI\82í\82è\81j
+    delete[] ptr;
+    return NULL;
+  }
+
+  SpListCompreDiag* result;
+  result = calc_next_list(lengths, expr, creators, filters, environ, max, idx, rval, base, move, depth, ptr);
+  return result;
+}
+
+void SpListCompreDiag::clearIntVector(IntVector& dst, int len)
+{
+  for(int i=0; i < len; i++){
+    dst.push_back(0);
+  }
+}
+
+void SpListCompreDiag::copyIntVector(IntVector& dst, IntVector& src)
+{
+  IntVector::iterator it;
+  it = src.begin();
+  for(; it < src.end(); it++){
+    dst.push_back(*it);
+  }
+}
+
+// class SpListCompreDiagCreator
+SpValue& SpListCompreDiagCreator::eval()
+{
+  SpListCompreDiag* list = SpListCompreDiag::Create(expr, creators, filters);
+  if(list == NULL){
+    return NilObject;
+  }
+  //  static SpValue result;
+  //  result.setObject(list);
+  //  return result;
+  SpValue result;
+  result.setObject(list);
+  //  return SpObjectResult(list);
+  return SpValueResult(result);
+}
+
+SpValue& SpListCompreDiagCreator::toString()
+{
+  SpString* str;
+
+  str = new SpString();
+  *str = "<list comprehension(diagonalising) creator>";
+  //  static SpValue s;
+  //  s.setNewObject(str);
+  //  return s;
+  return SpObjectResult(str);
+}
+
+
+/*
+ * class SpPatternWColon
+ */
+SpValue& SpPatternWColon::toString()
+{
+    SpValue v1 = head.toString();
+    SpValue v2 = tail.toString();
+    SpString* s1 = dynamic_cast<SpString*>(v1.getObject());
+    SpString* s2 = dynamic_cast<SpString*>(v2.getObject());
+    *s1 += "::";
+    *s1 += *s2;
+    SpString* s = new SpString(s1->toCStringWithEncoder());
+    //    static SpValue v;
+    //    v.setNewObject(s);
+    //    return v;
+    return SpObjectResult(s);
+}
+
+bool SpPatternWColon::match(SpValue&, SpValue& val, SpNameSpace* ns)
+{
+    SpValue temp;
+    if(!val.isList()){
+        return false;
+    }
+    // val is list
+    SpList* ptr = dynamic_cast<SpList*>(val.getObject());
+    //if(!head.match(ptr->value(), ns)){
+    temp = ptr->value();
+    if(!head.match(temp, ns)){
+        return false;
+    }
+    // match head
+    //return tail.match(ptr->nextList(), ns);
+    temp = ptr->nextList();
+    return tail.match(temp, ns);
+}
+
+/*
+ * class SpPatternAt
+ */
+SpValue& SpPatternAt::toString()
+{
+    SpValue v1 = list1.toString();
+    SpValue v2 = list2.toString();
+    SpString* s1 = dynamic_cast<SpString*>(v1.getObject());
+    SpString* s2 = dynamic_cast<SpString*>(v2.getObject());
+    *s1 += "@";
+    *s1 += *s2;
+    SpString* s = new SpString(s1->toCStringWithEncoder());
+    //    static SpValue v;
+    //    v.setNewObject(s);
+    //    return v;
+    return SpObjectResult(s);
+}
+
+bool SpPatternAt::match(SpValue&, SpValue& val, SpNameSpace* ns)
+{
+    if(!val.isList()){
+        return false;
+    }
+    // val is list
+    SpValue l1 = list1;
+    SpValue l2 = val;
+    while(l2.isList()){
+        SpList* ptr = dynamic_cast<SpList*>(l1.getObject());
+        SpList* ptr2 = dynamic_cast<SpList*>(l2.getObject());
+
+        //if(!ptr->value().match(ptr2->value(), ns)){
+        SpValue temp, temp2;
+        temp = ptr->value();
+        temp2 = ptr2->value();
+        if(!temp.match(temp2, ns)){
+            return false;
+        }
+
+        l1 = ptr->nextList();
+        l2 = ptr2->nextList();
+        if(l1.isNil()){
+            return list2.match(l2,ns);
+        }
+    }
+    return false;
+}
+
diff --git a/src/Load.cpp b/src/Load.cpp
new file mode 100644 (file)
index 0000000..4f6a9dc
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Load.cpp,v 1.25 2007/01/29 11:46:16 randy Exp $
+ */
+
+#ifdef __WIN32__
+#include <io.h>
+#else
+#include <unistd.h>
+#include <stdio.h>
+#endif
+
+#include "soopy.h"
+
+SpValue program;
+
+int openWithLibPaths(ifstream& fin, const char* fname)
+{
+    if(access(fname, 04) == 0){
+        fin.open(fname);
+        if(fin.fail()){
+            return -1; // failure
+        }
+    }else{
+        char* name = new char[strlen(fname) + MaxLibPathBuffer];
+        for(int i=0; i < NumberOfLibPath; i++){
+#ifdef __WIN32__
+            sprintf(name, "%s\\%s", LibPaths[i], fname);
+#else
+            sprintf(name, "%s/%s", LibPaths[i], fname);
+#endif
+            if(access(name, 04) == 0){
+                fin.open(name);
+                if(!fin.fail()){
+                    delete name;
+                    return 1;
+                }else{
+                    break; // failure
+                }
+            }
+        }
+        delete name;
+        return -1; // failure
+    }
+    return 1;
+}
+
+extern int yyparse();
+
+//int load(const char* fname)
+SpValue& load(const char* fname)
+{
+    SpValue evaled;
+    int result;
+    int status = 1;
+    char old_name[SP_NAME_MAX];
+    unsigned int old_line;
+    ifstream fin;
+
+    if(openWithLibPaths(fin, fname) < 0){
+        cerr << "can't open file '" << fname  << "'" << endl;
+//        return -1;
+        return NilObject;
+    }
+
+    strcpy(old_name, Filename);
+    setFilename((char*)fname);
+    old_line = lineno;
+    StreamReader* reader = new StreamReader(&fin);
+    JapaneseReadDecoder* encoder = new JapaneseReadDecoder(reader);
+    SpValue taker(encoder);
+    ReadEncoder* old_lexer_encoder = Lexer::getReadEncoder();
+    Lexer::setReadEncoder(encoder);
+    try{
+      while(status >= 0){
+          try{
+              result = yyparse();
+              if(result == 0){
+                  // status = 1;
+                  break;
+              }
+              evaled = program.eval();
+          }
+          catch(const SpException& e){
+              cout << "Uncaught exception: " << e.what() << endl;
+              status = -1;
+          }
+          catch(const exception& e){
+              cout << "Exception: " << e.what() << endl;
+              status = -2;
+          }
+          catch(...){
+              cout << "Unknown exception" << endl;
+              status = -3;
+          }
+      }
+    }catch(...){
+      //status = -1;
+      evaled = NilObject;
+    }
+    setFilename(old_name);
+    lineno = old_line;
+    Lexer::setReadEncoder(old_lexer_encoder);
+
+//    return status;
+  return SpValueResult(evaled);
+}
+
+int interaction(bool p)
+{
+    int result, status;
+
+    while(true){
+        if(p){
+            *spout << "\n> ";
+        }
+        try{
+            result = yyparse();
+            if(result == 0){
+                if(p){
+                    *spout << "bye.\n";
+                }
+                status = 1;
+                break;
+            }
+            SpValue evaled = program.eval();
+            if(p){
+                *spout << evaled;
+            }
+        }
+        catch(const SpException& e){
+            cout << "Uncaught exception: " << e.what() << endl;
+        }
+        catch(const exception& e){
+            cout << "Exception: " << e.what() << endl;
+        }
+        catch(...){
+            cout << "Unknown exception" << endl;
+            status = -1;
+            break;
+        }
+    }
+    return status;
+}
+
diff --git a/src/Loop.cpp b/src/Loop.cpp
new file mode 100644 (file)
index 0000000..2370446
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Loop.cpp,v 1.10 2004/03/25 13:25:48 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * class SpLoop
+ */
+
+SpValue& SpLoop::eval()
+{
+    //static SpValue result;
+    SpValue result;
+    SpValue temp;
+    bool stepp  = !step.isNil();
+    bool whilep = !while_cond.isNil();
+    bool untilp = !until_cond.isNil();
+    bool body_is_list = body.isList();
+    if(!from.isNil()){
+        if(from.isList()){
+            SpValue L = from;
+            while(L.isList()){
+                SpList* list = dynamic_cast<SpList*>(L.getObject());
+                //temp = list->value().eval();
+                temp = list->value();
+                temp = temp.eval();
+                L = list->nextList();
+            }
+        }else{
+            temp = from.eval();
+        }
+    }
+    while(true){
+start:
+        // check while
+        if(whilep){
+            SpValue cond = while_cond.eval();
+            if(cond.isFalse()){
+                break;
+            }
+        }
+        // check until
+        if(untilp){
+            SpValue cond = until_cond.eval();
+            if(cond.isTrue()){
+                break;
+            }
+        }
+        // do body
+        try {
+            if(body_is_list){
+                SpValue L = body;
+                while(L.isList()){
+                    SpList* list = dynamic_cast<SpList*>(L.getObject());
+                    SpValue v = list->value();
+                    result = v.eval();
+                    L = list->nextList();
+                }
+            }else{
+                result = body.eval();
+            }
+        }catch(SpExitException& e){
+            if(e.symbol.isNil()){
+                result = e.val;
+            }else if(symbol == e.symbol){
+                result = e.val;
+            }else{
+                throw;
+            }
+            break;
+        }catch(SpNextException& e){
+            if(e.symbol.isNil()){
+                goto start;
+            }else if(symbol == e.symbol){
+                goto start;
+            }
+            throw;
+        }
+        // check variant
+        // check invariant
+        // step
+        if(stepp){
+            if(step.isList()){
+                SpValue L = step;
+                while(L.isList()){
+                    SpList* list = dynamic_cast<SpList*>(L.getObject());
+                    temp = list->value();
+                    temp = temp.eval();
+                    L = list->nextList();
+                }
+            }else{
+                temp = step.eval();
+            }
+        }
+    }
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpLoop::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str += "loop ";
+    if(!symbol.isNil()){
+        *str += symbol.toString();
+    }
+    *str += " {\n";
+    if(!while_cond.isNil()){
+        *str += "  while: ";
+        *str += while_cond;
+        *str += "\n";
+    }
+    if(!until_cond.isNil()){
+        *str += "  until: ";
+        *str += until_cond;
+        *str += "\n";
+    }
+    if(!body.isNil()){
+        *str += "  do: ";
+        *str += body;
+        *str += "\n";
+    }
+    if(!variant.isNil()){
+        *str += "  variant: ";
+        *str += variant;
+        *str += "\n";
+    }
+    if(!invariant.isNil()){
+        *str += "  invariant: ";
+        *str += invariant;
+        *str += "\n";
+    }
+
+    *str += "}";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class SpExit
+ */
+
+SpValue& SpExit::eval()
+{
+    //    static SpValue val;
+    SpValue val;
+    val = expr.eval();
+    SpValueResult(val);
+    throw SpExitException(symbol, val, "uncaught exit");
+}
+
+SpValue& SpExit::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    if(!symbol.isNil()){
+        *str += symbol;
+        *str += ".";
+    }
+    *str += "exit";
+    if(!expr.isNil()){
+        *str += "(";
+        *str += expr;
+        *str += ")";
+    }
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * class SpNext
+ */
+
+SpValue& SpNext::eval()
+{
+    throw SpNextException(symbol, "uncaught next");
+}
+
+SpValue& SpNext::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    if(!symbol.isNil()){
+        *str += symbol;
+        *str += ".";
+    }
+    *str += "next";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
diff --git a/src/Makefile b/src/Makefile
new file mode 100644 (file)
index 0000000..88e6cb9
--- /dev/null
@@ -0,0 +1,630 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.  Generated from Makefile.in by configure.
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+
+pkgdatadir = $(datadir)/soopy
+pkglibdir = $(libdir)/soopy
+pkgincludedir = $(includedir)/soopy
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+bin_PROGRAMS = soopy$(EXEEXT)
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(srcdir)/../depcomp \
+       $(srcdir)/../install-sh $(srcdir)/../missing \
+       $(srcdir)/../ylwrap $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in $(srcdir)/config.h.in \
+       $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+       parser.cpp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_soopy_OBJECTS = Array.$(OBJEXT) Assign.$(OBJEXT) Base64.$(OBJEXT) \
+       Bool.$(OBJEXT) Byte.$(OBJEXT) Char.$(OBJEXT) Closure.$(OBJEXT) \
+       CR_LF.$(OBJEXT) Database.$(OBJEXT) Datatype.$(OBJEXT) \
+       Date.$(OBJEXT) DateTime.$(OBJEXT) DBBase.$(OBJEXT) \
+       Dir.$(OBJEXT) EucJPRW.$(OBJEXT) Except.$(OBJEXT) \
+       Expr.$(OBJEXT) File.$(OBJEXT) Func.$(OBJEXT) Handler.$(OBJEXT) \
+       If.$(OBJEXT) Int.$(OBJEXT) ISO2022JP.$(OBJEXT) \
+       Japanese.$(OBJEXT) Lexer.$(OBJEXT) List.$(OBJEXT) \
+       Load.$(OBJEXT) Loop.$(OBJEXT) Mutex.$(OBJEXT) \
+       NameSpace.$(OBJEXT) Nil.$(OBJEXT) Object.$(OBJEXT) \
+       parser.$(OBJEXT) Prim.$(OBJEXT) RAW.$(OBJEXT) Real.$(OBJEXT) \
+       RW.$(OBJEXT) SendMsg.$(OBJEXT) SjisRW.$(OBJEXT) \
+       Socket.$(OBJEXT) soopy.$(OBJEXT) String.$(OBJEXT) \
+       Symbol.$(OBJEXT) Thread.$(OBJEXT) Time.$(OBJEXT) \
+       Tuple.$(OBJEXT) URLEncode.$(OBJEXT) Word.$(OBJEXT)
+soopy_OBJECTS = $(am_soopy_OBJECTS)
+soopy_LDADD = $(LDADD)
+DEFAULT_INCLUDES = -I.
+depcomp = $(SHELL) $(top_srcdir)/../depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+       -o $@
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+YLWRAP = $(top_srcdir)/../ylwrap
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(soopy_SOURCES)
+DIST_SOURCES = $(soopy_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d $(distdir) \
+    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr $(distdir); }; }
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = ${SHELL} /Users/randy/Documents/Program/soopy/soopy/missing --run aclocal-1.10
+ALLOCA = 
+AMTAR = ${SHELL} /Users/randy/Documents/Program/soopy/soopy/missing --run tar
+AUTOCONF = ${SHELL} /Users/randy/Documents/Program/soopy/soopy/missing --run autoconf
+AUTOHEADER = ${SHELL} /Users/randy/Documents/Program/soopy/soopy/missing --run autoheader
+AUTOMAKE = ${SHELL} /Users/randy/Documents/Program/soopy/soopy/missing --run automake-1.10
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2
+CPP = gcc -E
+CPPFLAGS = 
+CXX = g++
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO_C = \c
+ECHO_N = 
+ECHO_T = 
+EGREP = /usr/bin/grep -E
+EXEEXT = 
+GREP = /usr/bin/grep
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+LDFLAGS = 
+LIBOBJS =  ${LIBOBJDIR}lstat$U.o
+LIBS = 
+LTLIBOBJS =  ${LIBOBJDIR}lstat$U.lo
+MAKEINFO = ${SHELL} /Users/randy/Documents/Program/soopy/soopy/missing --run makeinfo
+MKDIR_P = ./../install-sh -c -d
+OBJEXT = o
+PACKAGE = soopy
+PACKAGE_BUGREPORT = jun.suzuki.japan@gmail.com
+PACKAGE_NAME = soopy
+PACKAGE_STRING = soopy 2.0
+PACKAGE_TARNAME = soopy
+PACKAGE_VERSION = 2.0
+PATH_SEPARATOR = :
+SET_MAKE = 
+SHELL = /bin/sh
+STRIP = 
+VERSION = 1.0.0
+YACC = bison -y
+YFLAGS = 
+abs_builddir = /Users/randy/Documents/Program/soopy/soopy/src
+abs_srcdir = /Users/randy/Documents/Program/soopy/soopy/src
+abs_top_builddir = /Users/randy/Documents/Program/soopy/soopy/src
+abs_top_srcdir = /Users/randy/Documents/Program/soopy/soopy/src
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+am__include = include
+am__leading_dot = .
+am__quote = 
+am__tar = ${AMTAR} chof - "$$tardir"
+am__untar = ${AMTAR} xf -
+bindir = ${exec_prefix}/bin
+build_alias = 
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host_alias = 
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = $(SHELL) /Users/randy/Documents/Program/soopy/soopy/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(top_builddir)/./../install-sh -c -d
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias = 
+top_builddir = .
+top_srcdir = .
+# source codes
+soopy_SOURCES = Array.cpp Assign.cpp Base64.cpp Bool.cpp Byte.cpp Char.cpp Closure.cpp CR_LF.cpp Database.cpp Datatype.cpp Date.cpp DateTime.cpp DBBase.cpp Dir.cpp EucJPRW.cpp Except.cpp Expr.cpp File.cpp Func.cpp Handler.cpp If.cpp Int.cpp ISO2022JP.cpp Japanese.cpp Lexer.cpp List.cpp Load.cpp Loop.cpp Mutex.cpp NameSpace.cpp Nil.cpp Object.cpp parser.ypp Prim.cpp RAW.cpp Real.cpp RW.cpp SendMsg.cpp SjisRW.cpp Socket.cpp soopy.cpp String.cpp Symbol.cpp Thread.cpp Time.cpp Tuple.cpp URLEncode.cpp Word.cpp
+all: config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .o .obj .ypp
+am--refresh:
+       @:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
+             cd $(srcdir) && $(AUTOMAKE) --gnu  \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  Makefile'; \
+       cd $(top_srcdir) && \
+         $(AUTOMAKE) --gnu  Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           echo ' $(SHELL) ./config.status'; \
+           $(SHELL) ./config.status;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+config.h: stamp-h1
+       @if test ! -f $@; then \
+         rm -f stamp-h1; \
+         $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+       else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+       @rm -f stamp-h1
+       cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps) 
+       cd $(top_srcdir) && $(AUTOHEADER)
+       rm -f stamp-h1
+       touch $@
+
+distclean-hdr:
+       -rm -f config.h stamp-h1
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; for p in $$list; do \
+         p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+         if test -f $$p \
+         ; then \
+           f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+          echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+          $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+         else :; fi; \
+       done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; for p in $$list; do \
+         f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+         echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+         rm -f "$(DESTDIR)$(bindir)/$$f"; \
+       done
+
+clean-binPROGRAMS:
+       -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+soopy$(EXEEXT): $(soopy_OBJECTS) $(soopy_DEPENDENCIES) 
+       @rm -f soopy$(EXEEXT)
+       $(CXXLINK) $(soopy_OBJECTS) $(soopy_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+include ./$(DEPDIR)/Array.Po
+include ./$(DEPDIR)/Assign.Po
+include ./$(DEPDIR)/Base64.Po
+include ./$(DEPDIR)/Bool.Po
+include ./$(DEPDIR)/Byte.Po
+include ./$(DEPDIR)/CR_LF.Po
+include ./$(DEPDIR)/Char.Po
+include ./$(DEPDIR)/Closure.Po
+include ./$(DEPDIR)/DBBase.Po
+include ./$(DEPDIR)/Database.Po
+include ./$(DEPDIR)/Datatype.Po
+include ./$(DEPDIR)/Date.Po
+include ./$(DEPDIR)/DateTime.Po
+include ./$(DEPDIR)/Dir.Po
+include ./$(DEPDIR)/EucJPRW.Po
+include ./$(DEPDIR)/Except.Po
+include ./$(DEPDIR)/Expr.Po
+include ./$(DEPDIR)/File.Po
+include ./$(DEPDIR)/Func.Po
+include ./$(DEPDIR)/Handler.Po
+include ./$(DEPDIR)/ISO2022JP.Po
+include ./$(DEPDIR)/If.Po
+include ./$(DEPDIR)/Int.Po
+include ./$(DEPDIR)/Japanese.Po
+include ./$(DEPDIR)/Lexer.Po
+include ./$(DEPDIR)/List.Po
+include ./$(DEPDIR)/Load.Po
+include ./$(DEPDIR)/Loop.Po
+include ./$(DEPDIR)/Mutex.Po
+include ./$(DEPDIR)/NameSpace.Po
+include ./$(DEPDIR)/Nil.Po
+include ./$(DEPDIR)/Object.Po
+include ./$(DEPDIR)/Prim.Po
+include ./$(DEPDIR)/RAW.Po
+include ./$(DEPDIR)/RW.Po
+include ./$(DEPDIR)/Real.Po
+include ./$(DEPDIR)/SendMsg.Po
+include ./$(DEPDIR)/SjisRW.Po
+include ./$(DEPDIR)/Socket.Po
+include ./$(DEPDIR)/String.Po
+include ./$(DEPDIR)/Symbol.Po
+include ./$(DEPDIR)/Thread.Po
+include ./$(DEPDIR)/Time.Po
+include ./$(DEPDIR)/Tuple.Po
+include ./$(DEPDIR)/URLEncode.Po
+include ./$(DEPDIR)/Word.Po
+include ./$(DEPDIR)/parser.Po
+include ./$(DEPDIR)/soopy.Po
+
+.cpp.o:
+       $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+       mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+#      source='$<' object='$@' libtool=no \
+#      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
+#      $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+       $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+       mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+#      source='$<' object='$@' libtool=no \
+#      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
+#      $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.ypp.cpp:
+       $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+           $$tags $$unique; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       test -z "$(CTAGS_ARGS)$$tags$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$tags $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && cd $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       $(am__remove_distdir)
+       test -d $(distdir) || mkdir $(distdir)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+           fi; \
+           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+         else \
+           test -f $(distdir)/$$file \
+           || cp -p $$d/$$file $(distdir)/$$file \
+           || exit 1; \
+         fi; \
+       done
+       -find $(distdir) -type d ! -perm -755 -exec chmod u+rwx,go+rx {} \; -o \
+         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+       || chmod -R a+r $(distdir)
+dist-gzip: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+       $(am__remove_distdir)
+
+dist-tarZ: distdir
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__remove_distdir)
+
+dist-shar: distdir
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__remove_distdir)
+
+dist dist-all: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       case '$(DIST_ARCHIVES)' in \
+       *.tar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+       *.tar.bz2*) \
+         bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+       *.tar.Z*) \
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+       *.shar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+       *.zip*) \
+         unzip $(distdir).zip ;;\
+       esac
+       chmod -R a-w $(distdir); chmod a+w $(distdir)
+       mkdir $(distdir)/_build
+       mkdir $(distdir)/_inst
+       chmod a-w $(distdir)
+       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && cd $(distdir)/_build \
+         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(DISTCHECK_CONFIGURE_FLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+               distuninstallcheck \
+         && chmod -R a-w "$$dc_install_base" \
+         && ({ \
+              (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+             } || { rm -rf "$$dc_destdir"; exit 1; }) \
+         && rm -rf "$$dc_destdir" \
+         && $(MAKE) $(AM_MAKEFLAGS) dist \
+         && rm -rf $(DIST_ARCHIVES) \
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+       $(am__remove_distdir)
+       @(echo "$(distdir) archives ready for distribution: "; \
+         list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+         sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+       @cd $(distuninstallcheck_dir) \
+       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+          || { echo "ERROR: files left after uninstall:" ; \
+               if test -n "$(DESTDIR)"; then \
+                 echo "  (check DESTDIR support)"; \
+               fi ; \
+               $(distuninstallcheck_listfiles) ; \
+               exit 1; } >&2
+distcleancheck: distclean
+       @if test '$(srcdir)' = . ; then \
+         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+         exit 1 ; \
+       fi
+       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+         || { echo "ERROR: files left in build directory after distclean:" ; \
+              $(distcleancheck_listfiles) ; \
+              exit 1; } >&2
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) config.h
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -rm -f parser.cpp
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
+
+distclean: distclean-am
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-hdr distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
+       clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
+       dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
+       distclean-compile distclean-generic distclean-hdr \
+       distclean-tags distcleancheck distdir distuninstallcheck dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-info install-info-am install-man \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       maintainer-clean maintainer-clean-generic mostlyclean \
+       mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+       tags uninstall uninstall-am uninstall-binPROGRAMS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644 (file)
index 0000000..3dd0049
--- /dev/null
@@ -0,0 +1,630 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+bin_PROGRAMS = soopy$(EXEEXT)
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(srcdir)/../depcomp \
+       $(srcdir)/../install-sh $(srcdir)/../missing \
+       $(srcdir)/../ylwrap $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in $(srcdir)/config.h.in \
+       $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+       parser.cpp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_soopy_OBJECTS = Array.$(OBJEXT) Assign.$(OBJEXT) Base64.$(OBJEXT) \
+       Bool.$(OBJEXT) Byte.$(OBJEXT) Char.$(OBJEXT) Closure.$(OBJEXT) \
+       CR_LF.$(OBJEXT) Database.$(OBJEXT) Datatype.$(OBJEXT) \
+       Date.$(OBJEXT) DateTime.$(OBJEXT) DBBase.$(OBJEXT) \
+       Dir.$(OBJEXT) EucJPRW.$(OBJEXT) Except.$(OBJEXT) \
+       Expr.$(OBJEXT) File.$(OBJEXT) Func.$(OBJEXT) Handler.$(OBJEXT) \
+       If.$(OBJEXT) Int.$(OBJEXT) ISO2022JP.$(OBJEXT) \
+       Japanese.$(OBJEXT) Lexer.$(OBJEXT) List.$(OBJEXT) \
+       Load.$(OBJEXT) Loop.$(OBJEXT) Mutex.$(OBJEXT) \
+       NameSpace.$(OBJEXT) Nil.$(OBJEXT) Object.$(OBJEXT) \
+       parser.$(OBJEXT) Prim.$(OBJEXT) RAW.$(OBJEXT) Real.$(OBJEXT) \
+       RW.$(OBJEXT) SendMsg.$(OBJEXT) SjisRW.$(OBJEXT) \
+       Socket.$(OBJEXT) soopy.$(OBJEXT) String.$(OBJEXT) \
+       Symbol.$(OBJEXT) Thread.$(OBJEXT) Time.$(OBJEXT) \
+       Tuple.$(OBJEXT) URLEncode.$(OBJEXT) Word.$(OBJEXT)
+soopy_OBJECTS = $(am_soopy_OBJECTS)
+soopy_LDADD = $(LDADD)
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/../depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+       -o $@
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+YLWRAP = $(top_srcdir)/../ylwrap
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(soopy_SOURCES)
+DIST_SOURCES = $(soopy_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d $(distdir) \
+    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr $(distdir); }; }
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build_alias = @build_alias@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+# source codes
+soopy_SOURCES = Array.cpp Assign.cpp Base64.cpp Bool.cpp Byte.cpp Char.cpp Closure.cpp CR_LF.cpp Database.cpp Datatype.cpp Date.cpp DateTime.cpp DBBase.cpp Dir.cpp EucJPRW.cpp Except.cpp Expr.cpp File.cpp Func.cpp Handler.cpp If.cpp Int.cpp ISO2022JP.cpp Japanese.cpp Lexer.cpp List.cpp Load.cpp Loop.cpp Mutex.cpp NameSpace.cpp Nil.cpp Object.cpp parser.ypp Prim.cpp RAW.cpp Real.cpp RW.cpp SendMsg.cpp SjisRW.cpp Socket.cpp soopy.cpp String.cpp Symbol.cpp Thread.cpp Time.cpp Tuple.cpp URLEncode.cpp Word.cpp
+all: config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .o .obj .ypp
+am--refresh:
+       @:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
+             cd $(srcdir) && $(AUTOMAKE) --gnu  \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  Makefile'; \
+       cd $(top_srcdir) && \
+         $(AUTOMAKE) --gnu  Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           echo ' $(SHELL) ./config.status'; \
+           $(SHELL) ./config.status;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+config.h: stamp-h1
+       @if test ! -f $@; then \
+         rm -f stamp-h1; \
+         $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+       else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+       @rm -f stamp-h1
+       cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps) 
+       cd $(top_srcdir) && $(AUTOHEADER)
+       rm -f stamp-h1
+       touch $@
+
+distclean-hdr:
+       -rm -f config.h stamp-h1
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; for p in $$list; do \
+         p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+         if test -f $$p \
+         ; then \
+           f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+          echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+          $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+         else :; fi; \
+       done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; for p in $$list; do \
+         f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+         echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+         rm -f "$(DESTDIR)$(bindir)/$$f"; \
+       done
+
+clean-binPROGRAMS:
+       -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+soopy$(EXEEXT): $(soopy_OBJECTS) $(soopy_DEPENDENCIES) 
+       @rm -f soopy$(EXEEXT)
+       $(CXXLINK) $(soopy_OBJECTS) $(soopy_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Array.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Assign.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Base64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Bool.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Byte.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CR_LF.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Char.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Closure.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DBBase.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Database.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Datatype.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Date.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DateTime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dir.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EucJPRW.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Except.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Expr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/File.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Func.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Handler.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ISO2022JP.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/If.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Int.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Japanese.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Lexer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/List.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Load.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Loop.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mutex.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NameSpace.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Nil.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Object.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Prim.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RAW.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RW.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Real.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SendMsg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SjisRW.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Socket.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/String.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Symbol.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Thread.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Time.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Tuple.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/URLEncode.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Word.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parser.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/soopy.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@  mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.ypp.cpp:
+       $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+           $$tags $$unique; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       test -z "$(CTAGS_ARGS)$$tags$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$tags $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && cd $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       $(am__remove_distdir)
+       test -d $(distdir) || mkdir $(distdir)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+           fi; \
+           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+         else \
+           test -f $(distdir)/$$file \
+           || cp -p $$d/$$file $(distdir)/$$file \
+           || exit 1; \
+         fi; \
+       done
+       -find $(distdir) -type d ! -perm -755 -exec chmod u+rwx,go+rx {} \; -o \
+         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+       || chmod -R a+r $(distdir)
+dist-gzip: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+       $(am__remove_distdir)
+
+dist-tarZ: distdir
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__remove_distdir)
+
+dist-shar: distdir
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__remove_distdir)
+
+dist dist-all: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       case '$(DIST_ARCHIVES)' in \
+       *.tar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+       *.tar.bz2*) \
+         bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+       *.tar.Z*) \
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+       *.shar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+       *.zip*) \
+         unzip $(distdir).zip ;;\
+       esac
+       chmod -R a-w $(distdir); chmod a+w $(distdir)
+       mkdir $(distdir)/_build
+       mkdir $(distdir)/_inst
+       chmod a-w $(distdir)
+       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && cd $(distdir)/_build \
+         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(DISTCHECK_CONFIGURE_FLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+               distuninstallcheck \
+         && chmod -R a-w "$$dc_install_base" \
+         && ({ \
+              (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+             } || { rm -rf "$$dc_destdir"; exit 1; }) \
+         && rm -rf "$$dc_destdir" \
+         && $(MAKE) $(AM_MAKEFLAGS) dist \
+         && rm -rf $(DIST_ARCHIVES) \
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+       $(am__remove_distdir)
+       @(echo "$(distdir) archives ready for distribution: "; \
+         list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+         sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+       @cd $(distuninstallcheck_dir) \
+       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+          || { echo "ERROR: files left after uninstall:" ; \
+               if test -n "$(DESTDIR)"; then \
+                 echo "  (check DESTDIR support)"; \
+               fi ; \
+               $(distuninstallcheck_listfiles) ; \
+               exit 1; } >&2
+distcleancheck: distclean
+       @if test '$(srcdir)' = . ; then \
+         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+         exit 1 ; \
+       fi
+       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+         || { echo "ERROR: files left in build directory after distclean:" ; \
+              $(distcleancheck_listfiles) ; \
+              exit 1; } >&2
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) config.h
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -rm -f parser.cpp
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
+
+distclean: distclean-am
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-hdr distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
+       clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
+       dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
+       distclean-compile distclean-generic distclean-hdr \
+       distclean-tags distcleancheck distdir distuninstallcheck dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-info install-info-am install-man \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       maintainer-clean maintainer-clean-generic mostlyclean \
+       mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+       tags uninstall uninstall-am uninstall-binPROGRAMS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/Makefile.linux b/src/Makefile.linux
new file mode 100644 (file)
index 0000000..58295d2
--- /dev/null
@@ -0,0 +1,125 @@
+CC=g++
+#CC=bc++
+DEBUG=
+DEBUG= -g
+#COPT= $(DEBUG) -c -DUSE_BISON -DNO_FINALLY
+COPT= $(DEBUG) -c -DEUC_JP -DLINUX -DUSE_SOCKET -DNO_READSOME -DUSE_PTHREAD
+LINKOPT= $(DEBUG) -lpthread
+YTAB_C=ytab.cpp
+YTAB_OBJ=ytab.o
+#YACC=bison -o $(YTAB_C)
+YACC=kmyacc
+INSTALL_DIR=/usr/local/bin
+
+OBJ= Object.o Char.o String.o Tuple.o List.o \
+     NameSpace.o Symbol.o SjisRW.o Assign.o SendMsg.o \
+     Nil.o Bool.o Int.o Real.o Handler.o Prim.o Closure.o \
+     Expr.o Func.o Load.o $(YTAB_OBJ) Lexer.o \
+     If.o Loop.o Array.o Datatype.o Except.o RW.o \
+     EucJPRW.o Dir.o Byte.o Word.o RAW.o CR_LF.o Socket.o \
+     Base64.o File.o URLEncode.o ISO2022JP.o Japanese.o \
+     Date.o Time.o DateTime.o Thread.o Mutex.o
+
+
+SUFFIXES= .cpp .o
+
+.cpp.o:
+       $(CC) $(COPT) $<
+
+all: soopy
+#all: test soopy
+
+install: all
+       cp -f soopy $(INSTALL_DIR)
+
+clean:
+       rm -f *.o $(YTAB_C) ytab.h
+
+Object.o: Object.cpp soopy.h
+Char.o: Char.cpp soopy.h
+String.o: String.cpp soopy.h
+Tuple.o: Tuple.cpp soopy.h
+List.o: List.cpp soopy.h
+NameSpace.o: NameSpace.cpp soopy.h
+Symbol.o: Symbol.cpp soopy.h
+SjisRW.o: SjisRW.cpp soopy.h
+Lexer.o: Lexer.cpp soopy.h $(YTAB_OBJ)
+       $(CC) $(COPT) Lexer.cpp
+$(YTAB_C): parser.y soopy.h
+       $(YACC) -d parser.y
+       -mv y.tab.h ytab.h
+       -mv y.tab.c ytab.cpp
+
+#      $(YACC) -o$(YTAB_C) -d p.y
+#      mv ytab.c ytab.cpp
+$(YTAB_OBJ): $(YTAB_C)
+Assign.o: Assign.cpp soopy.h
+SendMsg.o: SendMsg.cpp soopy.h
+Nil.o: Nil.cpp soopy.h
+Bool.o: Bool.cpp soopy.h
+Int.o: Int.cpp soopy.h
+Real.o: Real.cpp soopy.h
+Handler.o: Handler.cpp soopy.h
+Prim.o: Prim.cpp soopy.h
+Closure.o: Closure.cpp soopy.h
+Expr.o: Expr.cpp soopy.h
+Func.o: Func.cpp soopy.h
+soopy.o: soopy.cpp soopy.h
+If.o: If.cpp soopy.h
+Loop.o: Loop.cpp soopy.h
+Load.o: Load.cpp soopy.h
+Array.o: Array.cpp soopy.h
+Datatype.o: Datatype.cpp soopy.h
+Except.o: Except.cpp soopy.h
+#File.o: File.cpp soopy.h
+RW.o: RW.cpp soopy.h
+EucJPRW.o: EucJPRW.cpp soopy.h
+Dir.o: Dir.cpp soopy.h
+Byte.o: Byte.cpp soopy.h
+Word.o: Word.cpp soopy.h
+RAW.o: RAW.cpp soopy.h
+CR_LF.o: CR_LF.cpp soopy.h
+Socket.o: Socket.cpp soopy.h
+Base64.o: Base64.cpp soopy.h
+File.o: File.cpp soopy.h
+URLEncode.o: URLEncode.cpp soopy.h
+ISO2022JP.o: ISO2022JP.cpp soopy.h
+Japanese.o: Japanese.cpp soopy.h
+Date.o: Date.cpp soopy.h
+Time.o: Time.cpp soopy.h
+DateTime.o: DateTime.cpp soopy.h
+Thread.o: Thread.cpp soopy.h
+Mutex.o: Mutex.cpp soopy.h
+
+
+soopy: soopy.o $(OBJ)
+       $(CC) $(LINKOPT) -o soopy soopy.o $(OBJ)
+
+test: test2 test3 test4 test5 test6 \
+      test7 test8 test9
+
+test2: test2.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test2 test2.cpp $(OBJ)
+
+test3: test3.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test3 test3.cpp $(OBJ)
+
+test4: test4.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test4 test4.cpp $(OBJ)
+
+test5: test5.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test5 test5.cpp $(OBJ)
+
+test6: test6.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test6 test6.cpp $(OBJ)
+
+test7: test7.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test7 test7.cpp $(OBJ)
+
+test8: test8.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test8 test8.cpp $(OBJ)
+
+test9: test9.cpp $(OBJ)
+       $(CC) $(LINKOPT) -DEUC_JP -o test9 test9.cpp $(OBJ)
+
+
diff --git a/src/Makefile.osx b/src/Makefile.osx
new file mode 100644 (file)
index 0000000..c1a49cc
--- /dev/null
@@ -0,0 +1,122 @@
+CC=g++
+#CC=bc++
+#DEBUG=
+DEBUG= -g
+COPT= $(DEBUG) -c -DEUC_JP -DOSX -DUSE_SOCKET -DUSE_PTHREAD
+#COPT= $(DEBUG) -c -DEUC_JP -DOSX -DUSE_SOCKET
+#STACK_SIZE=8192
+#LINKOPT= $(DEBUG) -lpthread
+LINKOPT= $(DEBUG)
+YTAB_C=ytab.cpp
+YTAB_OBJ=ytab.o
+YACC=kmyacc
+
+OBJ= Object.o Char.o String.o Tuple.o List.o \
+     NameSpace.o Symbol.o SjisRW.o Assign.o SendMsg.o \
+     Nil.o Bool.o Int.o Real.o Handler.o Prim.o Closure.o \
+     Expr.o Func.o Load.o $(YTAB_OBJ) Lexer.o \
+     If.o Loop.o Array.o Datatype.o Except.o RW.o \
+     EucJPRW.o Dir.o Byte.o Word.o RAW.o CR_LF.o Socket.o \
+     Base64.o File.o URLEncode.o ISO2022JP.o Japanese.o \
+     Date.o Time.o DateTime.o Thread.o Mutex.o
+
+
+SUFFIXES= .cpp .o
+
+.cpp.o:
+       $(CC) $(COPT) $<
+
+all: soopy
+#all: test soopy
+
+Object.o: Object.cpp soopy.h
+Char.o: Char.cpp soopy.h
+String.o: String.cpp soopy.h
+Tuple.o: Tuple.cpp soopy.h
+List.o: List.cpp soopy.h
+NameSpace.o: NameSpace.cpp soopy.h
+Symbol.o: Symbol.cpp soopy.h
+SjisRW.o: SjisRW.cpp soopy.h
+Lexer.o: Lexer.cpp soopy.h $(YTAB_OBJ)
+       $(CC) $(COPT) Lexer.cpp
+$(YTAB_C): parser.y soopy.h
+       $(YACC) -d parser.y
+       mv y.tab.c ytab.cpp
+       mv y.tab.h ytab.h
+
+#      $(NKF) --unix -O parser.y p.y
+#      $(YACC) -o$(YTAB_C) -d p.y
+#      mv ytab.c ytab.cpp
+$(YTAB_OBJ): $(YTAB_C)
+Assign.o: Assign.cpp soopy.h
+SendMsg.o: SendMsg.cpp soopy.h
+Nil.o: Nil.cpp soopy.h
+Bool.o: Bool.cpp soopy.h
+Int.o: Int.cpp soopy.h
+Real.o: Real.cpp soopy.h
+Handler.o: Handler.cpp soopy.h
+Prim.o: Prim.cpp soopy.h
+Closure.o: Closure.cpp soopy.h
+Expr.o: Expr.cpp soopy.h
+Func.o: Func.cpp soopy.h
+soopy.o: soopy.cpp soopy.h
+If.o: If.cpp soopy.h
+Loop.o: Loop.cpp soopy.h
+Load.o: Load.cpp soopy.h
+Array.o: Array.cpp soopy.h
+Datatype.o: Datatype.cpp soopy.h
+Except.o: Except.cpp soopy.h
+#File.o: File.cpp soopy.h
+RW.o: RW.cpp soopy.h
+EucJPRW.o: EucJPRW.cpp soopy.h
+Dir.o: Dir.cpp soopy.h
+Byte.o: Byte.cpp soopy.h
+Word.o: Word.cpp soopy.h
+RAW.o: RAW.cpp soopy.h
+CR_LF.o: CR_LF.cpp soopy.h
+Socket.o: Socket.cpp soopy.h
+Base64.o: Base64.cpp soopy.h
+File.o: File.cpp soopy.h
+URLEncode.o: URLEncode.cpp soopy.h
+ISO2022JP.o: ISO2022JP.cpp soopy.h
+Japanese.o: Japanese.cpp soopy.h
+Date.o: Date.cpp soopy.h
+Time.o: Time.cpp soopy.h
+DateTime.o: DateTime.cpp soopy.h
+Thread.o: Thread.cpp soopy.h
+Mutex.o: Mutex.cpp soopy.h
+
+
+soopy: soopy.o $(OBJ)
+#      $(CC) --stack,$(STACK_SIZE) -o soopy soopy.o $(OBJ)
+       $(CC) -o soopy soopy.o $(OBJ)
+
+test: test2 test3 test4 test5 test6 \
+      test7 test8 test9
+
+test2: test2.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test2 test2.cpp $(OBJ)
+
+test3: test3.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test3 test3.cpp $(OBJ)
+
+test4: test4.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test4 test4.cpp $(OBJ)
+
+test5: test5.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test5 test5.cpp $(OBJ)
+
+test6: test6.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test6 test6.cpp $(OBJ)
+
+test7: test7.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test7 test7.cpp $(OBJ)
+
+test8: test8.cpp $(OBJ)
+       $(CC) $(LINKOPT) -o test8 test8.cpp $(OBJ)
+
+test9: test9.cpp $(OBJ)
+       $(CC) $(LINKOPT) -DEUC_JP -o test9 test9.cpp $(OBJ)
+
+clean:
+       rm -f $(OBJ) soopy.o
diff --git a/src/Mutex.cpp b/src/Mutex.cpp
new file mode 100644 (file)
index 0000000..288b959
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Mutex.cpp,v 1.3 2004/03/29 10:38:20 randy Exp $
+ */
+
+#include "soopy.h"
+
+//
+// Soopy Mutex Class
+//
+
+#ifdef THREAD
+
+//
+// instance primitives
+//
+SpValue& SpMutex::prim_synchronize(SpValue& self, SpValue& func)
+{
+  SpValue result;
+  SpValue taker;
+  SpFunc* f;
+  if(func.isNameSpace()){
+    SpNameSpace* ns = func.asNameSpace();
+    f = SpUsrFunc::fromNameSpace(ns);
+    taker.setObject(f);
+  }else if(func.isFunc()){
+    f = func.asFunc();
+  }else{
+    throw SpException("not function (mutex.synchronize)");
+  }
+  SpMutex* ptr = dynamic_cast<SpMutex*>(self.getObject());
+  if(ptr == NULL){
+    throw SpException("not mutex (synchronize)");
+  }
+  ptr->lock();
+  try{
+    result = (*f)(NilObject);
+  }catch(...){
+    ptr->unlock();
+    throw;
+  }
+  ptr->unlock();
+
+  return SpValueResult(result);
+}
+
+SpValue& SpMutex::toString()
+{
+    SpString* str;
+    char buf[32];
+
+    sprintf(buf, "%X", mutex);
+    str = new SpString();
+    *str = "<mutex: ";
+    *str += buf;
+    *str += ">";
+    return SpObjectResult(str);
+}
+
+//
+// primitives (Mutex)
+//
+SpValue& SpMutex::prim_new()
+{
+  SpValue result;
+  SpMutex* mutex = new SpMutex();
+  result.setNewObject(mutex);
+  return SpValueResult(result);
+}
+
+//
+// onMessage
+//
+MsgHandler MutexMsgHandler;
+
+SpValue& SpMutex::onMessage(SpValue& rec, SpValue& msg)
+{
+  return MutexMsgHandler(rec, msg);
+}
+
+//
+// init
+//
+//SpNameSpace* PMutexNameSpace;
+//SpValue      MutexNS;
+
+void SpMutex::init()
+{
+/*
+  // set namespace to symbol 'mutex'.
+  PMutexNameSpace = new SpNameSpace();
+  MutexNS.setNewObject(PMutexNameSpace);
+  SpValue SymMutex(new SpSymbol("mutex"));
+  PMainNameSpace->internConst(SymMutex, MutexNS);
+
+  SpValue SymNew(new SpSymbol("new"));
+  SpValue PrimNew(new SpPrim0(prim_new));
+  PMutexNameSpace->internFunc(SymNew, PrimNew);
+ */
+  SpValue SymMakeMutex(new SpSymbol("make_mutex"));
+  SpValue PrimMakeMutex(new SpPrim0(prim_new));
+  PMainNameSpace->internFunc(SymMakeMutex, PrimMakeMutex);
+
+  // init instance method
+  SpValue SymSynchronize(new SpSymbol("synchronize"));
+  SpValue PrimSynchronize(new SpPrim2(prim_synchronize));
+  MutexMsgHandler.append(SymSynchronize, PrimSynchronize);
+}
+
+#endif /* THREAD */
diff --git a/src/NameSpace.cpp b/src/NameSpace.cpp
new file mode 100644 (file)
index 0000000..1fa559b
--- /dev/null
@@ -0,0 +1,765 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: NameSpace.cpp,v 1.69 2004/03/27 05:08:14 randy Exp $
+ */
+
+#include "soopy.h"
+
+//
+// Soopy NameSpace Class
+//
+
+#ifndef USE_PTHREAD
+vector<SpValue> Frame;
+#endif
+
+SpNameSpace::SpNameSpace(NSMap& m, SpValue& p)
+{
+    aMap = m;
+    parentNS = p;
+}
+
+SpNameSpace::SpNameSpace(SpNameSpace* ns1, SpNameSpace* ns2, SpValue& p)
+{
+    aMap = ns1->aMap;
+    NSMap::iterator found;
+    NSMap::iterator it = ns2->aMap.begin();
+    for(; it != ns2->aMap.end(); it++){
+        found = aMap.find(it->first);
+        if(found != aMap.end()){
+            aMap.erase(found);
+        }
+        aMap[it->first] = it->second;
+    }
+    parentNS = p;
+}
+
+SpNameSpace::SpNameSpace(SpValue& p)
+{
+    parentNS = p;
+}
+
+SpNameSpace::~SpNameSpace()
+{
+#ifdef TEST
+    *spout << ":destroy NameSpace:" << "\n";
+#endif
+//    NSMap::iterator it;
+//    for(it = aMap.begin(); it != aMap.end(); it++){
+//        delete it->first;
+//    }
+}
+
+SpValue& SpNameSpace::toString()
+{
+    SpString* str;
+    bool isPublic=true;
+
+    str = new SpString();
+    *str = "{\n";
+    NSMap::iterator it;
+    for(it = aMap.begin(); it != aMap.end(); it++){
+        SpValue temp = it->first;
+        NSKey* key = temp.asNSKey();
+        if(key->isPublic != isPublic){
+            isPublic = ! isPublic;
+            if(isPublic){
+                *str += "public\n";
+            }else{
+                *str += "private\n";
+            }
+        }
+        *str += "  ";
+        *str += key->toString();
+        *str += ": ";
+        *str += it->second.toString();
+        *str += ";\n";
+    }
+    *str += "}";
+
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+bool SpNameSpace::operator==(SpObject& obj)
+{
+    if(SpNameSpace* p2 = dynamic_cast<SpNameSpace*>(&obj)){
+        if(size() != p2->size()){
+            return false;
+        }
+
+        NSMap::iterator it;
+        for(it = aMap.begin(); it != aMap.end(); it++){
+            NSMap::iterator find;
+
+            find = p2->aMap.find(it->first);
+            if(find == p2->aMap.end()){ // not found
+                return false;
+            }
+            if(it->second != find->second){
+                return false;
+            }
+        }
+        return true;
+    }
+    return false;
+}
+
+bool SpNameSpace::operator<(SpObject& obj)
+{
+    if(SpNameSpace* p2 = dynamic_cast<SpNameSpace*>(&obj)){
+        int size1 = size();
+        int size2 = p2->size();
+        if(size1 != size2){
+            return size1 < size2;
+        }
+
+        // \82·\82×\82Ä\82Ì\83L\81[\82ª\93¯\82\82©\82Ç\82¤\82©\83`\83F\83b\83N
+        bool all_match = true;
+        NSMap::iterator it;
+        for(it = aMap.begin(); it != aMap.end(); it++){
+            NSMap::iterator find;
+            find = p2->aMap.find(it->first);
+            if(find == p2->aMap.end()){ // not found
+                all_match = false;
+                break;
+            }
+        }
+
+        if(all_match){
+            // \82·\82×\82Ä\82Ì\83L\81[\82ª\93¯\82\82Æ\82«\81A\92l\82ð\8f\87\94Ô\82É\94ä\8ar\82·\82é\81B
+            NSMap::iterator it;
+            for(it = aMap.begin(); it != aMap.end(); it++){
+                if(it->second != p2->aMap[it->first]){
+                    return it->second < p2->aMap[it->first];
+                }
+            }
+            return false;
+        }else{
+            // \83L\81[\82ª\95Ê\82Ì\82Æ\82«\81A\83L\81[\82Ì\91å\82«\82³\82ð\94ä\8ar\82·\82é\81B
+            //   \83L\81[\82Ì\8f\87\94Ô\82É\82Í\88Ó\96¡\82ª\82È\82¢\82Ì\82Å\81A\82±\82ê\82Å\82Í\81A\96{\93\96\82Í\95s\8f\\95ª\81B
+            //   \82æ\82Á\82Ä\81A\92P\8f\83\82È\83l\81[\83\80\83X\83y\81[\83X\88È\8aO\82ð\81A\83l\81[\83\80\83X\83y\81[\83X\82Ì\83L\81[\82Æ\82µ\82Ä\8eg\82¤\82×\82«\82Å\82Í\82È\82¢\81B
+            NSMap::iterator it;
+            NSMap::iterator it2;
+            for(it = aMap.begin(), it2 = p2->aMap.begin();
+                it != aMap.end();
+                it++, it2++)
+            {
+                SpValue temp;
+                temp = it->first;
+                NSKey* key1 = temp.asNSKey();
+                temp = it2->first;
+                NSKey* key2 = temp.asNSKey();
+                SpValue v1 = key1->val;
+                SpValue v2 = key2->val;
+                if(v1 != v2){
+                    return v1 < v2;
+                }
+            }
+        }
+    }
+    return SpObject::operator<(obj);
+}
+
+SpNameSpace& SpNameSpace::operator+=(SpNameSpace& ns)
+{
+    NSMap::iterator it;
+    for(it=ns.begin(); it != ns.end(); it++){
+        this->setValue((SpValue&)it->first, it->second, (SpNameSpace*)this);
+    }
+    return *this;
+}
+
+bool SpNameSpace::reachable(SpNameSpace* ns)
+{
+  if(ns == NULL) return false;
+  if(this == ns){
+    return true;
+  }
+  if(!parentNS.isNil()){
+    SpNameSpace* p = parentNS.asNameSpace();
+    return p->reachable(ns);
+  }
+  return false;
+}
+
+SpValue& SpNameSpace::lookup(SpValue& v, SpNameSpace* searcher)
+{
+    NSVar* key = new NSVar(v);
+    try{
+        return getValue(key, searcher, NULL, true);
+    //}catch(SpAccessException& e){
+    //    throw;
+    //}catch(SpException& e){
+    }catch(SpKeyException& e){
+        return NilObject;
+    }
+}
+
+// search 1 level only
+SpValue& SpNameSpace::lookup1(SpValue& v, SpNameSpace* searcher)
+{
+    NSVar* key = new NSVar(v);
+    try{
+        return getValue(key, searcher, NULL, false);
+    //}catch(SpAccessException& e){
+    //    throw;
+    //}catch(SpException& e){
+    }catch(SpKeyException& e){
+        return NilObject;
+    }
+}
+
+SpValue& SpNameSpace::getValue(NSKey* k, SpNameSpace* searcher, SpNameSpace* cur_ns, bool search_parent)
+{
+//cout << "getValue key:'" << *k << "'" << endl;
+    if(cur_ns == NULL){
+        cur_ns = this;
+    }
+    NSKey* ptr;
+    //    SpValue key(k);
+    SpValue key;
+    key.setObject(k);
+    NSMap::iterator it;
+    it = aMap.find(key);
+    if(it != aMap.end()){
+        SpValue temp = it->first;
+        ptr = temp.asNSKey();
+        // check permission
+        if(!ptr->isPublic){
+            if(searcher == NULL){
+                throw SpAccessException("can't access private feature.");
+            }
+            if(!searcher->reachable(this)){
+                throw SpAccessException("can't access private feature.");
+            }
+        }
+        if(ptr->isNSProperty()){
+            NSProperty* pro = (NSProperty*)ptr;
+            NSVar* var = new NSVar(pro->getter);
+            SpValue key2(var);
+            it = aMap.find(key2);
+            if(it == aMap.end()){ throw SpException("no getter in property"); }
+            temp = it->first;
+            NSKey* ptr2 = dynamic_cast<NSKey*>(temp.getObject());
+            if(ptr2->isNSFunc()){
+                SpFunc* func = it->second.asFunc();
+                //static SpValue v;
+                SpValue v;
+                // push this to currentNS
+                SpValue ns(cur_ns);
+                pushCurrentNS(ns);
+                try{
+                    v = (*func)(NilObject);
+                }catch(...){
+                    popCurrentNS();
+                    throw;
+                }
+                popCurrentNS();
+               //                return v;
+               return SpValueResult(v);
+            }else{
+                return it->second;
+            }
+        }else if(ptr->isNSPrimProperty()){
+            NSPrimProperty* pro = (NSPrimProperty*)ptr;
+            if(pro->getter.isFunc()){
+                SpFunc* func = pro->getter.asFunc();
+               //                static SpValue v;
+                SpValue v;
+                // push this to currentNS
+                SpValue ns(cur_ns);
+                pushCurrentNS(ns);
+                try{
+                    v = (*func)(NilObject);
+                }catch(...){
+                    popCurrentNS();
+                    throw;
+                }
+                popCurrentNS();
+               //                return v;
+               return SpValueResult(v);
+            }else{
+                return it->second;
+            }
+        }else if(ptr->isNSFunc()){
+            //SpValue ns(this);
+            SpValue ns(cur_ns);
+            SpClosure* clos = new SpClosure(it->second, ns);
+           //            static SpValue result;
+           //            result.setNewObject(clos);
+           //            return result;
+           return SpObjectResult(clos);
+        }else{
+            return it->second;
+        }
+    }
+    // not found
+    if(search_parent && !parentNS.isNil()){
+        SpNameSpace* ns = dynamic_cast<SpNameSpace*>(parentNS.getObject());
+        return ns->getValue(k, searcher, cur_ns);
+    }
+
+    throw SpKeyException("no such a key", k->toCStringWithEncoder());
+}
+
+void SpNameSpace::setValue(SpValue& key, SpValue& val, SpNameSpace* searcher, SpNameSpace* cur_ns)
+{
+    SpValue old_value;
+    if(cur_ns == NULL){
+        cur_ns = this;
+    }
+    NSMap::iterator it;
+    it = aMap.find(key);
+    if(it != aMap.end()){
+        old_value = it->second;
+        SpValue temp = it->first;
+        NSKey* ptr = temp.asNSKey();
+        // check permission
+        if(!ptr->isPublic){
+            if(searcher == NULL){
+                throw SpAccessException("can't access private feature.");
+            }
+            if(!searcher->reachable(this)){
+                throw SpAccessException("can't access private feature.");
+            }
+        }
+        if(ptr->isNSProperty()){
+            NSProperty* pro = (NSProperty*)ptr;
+            NSVar* var = new NSVar(pro->setter);
+            SpValue key2(var);
+            it = aMap.find(key2);
+            if(it == aMap.end()){ throw SpException("no setter in property"); }
+            temp = it->first;
+            NSKey* ptr2 = dynamic_cast<NSKey*>(temp.getObject());
+            if(ptr2->isNSFunc()){
+                SpFunc* func = it->second.asFunc();
+                // push this to currentNS
+                //SpValue ns(this);
+                SpValue ns(cur_ns);
+                pushCurrentNS(ns);
+                try{
+                    (*func)(val);
+                }catch(...){
+                    popCurrentNS();
+                    throw;
+                }
+                popCurrentNS();
+            }else if(ptr2->isNSConst()){
+                throw SpException("setter is constant or function");
+            }else{
+                //aMap[pro->setter] = val;
+                aMap[key2] = val;
+            }
+        }else if(ptr->isNSPrimProperty()){
+            NSPrimProperty* pro = (NSPrimProperty*)ptr;
+            if(pro->setter.isFunc()){
+                SpFunc* func = pro->setter.asFunc();
+               //                static SpValue v;
+                // push this to currentNS
+                SpValue ns(cur_ns);
+                pushCurrentNS(ns);
+                try{
+                    (*func)(val);
+                }catch(...){
+                    popCurrentNS();
+                    throw;
+                }
+                popCurrentNS();
+            }else{
+                //throw SpException("system error");
+                throw SpSystemError(__FILE__, __LINE__);
+            }
+        }else{
+            if(ptr->isNSConst()){
+                throw SpException("can't change constant or function");
+            }
+           aMap.erase(it);
+            aMap[key] = val;
+        }
+    }else{
+        if(!parentNS.isNil()){
+            SpNameSpace* ns = dynamic_cast<SpNameSpace*>(parentNS.getObject());
+            ns->setValue(key, val, searcher);
+        }else if(this == PMainNameSpace){
+            aMap[key] = val;
+        }else{
+            throw SpException("can't set undefined feature");
+        }
+    }
+}
+
+void SpNameSpace::intern(SpValue& key, SpValue& val)
+{
+    NSMap::iterator it = aMap.find(key);
+    if(it != aMap.end()){
+        aMap.erase(it);
+    }
+    aMap[key] = val;
+}
+
+/*
+ * NSVar
+ */
+
+SpValue& NSVar::toString()
+{
+    SpString* s = new SpString("var ");
+    *s += val.toString();
+    //    static SpValue v;
+    //    v.setNewObject(s);
+    //    return v;
+    return SpObjectResult(s);
+}
+
+
+/*
+ * NSCont
+ */
+
+SpValue& NSConst::toString()
+{
+    SpString* s1 = new SpString("const ");
+    SpValue taker(s1);
+    SpValue v2 = val.toString();
+    SpString* s2 = dynamic_cast<SpString*>(v2.getObject());
+    *s1 += *s2;
+    SpString* s = new SpString(s1->toCStringWithEncoder());
+    //    static SpValue v;
+    //    v.setNewObject(s);
+    //    return v;
+    return SpObjectResult(s);
+}
+
+
+/*
+ * NSProperty
+ */
+
+SpValue& NSProperty::toString()
+{
+    bool print_getter=false;
+    SpString* s = new SpString("property ");
+    SpValue taker(s);
+    SpValue v0 = NSKey::toString();
+    SpValue v1 = getter.toString();
+    SpValue v2 = setter.toString();
+    SpString* s1 = dynamic_cast<SpString*>(v1.getObject());
+    SpString* s2 = dynamic_cast<SpString*>(v2.getObject());
+    *s += v0;
+    *s += " {";
+    if(getter != NilObject){
+        *s += "get: ";
+        *s += *s1;
+        print_getter = true;
+    }
+    if(setter != NilObject){
+        if(print_getter){
+            *s += ", ";
+        }
+        *s += "set: ";
+        *s += *s2;
+    }
+    *s += "}";
+    SpString* s3 = new SpString(s->toCStringWithEncoder());
+    //    static SpValue v;
+    //    v.setNewObject(s3);
+    //    return v;
+    return SpObjectResult(s3);
+}
+
+
+/*
+ * NSPrimProperty
+ */
+
+SpValue& NSPrimProperty::toString()
+{
+    bool print_getter=false;
+    SpString* s = new SpString("property ");
+    SpValue taker(s);
+    SpValue v0 = NSKey::toString();
+    SpValue v1 = getter.toString();
+    SpValue v2 = setter.toString();
+    SpString* s1 = dynamic_cast<SpString*>(v1.getObject());
+    SpString* s2 = dynamic_cast<SpString*>(v2.getObject());
+    *s += v0;
+    *s += " {";
+    if(getter != NilObject){
+        *s += "get: ";
+        *s += *s1;
+        print_getter = true;
+    }
+    if(setter != NilObject){
+        if(print_getter){
+            *s += ", ";
+        }
+        *s += "set: ";
+        *s += *s2;
+    }
+    *s += "}";
+    SpString* s3 = new SpString(s->toCStringWithEncoder());
+    //    static SpValue v;
+    //    v.setNewObject(s3);
+    //    return v;
+    return SpObjectResult(s3);
+}
+
+
+/*
+ * Message Handler
+ */
+
+SpValue& SpNameSpace::onMessage(SpValue& rec, SpValue& msg)
+{
+    NSVar* key = new NSVar(msg);
+    try{
+        SpValue temp = getCurrentNS();
+        SpNameSpace* ns = temp.asNameSpace();
+        return getValue(key, ns);
+        //        return lookup(msg);
+    }catch(SpAccessException& e){
+        throw;
+    }catch(SpException& e){
+        try{
+            return NameSpaceMsgHandler(rec, msg);
+        }catch(SpNoMethodException& e){
+            return NilObject;
+        }
+    }
+}
+
+/*
+ * primitives
+ */
+
+SpValue& SpNameSpace::rename(SpValue& self, SpValue& renames)
+{
+    if(!renames.isNameSpace()){
+        throw SpException("arg is not namespace.(ns.rename)");
+    }
+    SpNameSpace* ns1 = self.asNameSpace();
+    SpNameSpace* ns2 = renames.asNameSpace();
+
+    NSMap assoc = ns1->aMap;
+    NSMap::iterator it = ns2->aMap.begin();
+    for(; it != ns2->aMap.end(); it++){
+        NSMap::iterator found;
+        found = assoc.find(it->first);
+        if(found != assoc.end()){
+            SpValue val = found->second;
+            //NSKey* key = ((SpValue&)found->first).asNSKey();
+            SpValue temp = found->first;
+            NSKey* key = temp.asNSKey();
+            if(key->isNSProperty()){
+                NSProperty* p = (NSProperty*)key;
+                key = new NSProperty(it->second, p->getter, p->setter, p->isPublic);
+            }else if(key->isNSPrimProperty()){
+                NSPrimProperty* p = (NSPrimProperty*)key;
+                key = new NSProperty(it->second, p->getter, p->setter, p->isPublic);
+            }else if(key->isNSFunc()){
+                key = new NSFunc(it->second);
+            }else if(key->isNSDataType()){
+                key = new NSDataType(it->second);
+            }else if(key->isNSConst()){
+                key = new NSConst(it->second);
+            }else{
+                key = new NSVar(it->second);
+            }
+            assoc.erase(found);
+            assoc[key] = val;
+        }
+    }
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpNameSpace(assoc, ns1->parentNS));
+    //    return result;
+    return SpObjectResult(new SpNameSpace(assoc, ns1->parentNS));
+}
+
+
+SpValue& SpNameSpace::make_func(SpValue& self)
+{
+    SpNameSpace* ns = self.asNameSpace();
+    SpValue f(SpUsrFunc::fromNameSpace(ns));
+    //    static SpValue result;
+    //    result.setNewObject(new SpClosure(f, self));
+    //    return result;
+    return SpObjectResult(new SpClosure(f, self));
+}
+
+static SpValue PrimAppend;
+
+SpValue& SpNameSpace::prim_append(SpValue& self, SpValue& key, SpValue& val)
+{
+    SpNameSpace* ns = self.asNameSpace();
+    SpValue v1 = key.eval();
+    SpValue v2 = val.eval();
+    ns->internVar(v1, v2);
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpClosureP3_1(PrimAppend, self, getCurrentNS()));
+    //    return result;
+    return SpObjectResult(new SpClosureP3_1(PrimAppend, self, getCurrentNS()));
+}
+
+SpValue& SpNameSpace::prim_keys(SpValue& self)
+{
+    //    static SpValue result;
+    SpValue result;
+    result = NilObject;
+    SpNameSpace* ns = self.asNameSpace();
+
+    NSMap::iterator it = ns->aMap.begin();
+    for(; it != ns->aMap.end(); it++){
+        NSKey* key;
+        key = ((SpValue)it->first).asNSKey();
+        result.setNewObject(new SpCons(key->val, result));
+    }
+
+    //    return result;
+    return SpValueResult(result);
+}
+
+SpValue& SpNameSpace::prim_delete(SpValue& self, SpValue& key)
+{
+    SpNameSpace* ns = self.asNameSpace();
+    NSVar var(key);
+    SpValue k;
+    k.setObject(&var);
+    NSMap::iterator found = ns->aMap.find(k);
+    if(found != ns->aMap.end()){
+        ns->aMap.erase(found);
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+SpValue& SpNameSpace::prim_lookup(SpValue& self, SpValue& key)
+{
+    SpNameSpace* ns = self.asNameSpace();
+    SpValue v = key.eval();
+    //    static SpValue result;
+    //    result = ns->lookup(v);
+    //    return result;
+    return SpValueResult(ns->lookup(v));
+}
+
+/*
+ * init NameSpace
+ */
+
+SpNameSpace* PMainNameSpace;
+SpValue MainNS;
+SpNameSpace* PSoopyNameSpace;
+SpValue SoopyNS;
+SpNameSpace* PEnvNameSpace;
+SpValue EnvNS;
+
+void SpNameSpace::init()
+{
+    PMainNameSpace = new SpNameSpace();
+    MainNS.setNewObject(PMainNameSpace);
+    pushCurrentNS(MainNS);
+
+    PSoopyNameSpace = new SpNameSpace();
+    SoopyNS.setNewObject(PSoopyNameSpace);
+    PMainNameSpace->internConst(SymSoopy, SoopyNS);
+
+    PEnvNameSpace = new SpNameSpace();
+    EnvNS.setNewObject(PEnvNameSpace);
+    PMainNameSpace->internConst(SymEnv, EnvNS);
+
+    SpValue PrimRename(new SpPrim2(rename));
+    NameSpaceMsgHandler.append(SymRename, PrimRename);
+
+    SpValue SymEval(new SpSymbol("eval"));
+    SpValue PrimEval(new SpPrim1(make_func));
+    NameSpaceMsgHandler.append(SymEval, PrimEval);
+
+    PrimAppend.setNewObject(new SpPrim3(prim_append));
+    NameSpaceMsgHandler.append(SymAppend, PrimAppend);
+
+    SpValue PrimKeys(new SpPrim1(prim_keys));
+    NameSpaceMsgHandler.append(SymKeys, PrimKeys);
+
+    SpValue PrimDelete(new SpPrim2(prim_delete));
+    NameSpaceMsgHandler.append(SymDelete, PrimDelete);
+
+    SpValue SymLookup(new SpSymbol("lookup"));
+    SpValue PrimLookup(new SpPrim2(prim_lookup));
+    NameSpaceMsgHandler.append(SymLookup, PrimLookup);
+}
+
+/*
+ * operator +
+ */
+
+SpValue& SpNameSpace::plus(SpValue& e1, SpValue& e2)
+{
+    SpNameSpace* ns1;
+    SpNameSpace* ns2;
+    SpNameSpace* ns3;
+
+    if(!e2.isNameSpace()){
+        throw SpException("type mismatch in +(NameSpace, ...)");
+    }
+    ns1 = dynamic_cast<SpNameSpace*>(e1.getObject());
+    ns2 = dynamic_cast<SpNameSpace*>(e2.getObject());
+    ns3 = new SpNameSpace(ns1, ns2, getCurrentNS());
+    //    static SpValue v;
+    //    v.setNewObject(ns3);
+    //    return v;
+    return SpObjectResult(ns3);
+}
+
+
+/*
+ * class MakeNameSpace
+ */
+
+SpValue& MakeNameSpace::eval()
+{
+    SpNameSpace* src = dynamic_cast<SpNameSpace*>(ns.getObject());
+    SpNameSpace* assoc = new SpNameSpace(getCurrentNS());
+    NSMap::iterator it = src->aMap.begin();
+    for(; it != src->aMap.end(); it++){
+        SpValue temp = it->first;
+        if(temp.isNSKey() && temp.asNSKey()->isNSDataType()){
+            SpDataType* dt = it->second.asDataType();
+            dt->mapping2ns(it->second, assoc);
+        }else{
+            SpValue v = it->second.eval();
+            temp = it->first;
+            assoc->intern(temp, v);
+        }
+    }
+    //    static SpValue result;
+    //    result.setNewObject(assoc);
+    //    return result;
+    return SpObjectResult(assoc);
+}
+
+SpValue& MakeNameSpace::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "MakeNameSpace(";
+    *str += ns.toString();
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
diff --git a/src/Nil.cpp b/src/Nil.cpp
new file mode 100644 (file)
index 0000000..3d06e4d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Nil.cpp,v 1.10 2004/03/17 06:09:28 randy Exp $
+ */
+
+#include "soopy.h"
+
+void initNil()
+{
+    NilMsgHandler.append(SymIsList, PrimTrue);
+    NilMsgHandler.append(SymIsNil, PrimTrue);
+    NilMsgHandler.append(SymSplit, PrimNil2);
+    NilMsgHandler.append(SymEach, PrimNil2);
+    NilMsgHandler.append(SymSort, PrimNil);
+    NilMsgHandler.append(SymMap, PrimNil2);
+    NilMsgHandler.append(SymFilter, PrimNil2);
+    NilMsgHandler.append(SymLength, PrimZero);
+}
+
diff --git a/src/Object.cpp b/src/Object.cpp
new file mode 100644 (file)
index 0000000..01054d5
--- /dev/null
@@ -0,0 +1,1977 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Object.cpp,v 1.127 2004/05/23 13:15:53 randy Exp $
+ */
+
+
+#include <stdio.h>
+#include "soopy.h"
+
+char Filename[SP_NAME_MAX];
+unsigned int lineno = 1;
+
+SpValue NilObject;
+#ifndef USE_PTHREAD
+SpValue gResult;
+#endif  /* USE_PTHREAD */
+SpValue TrueObject((bool)true);
+SpValue FalseObject((bool)false);
+SpValue NullString;
+SpValue ObjectZero((int)0);
+SpValue ObjectOne((int)1);
+SpValue ObjectTwo((int)2);
+
+StreamWriter* strmout;
+SjisWriteEncoder* sjisout;
+EucJPWriteEncoder* eucjpout;
+RawWriteEncoder* write_raw_encoder;
+
+StreamReader* strmin;
+SjisReadDecoder* sjisin;
+EucJPReadDecoder* eucjpin;
+JapaneseReadDecoder* japanin;
+RawReadEncoder* read_raw_encoder;
+WriteEncoder* spout;
+ReadEncoder* spin;
+
+MsgHandler ObjectMsgHandler;
+MsgHandler NilMsgHandler(&ObjectMsgHandler);
+MsgHandler BoolMsgHandler(&ObjectMsgHandler);
+MsgHandler CharMsgHandler(&ObjectMsgHandler);
+MsgHandler IntMsgHandler(&ObjectMsgHandler);
+MsgHandler RealMsgHandler(&ObjectMsgHandler);
+MsgHandler StringMsgHandler(&ObjectMsgHandler);
+MsgHandler SymbolMsgHandler(&ObjectMsgHandler);
+MsgHandler ListMsgHandler(&ObjectMsgHandler);
+MsgHandler TupleMsgHandler(&ObjectMsgHandler);
+MsgHandler NameSpaceMsgHandler(&ObjectMsgHandler);
+MsgHandler ArrayMsgHandler(&ObjectMsgHandler);
+MsgHandler FileInMsgHandler(&ObjectMsgHandler);
+MsgHandler FileOutMsgHandler(&ObjectMsgHandler);
+MsgHandler DirMsgHandler(&ObjectMsgHandler);
+MsgHandler FileMsgHandler(&ObjectMsgHandler);
+#ifdef USE_SOCKET
+MsgHandler SocketMsgHandler(&ObjectMsgHandler);
+MsgHandler ServerSocketMsgHandler(&ObjectMsgHandler);
+#endif
+MsgHandler DateMsgHandler(&ObjectMsgHandler);
+MsgHandler TimeMsgHandler(&ObjectMsgHandler);
+MsgHandler DateTimeMsgHandler(&ObjectMsgHandler);
+#ifdef USE_DATABASE
+MsgHandler DatabaseMsgHandler(&ObjectMsgHandler);
+#endif
+
+SpValue SymIsInt;
+SpValue SymIsChar;
+SpValue SymIsBool;
+SpValue SymIsReal;
+SpValue SymIsList;
+SpValue SymIsNil;
+SpValue SymIsTuple;
+SpValue SymIsString;
+SpValue SymIsSymbol;
+SpValue SymHead;
+SpValue SymTail;
+SpValue SymLength;
+SpValue SymVar;
+SpValue SymRequire;
+SpValue SymDo;
+SpValue SymEnsure;
+SpValue SymRescue;
+SpValue SymFrom;
+SpValue SymStep;
+SpValue SymWhile;
+SpValue SymUntil;
+SpValue SymVariant;
+SpValue SymInvariant;
+SpValue SymSoopy;
+SpValue SymEnv;
+SpValue SymClose;
+SpValue SymRename;
+SpValue SymArg;
+SpValue SymName;
+SpValue SymToInt;
+SpValue SymToString;
+SpValue SymNth;
+SpValue SymEach;
+SpValue SymFirst;
+SpValue SymSecond;
+SpValue SymThird;
+SpValue SymFourth;
+SpValue SymFifth;
+SpValue SymEucjpOut;
+SpValue SymEucjpIn;
+SpValue SymSjisOut;
+SpValue SymSjisIn;
+SpValue SymJapaneseIn;
+// types for type check
+SpValue SymBool;
+SpValue SymInt;
+SpValue SymByte;
+SpValue SymWord;
+SpValue SymChar;
+SpValue SymReal;
+SpValue SymString;
+SpValue SymSymbol;
+SpValue SymFunction;
+SpValue SymTuple;
+SpValue SymList;
+SpValue SymArray;
+SpValue SymNameSpace;
+SpValue SymReader;
+SpValue SymWriter;
+SpValue SymEncoderIn;
+SpValue SymEncoderOut;
+SpValue SymDecoderIn;
+SpValue SymDecoderOut;
+SpValue SymDir;
+SpValue SymMember;
+SpValue SymOpen;
+SpValue SymOpenIn;
+SpValue SymOpenOut;
+SpValue SymOpenAppend;
+SpValue SymSelf;
+SpValue SymWriteChar;
+SpValue SymWrite;
+SpValue SymWriteLine;
+SpValue SymReadLine;
+SpValue SymFlush;
+SpValue SymClosed;
+SpValue SymIsEOF;
+SpValue SymUpper;
+SpValue SymLower;
+SpValue SymAppend;
+SpValue SymKeys;
+SpValue SymDelete;
+SpValue SymSplit;
+SpValue SymSplit1;
+SpValue SymSort;
+SpValue SymStdin;
+SpValue SymStdout;
+SpValue SymMap;
+SpValue SymFoldl;
+SpValue SymFoldr;
+SpValue SymFilter;
+SpValue SymReplace;
+SpValue SymReplace1;
+SpValue SymFind;
+SpValue SymYear;
+SpValue SymMonth;
+SpValue SymDay;
+SpValue SymSucc;
+SpValue SymPred;
+SpValue SymHour;
+SpValue SymMinute;
+SpValue SymDate;
+SpValue SymTime;
+SpValue SymAtime;
+SpValue SymCtime;
+SpValue SymMtime;
+#ifdef USE_DATABASE
+SpValue SymDatabase;
+#endif
+SpValue SymGet;
+SpValue SymSet;
+SpValue SymCurrentThread;
+
+SpSymbol* symbolBool;
+SpSymbol* symbolInt;
+SpSymbol* symbolByte;
+SpSymbol* symbolWord;
+SpSymbol* symbolChar;
+SpSymbol* symbolReal;
+SpSymbol* symbolString;
+SpSymbol* symbolSymbol;
+SpSymbol* symbolFunction;
+SpSymbol* symbolTuple;
+SpSymbol* symbolList;
+SpSymbol* symbolArray;
+SpSymbol* symbolNameSpace;
+SpSymbol* symbolReader;
+SpSymbol* symbolWriter;
+SpSymbol* symbolEncoderIn;
+SpSymbol* symbolEncoderOut;
+SpSymbol* symbolDecoderIn;
+SpSymbol* symbolDecoderOut;
+
+SpValue PrimNil;
+SpValue PrimNil2;
+SpValue PrimNil3;
+SpValue PrimTrue;
+SpValue PrimFalse;
+SpValue PrimZero;
+
+// type check
+void CheckType(SpValue& featureType, SpValue& value)
+{
+    static char buf[256];
+    static char buf2[256];
+
+    if(featureType.isNil()){  // any type is OK.
+        return;
+    }
+    if(!featureType.isSymbol()){
+        throw SpException("not symbol (type)");
+    }
+    SpSymbol* sym = featureType.asSymbol();
+    switch(value.getType()){
+    case TypeBool:
+        if(*sym == *symbolBool) return;
+        break;
+    case TypeInt:
+        if(*sym == *symbolInt) return;
+        if(*sym == *symbolByte) return;
+        if(*sym == *symbolWord) return;
+        break;
+    case TypeChar:
+        if(*sym == *symbolChar) return;
+        break;
+    case TypeReal:
+        if(*sym == *symbolReal) return;
+        break;
+    case TypeString:
+        if(*sym == *symbolString) return;
+        break;
+    case TypeSymbol:
+        if(*sym == *symbolSymbol) return;
+        break;
+    case TypeList:
+        if(*sym == *symbolList) return;
+        break;
+    case TypeTuple:
+        if(*sym == *symbolTuple) return;
+        break;
+    case TypeNameSpace:
+        if(*sym == *symbolNameSpace) return;
+        break;
+    case TypeExpr:
+        throw SpSystemError(__FILE__, __LINE__);
+    case TypeArray:
+        if(*sym == *symbolArray) return;
+        break;
+    case TypeDType:
+        SpDType* dt = value.asDType();
+        if(featureType == dt->symbol) return;
+        if(featureType == dt->con->datatype->symbol) return;
+        strncpy(buf, featureType.toCStringWithEncoder(), 255);
+        buf[255] = '\0';
+        strncpy(buf2, value.typeString(), 255);
+        buf2[255] = '\0';
+        throw SpTypeException("type error", buf, buf2);
+        break;
+/*
+    case TypeObject:
+        break;
+*/
+    }
+    strncpy(buf, featureType.toCStringWithEncoder(), 255);
+    buf[255] = '\0';
+    strncpy(buf2, value.typeString(), 255);
+    buf2[255] = '\0';
+    throw SpTypeException("type error", buf, buf2);
+}
+
+// primitives
+SpValue& returnNil(SpValue&)
+{
+    return NilObject;
+}
+
+SpValue& returnNil2(SpValue&, SpValue&)
+{
+    return NilObject;
+}
+
+SpValue& returnNil3(SpValue&, SpValue&, SpValue&)
+{
+    return NilObject;
+}
+
+SpValue& returnTrue(SpValue&)
+{
+    return TrueObject;
+}
+
+SpValue& returnFalse(SpValue&)
+{
+    return FalseObject;
+}
+
+SpValue& returnZero(SpValue&)
+{
+    return ObjectOne;
+}
+
+static void setSymbols()
+{
+    SymIsInt.setNewObject(new SpSymbol("isint?"));
+    SymIsChar.setNewObject(new SpSymbol("ischar?"));
+    SymIsBool.setNewObject(new SpSymbol("isbool?"));
+    SymIsReal.setNewObject(new SpSymbol("isreal?"));
+    SymIsList.setNewObject(new SpSymbol("islist?"));
+    SymIsNil.setNewObject(new SpSymbol("isnil?"));
+    SymIsTuple.setNewObject(new SpSymbol("istuple?"));
+    SymIsString.setNewObject(new SpSymbol("isstring?"));
+    SymIsSymbol.setNewObject(new SpSymbol("issymbol?"));
+    SymHead.setNewObject(new SpSymbol("head"));
+    SymTail.setNewObject(new SpSymbol("tail"));
+    SymLength.setNewObject(new SpSymbol("length"));
+    SymVar.setNewObject(new SpSymbol("var"));
+    SymRequire.setNewObject(new SpSymbol("require"));
+    SymDo.setNewObject(new SpSymbol("do"));
+    SymEnsure.setNewObject(new SpSymbol("ensure"));
+    SymRescue.setNewObject(new SpSymbol("rescue"));
+    SymWhile.setNewObject(new SpSymbol("while"));
+    SymUntil.setNewObject(new SpSymbol("until"));
+    SymVariant.setNewObject(new SpSymbol("variant"));
+    SymInvariant.setNewObject(new SpSymbol("invariant"));
+    SymFrom.setNewObject(new SpSymbol("from"));
+    SymStep.setNewObject(new SpSymbol("step"));
+    SymSoopy.setNewObject(new SpSymbol("soopy"));
+    SymEnv.setNewObject(new SpSymbol("env"));
+    SymClose.setNewObject(new SpSymbol("close"));
+    SymRename.setNewObject(new SpSymbol("rename"));
+    SymArg.setNewObject(new SpSymbol("arg"));
+    SymName.setNewObject(new SpSymbol("name"));
+    SymToInt.setNewObject(new SpSymbol("toint"));
+    SymToString.setNewObject(new SpSymbol("tostring"));
+    SymNth.setNewObject(new SpSymbol("nth"));
+    SymEach.setNewObject(new SpSymbol("each"));
+    SymFirst.setNewObject(new SpSymbol("first"));
+    SymSecond.setNewObject(new SpSymbol("second"));
+    SymThird.setNewObject(new SpSymbol("third"));
+    SymFourth.setNewObject(new SpSymbol("fourth"));
+    SymFifth.setNewObject(new SpSymbol("fifth"));
+    SymEucjpOut.setNewObject(new SpSymbol("eucjpout"));
+    SymEucjpIn.setNewObject(new SpSymbol("eucjpin"));
+    SymSjisOut.setNewObject(new SpSymbol("sjisout"));
+    SymSjisIn.setNewObject(new SpSymbol("sjisin"));
+    SymDir.setNewObject(new SpSymbol("dir"));
+    SymJapaneseIn.setNewObject(new SpSymbol("japanesein"));
+    SymYear.setNewObject(new SpSymbol("year"));
+    SymMonth.setNewObject(new SpSymbol("month"));
+    SymDay.setNewObject(new SpSymbol("day"));
+    SymSucc.setNewObject(new SpSymbol("succ"));
+    SymPred.setNewObject(new SpSymbol("pred"));
+    SymHour.setNewObject(new SpSymbol("hour"));
+    SymMinute.setNewObject(new SpSymbol("minute"));
+    SymDate.setNewObject(new SpSymbol("date"));
+    SymTime.setNewObject(new SpSymbol("time"));
+    SymAtime.setNewObject(new SpSymbol("atime"));
+    SymCtime.setNewObject(new SpSymbol("ctime"));
+    SymMtime.setNewObject(new SpSymbol("mtime"));
+#ifdef USE_DATABASE
+    SymDatabase.setNewObject(new SpSymbol("database"));
+#endif
+
+
+    symbolBool = new SpSymbol("bool");
+    symbolInt  = new SpSymbol("int");
+    symbolByte = new SpSymbol("byte");
+    symbolWord = new SpSymbol("word");
+    symbolChar = new SpSymbol("char");
+    symbolReal = new SpSymbol("real");
+    symbolString   = new SpSymbol("string");
+    symbolFunction = new SpSymbol("function");
+    symbolTuple = new SpSymbol("tuple");
+    symbolList  = new SpSymbol("list");
+    symbolArray = new SpSymbol("array");
+    symbolNameSpace = new SpSymbol("namespace");
+    symbolReader    = new SpSymbol("reader");
+    symbolWriter    = new SpSymbol("writer");
+    symbolEncoderIn = new SpSymbol("encoderin");
+    symbolEncoderOut= new SpSymbol("encoderout");
+    symbolDecoderIn = new SpSymbol("decoderin");
+    symbolDecoderOut= new SpSymbol("decoderout");
+
+    SymBool.setNewObject(symbolBool);
+    SymInt.setNewObject(symbolInt);
+    SymByte.setNewObject(symbolByte);
+    SymWord.setNewObject(symbolWord);
+    SymChar.setNewObject(symbolChar);
+    SymReal.setNewObject(symbolReal);
+    SymString.setNewObject(symbolString);
+    SymFunction.setNewObject(symbolFunction);
+    SymTuple.setNewObject(symbolTuple);
+    SymList.setNewObject(symbolList);
+    SymArray.setNewObject(symbolArray);
+    SymNameSpace.setNewObject(symbolNameSpace);
+    SymReader.setNewObject(symbolReader);
+    SymWriter.setNewObject(symbolWriter);
+    SymEncoderIn.setNewObject(symbolEncoderIn);
+    SymEncoderOut.setNewObject(symbolEncoderOut);
+    SymDecoderIn.setNewObject(symbolDecoderIn);
+    SymDecoderOut.setNewObject(symbolDecoderOut);
+
+    SymMember.setNewObject(new SpSymbol("member?"));
+    SymOpen.setNewObject(new SpSymbol("open"));
+    SymOpenIn.setNewObject(new SpSymbol("openin"));
+    SymOpenOut.setNewObject(new SpSymbol("openout"));
+    SymOpenAppend.setNewObject(new SpSymbol("openappend"));
+    SymSelf.setNewObject(new SpSymbol("self"));
+    SymWriteChar.setNewObject(new SpSymbol("writechar"));
+    SymWrite.setNewObject(new SpSymbol("write"));
+    SymWriteLine.setNewObject(new SpSymbol("writeline"));
+    SymReadLine.setNewObject(new SpSymbol("readline"));
+    SymFlush.setNewObject(new SpSymbol("flush"));
+    SymClosed.setNewObject(new SpSymbol("closed?"));
+    //SymEof.setNewObject(new SpSymbol("eof"));
+    SymIsEOF.setNewObject(new SpSymbol("eof?"));
+    SymUpper.setNewObject(new SpSymbol("upper"));
+    SymLower.setNewObject(new SpSymbol("lower"));
+    SymAppend.setNewObject(new SpSymbol("append"));
+    SymKeys.setNewObject(new SpSymbol("keys"));
+    SymDelete.setNewObject(new SpSymbol("delete"));
+    SymSplit.setNewObject(new SpSymbol("split"));
+    SymSplit1.setNewObject(new SpSymbol("split1"));
+    SymSort.setNewObject(new SpSymbol("sort"));
+    SymMap.setNewObject(new SpSymbol("map"));
+    SymFoldl.setNewObject(new SpSymbol("foldl"));
+    SymFoldr.setNewObject(new SpSymbol("foldr"));
+    SymFilter.setNewObject(new SpSymbol("filter"));
+    SymReplace.setNewObject(new SpSymbol("replace"));
+    SymReplace1.setNewObject(new SpSymbol("replace1"));
+    SymFind.setNewObject(new SpSymbol("find"));
+
+    SymStdin.setNewObject(new SpSymbol("stdin"));
+    SymStdout.setNewObject(new SpSymbol("stdout"));
+    SymGet.setNewObject(new SpSymbol("get"));
+    SymSet.setNewObject(new SpSymbol("set"));
+    SymCurrentThread.setNewObject(new SpSymbol("current_thread"));
+}
+
+void setPrims()
+{
+    PrimNil.setNewObject(new SpPrim1(&returnNil));
+    PrimNil2.setNewObject(new SpPrim2(&returnNil2));
+    PrimNil3.setNewObject(new SpPrim3(&returnNil3));
+    PrimTrue.setNewObject(new SpPrim1(&returnTrue));
+    PrimFalse.setNewObject(new SpPrim1(&returnFalse));
+    PrimZero.setNewObject(new SpPrim1(&returnZero));
+}
+
+void InitCommandLine(int argc, char** argv)
+{
+    SpValue val;
+    if(argc > 0){
+        SpValue temp(new SpString(*argv));
+        SpCons* head = new SpCons(temp);
+        argc--; argv++;
+        for(;argc > 0; argc--, argv++){
+            SpValue v(new SpString(*argv));
+            head->append(v);
+        }
+        val.setNewObject(head);
+    }
+    SpValue SymCLine(new SpSymbol("commandline"));
+    PSoopyNameSpace->internConst(SymCLine, val);
+}
+
+void InitEnv(char* env[])
+{
+    for(; *env != NULL; env++){
+        char* ptr = *env;
+        char* p = strchr(ptr, '=');
+        if(p != NULL){
+            *p = '\0';
+            SpValue keystr(new SpString(ptr));
+            SpValue valstr(new SpString(p+1));
+            PEnvNameSpace->internConst(keystr, valstr);
+            *p = '=';
+        }
+    }
+}
+
+// init SOOPY_LIB
+
+#ifndef PATH_DELIMIT
+#define PATH_DELIMIT ':'
+#endif /* PATH_DELIMIT */
+
+char* LibPaths[MaxLibPath] = {
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+  };
+
+char LibPathBuffer[MaxLibPathBuffer];
+
+int NumberOfLibPath = 0;
+
+void InitLib()
+{
+    char* env = getenv("SOOPY_LIB");
+    if(env != NULL){
+        int len = strlen(env);
+        if(len >= (MaxLibPathBuffer-1)){
+            warning("too long env 'SOOPY_LIB'");
+            len = MaxLibPathBuffer-2;
+        }
+        memcpy(LibPathBuffer, env, len);
+        LibPathBuffer[len] = '\0';
+
+        // \83f\83\8a\83~\83^\82Å\95ª\8a\84\82·\82é
+        char* ptr = LibPathBuffer;
+        for(NumberOfLibPath=0; true; NumberOfLibPath++){
+            if(NumberOfLibPath >= MaxLibPath){
+                warning("too much lib_path");
+                NumberOfLibPath = MaxLibPath - 1;
+                break;
+            }
+            LibPaths[NumberOfLibPath] = ptr;
+            ptr = strchr(ptr, PATH_DELIMIT);
+            if(ptr == NULL){
+                NumberOfLibPath++;
+                break;
+            }
+            *ptr = '\0';
+            ptr++;
+        }
+    }
+}
+
+void SpInit(int argc, char* argv[], char* env[])
+{
+    extern void initNil();
+    extern void initBool();
+    extern void initChar();
+    extern void initInt();
+    extern void initReal();
+    extern void initPrim();
+    extern void initSjisFile();
+    extern void initEucJPFile();
+    extern void initISO2022JPFile();
+    extern void initJapaneseFile();
+    extern void initByteFile();
+    extern void initWordFile();
+    extern void initRawFile();
+    extern void initCRLF2LF();
+    extern void initCRLF2CR();
+    extern void initLF2CRLF();
+    extern void initCR2CRLF();
+    extern void initCR2LF();
+    extern void initLF2CR();
+    extern void initBase64();
+    extern void initURL();
+
+    // init Filename
+    strcpy(Filename, "STDIN");
+
+  // init stream
+    strmout = new StreamWriter(&cout);
+    sjisout = new SjisWriteEncoder(strmout);
+    eucjpout = new EucJPWriteEncoder(strmout);
+    write_raw_encoder = new RawWriteEncoder(strmout);
+    static SpValue StrmOut(strmout);
+    static SpValue SjisOut(sjisout);
+    static SpValue EucJPOut(eucjpout);
+    static SpValue RawOut(write_raw_encoder);
+
+    strmin = new StreamReader(&cin);
+    sjisin = new SjisReadDecoder(strmin);
+    eucjpin = new EucJPReadDecoder(strmin);
+    japanin = new JapaneseReadDecoder(strmin);
+    read_raw_encoder= new RawReadEncoder(strmin);
+    static SpValue StrmIn(strmin);
+    static SpValue SjisIn(sjisin);
+    static SpValue EucJPIn(eucjpin);
+    static SpValue JapaneseIn(japanin);
+    static SpValue RawIn(read_raw_encoder);
+
+#ifdef EUC_JP
+    spout = eucjpout;
+//    spin = eucjpin;
+#else
+    spout = sjisout;
+//    spin = sjisin;
+#endif
+    spin = japanin;
+
+    static SpValue Stdin(spin);
+    static SpValue Stdout(spout);
+
+    NullString.setNewObject(new SpString(""));
+
+    setSymbols();
+    setPrims();
+
+    initNil();
+    initBool();
+    initChar();
+    initInt();
+    initReal();
+    SpObject::init();
+    SpString::init();
+    SpSymbol::init();
+    SpList::init();
+    SpTuple::init();
+#ifdef THREAD
+    SpThread::init();
+#endif /* THREAD */
+    SpNameSpace::init();
+#ifdef THREAD
+    SpThread::init2();
+    SpMutex::init();
+#endif /* THREAD */
+    //SpFileIn::init();
+    Reader::init();
+    //SpFileOut::init();
+    Writer::init();
+    SpArray::init();
+    SpDate::init();
+    SpTime::init();
+    SpDateTime::init();
+    SpDir::init();
+    SpFile::init();
+#ifdef USE_DATABASE
+    SpDatabase::init();
+#endif
+    initPrim();
+    initSjisFile();
+    initEucJPFile();
+    initISO2022JPFile();
+    initJapaneseFile();
+    initByteFile();
+    initWordFile();
+    initRawFile();
+    initCRLF2LF();
+    initCRLF2CR();
+    initLF2CRLF();
+    initCR2CRLF();
+    initCR2LF();
+    initLF2CR();
+    initBase64();
+    initURL();
+#ifdef USE_SOCKET
+    Socket::init();
+#endif
+
+    PMainNameSpace->internConst(SymStdin, Stdin);
+    PMainNameSpace->internConst(SymStdout, Stdout);
+
+    InitCommandLine(argc, argv);
+    InitLib();
+    InitEnv(env);
+
+}
+
+void SpFinalize()
+{
+#ifdef THREAD
+  SpThread::finalize();
+#endif
+}
+
+
+//
+// class SpObject
+//
+const char* SpObject::toCString(WriteEncoder& encoder)
+{
+    //return toString().toCStringWithEncoder(encoder);
+    SpValue temp;
+    temp = toString();
+    return temp.toCStringWithEncoder(encoder);
+}
+
+const char* SpObject::toCStringWithEncoder(WriteEncoder& encoder)
+{
+    //return toString().toCStringWithEncoder(encoder);
+    SpValue temp;
+    temp = toString();
+    return temp.toCStringWithEncoder(encoder);
+}
+
+bool SpObject::operator<(SpObject& obj)
+{
+  //    return typeid(*this).before(typeid(obj));
+  return this < &obj;
+}
+
+SpValue& SpObject::prim_toString(SpValue& self)
+{
+    //    static SpValue result;
+    //    result = self.toString();
+    //    return result;
+    return SpValueResult(self.toString());
+}
+
+
+/*
+ * Message Handler
+ */
+
+// init Message Handler
+void SpObject::init()
+{
+    ObjectMsgHandler.append(SymIsNil, PrimFalse);
+    ObjectMsgHandler.append(SymIsInt, PrimFalse);
+    ObjectMsgHandler.append(SymIsChar, PrimFalse);
+    ObjectMsgHandler.append(SymIsBool, PrimFalse);
+    ObjectMsgHandler.append(SymIsReal, PrimFalse);
+    ObjectMsgHandler.append(SymIsList, PrimFalse);
+    ObjectMsgHandler.append(SymIsTuple, PrimFalse);
+    ObjectMsgHandler.append(SymIsString, PrimFalse);
+    ObjectMsgHandler.append(SymIsSymbol, PrimFalse);
+    SpValue PrimToString(new SpPrim1(prim_toString));
+    ObjectMsgHandler.append(SymToString, PrimToString);
+}
+
+SpValue& SpObject::onMessage(SpValue& rec, SpValue& msg)
+{
+    return SpValueResult(ObjectMsgHandler(rec, msg));
+}
+
+SpValue& SpObject::uminus(SpValue&)
+{
+    throw SpException("not defined operator unary -");
+}
+
+SpValue& SpObject::plus(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator +");
+}
+
+SpValue& SpObject::minus(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator -");
+}
+
+SpValue& SpObject::times(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator *");
+}
+
+SpValue& SpObject::div(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator /");
+}
+
+SpValue& SpObject::mod(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator %");
+}
+
+SpValue& SpObject::boolNot(SpValue&)
+{
+    throw SpException("not defined operator !");
+}
+
+SpValue& SpObject::boolAnd(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator &&");
+}
+
+SpValue& SpObject::boolOr(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator ||");
+}
+
+SpValue& SpObject::eq(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator ==");
+}
+
+SpValue& SpObject::ne(SpValue& e1, SpValue& e2)
+{
+    if(eq(e1,e2).isTrue()){
+        return FalseObject;
+    }
+    return TrueObject;
+}
+
+SpValue& SpObject::gt(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator >");
+}
+
+SpValue& SpObject::ge(SpValue& e1, SpValue& e2)
+{
+    if(eq(e1,e2).isTrue()){
+        return TrueObject;
+    }
+    if(gt(e1,e2).isTrue()){
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+SpValue& SpObject::lt(SpValue&, SpValue&)
+{
+    throw SpException("not defined operator <");
+}
+
+SpValue& SpObject::le(SpValue& e1, SpValue& e2)
+{
+    if(eq(e1,e2).isTrue()){
+        return TrueObject;
+    }
+    if(lt(e1,e2).isTrue()){
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+//
+// class SpValue
+//
+
+// copy constructor
+SpValue::SpValue(const SpValue& val)
+{
+    typ = val.typ;
+    switch(typ){
+    case TypeNil:
+        pObject = NULL;
+        break;
+    case TypeBool:
+        Bool = val.Bool;
+        break;
+    case TypeInt:
+        Int = val.Int;
+        break;
+    case TypeChar:
+        Char = val.Char;
+        break;
+    case TypeReal:
+        Real = val.Real;
+        break;
+    case TypeObject:
+        RetainObject(val.pObject);
+        break;
+    }
+}
+
+//SpValue::SpValue(char c, Reader& reader)
+SpValue::SpValue(char c, ReadEncoder& reader)
+{
+    typ = TypeChar;
+    Char = reader.fromChar(c);
+}
+
+const char* SpValue::typeString()
+{
+    switch(typ){
+    case TypeNil:
+        return "nil";
+    case TypeBool:
+        return "bool";
+    case TypeInt:
+        return "int";
+    case TypeChar:
+        return "char";
+    case TypeReal:
+        return "real";
+    case TypeObject:
+        return pObject->typeString();
+    }
+    throw SpException("illegal type -- system error");
+}
+
+SpObject* SpValue::getObject(){
+    if(isObject()){
+        if(pObject != NULL){
+            return pObject;
+        }else{
+#ifdef TEST
+            cout << "no objcet" << endl;
+#endif
+            throw SpException("no object");
+        }
+    }else{
+#ifdef TEST
+        cout << "NOT objcet" << endl;
+#endif
+        throw SpException("not object");
+    }
+}
+
+SpInt SpValue::asInt(){
+    if(typ != TypeInt){
+        throw SpException("not int (asInt)");
+    }
+    return Int;
+}
+
+SpTuple* SpValue::asTuple()
+{
+    if(!isTuple()){
+        throw SpException("not tuple");
+    }
+    SpTuple* ptr = dynamic_cast<SpTuple*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpNameSpace* SpValue::asNameSpace()
+{
+    if(!isNameSpace()){
+        throw SpException("not namespace");
+    }
+    SpNameSpace* ptr = dynamic_cast<SpNameSpace*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpDataType* SpValue::asDataType()
+{
+    if(!isDataType()){
+        throw SpException("not datatype");
+    }
+    SpDataType* ptr = dynamic_cast<SpDataType*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpConstructor* SpValue::asConstructor()
+{
+    if(!isConstructor()){
+        throw SpException("not constructor");
+    }
+    SpConstructor* ptr = dynamic_cast<SpConstructor*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpArg* SpValue::asArg()
+{
+    if(!isArg()){
+        throw SpException("not arg");
+    }
+    SpArg* ptr = dynamic_cast<SpArg*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpDType* SpValue::asDType()
+{
+    if(!isDType()){
+        throw SpException("not dtype");
+    }
+    SpDType* ptr = dynamic_cast<SpDType*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+NSKey* SpValue::asNSKey()
+{
+    if(!isNSKey()){
+        throw SpException("not nskey");
+    }
+    NSKey* ptr = dynamic_cast<NSKey*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpList* SpValue::asList()
+{
+    if(!isList()){
+        throw SpException("not list");
+    }
+    SpList* ptr = dynamic_cast<SpList*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpString* SpValue::asString()
+{
+    if(!isString()){
+        throw SpException("not string");
+    }
+    SpString* ptr = dynamic_cast<SpString*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+Reader* SpValue::asReader()
+{
+    if(!isReader()){
+        throw SpException("not reader");
+    }
+    Reader* ptr = dynamic_cast<Reader*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+Writer* SpValue::asWriter()
+{
+    if(!isWriter()){
+        throw SpException("not writer");
+    }
+    Writer* ptr = dynamic_cast<Writer*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpFunc* SpValue::asFunc()
+{
+    if(!isFunc()){
+        throw SpException("not function");
+    }
+    SpFunc* ptr = dynamic_cast<SpFunc*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpArray* SpValue::asArray()
+{
+    if(!isArray()){
+        throw SpException("not array");
+    }
+    SpArray* ptr = dynamic_cast<SpArray*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpByteArray* SpValue::asByteArray()
+{
+    if(!isByteArray()){
+        throw SpException("not byte array");
+    }
+    SpByteArray* ptr = dynamic_cast<SpByteArray*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpSymbol* SpValue::asSymbol()
+{
+    if(!isSymbol()){
+        throw SpException("not Symbol");
+    }
+    SpSymbol* ptr = dynamic_cast<SpSymbol*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpDir* SpValue::asDir()
+{
+    if(!isDir()){
+        throw SpException("not dir");
+    }
+    SpDir* ptr = dynamic_cast<SpDir*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpAssign* SpValue::asAssign()
+{
+    if(!isAssign()){
+        throw SpException("not assignment");
+    }
+    SpAssign* ptr = dynamic_cast<SpAssign*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+#ifdef USE_SOCKET
+Socket* SpValue::asSocket()
+{
+    if(!isSocket()){
+        throw SpException("not socket");
+    }
+    Socket* ptr = dynamic_cast<Socket*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+ServerSocket* SpValue::asServerSocket()
+{
+    if(!isServerSocket()){
+        throw SpException("not server socket");
+    }
+    ServerSocket* ptr = dynamic_cast<ServerSocket*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+#endif
+
+SpDate* SpValue::asDate()
+{
+    if(!isDate()){
+        throw SpException("not date");
+    }
+    SpDate* ptr = dynamic_cast<SpDate*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpTime* SpValue::asTime()
+{
+    if(!isTime()){
+        throw SpException("not time");
+    }
+    SpTime* ptr = dynamic_cast<SpTime*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+SpDateTime* SpValue::asDateTime()
+{
+    if(!isDateTime()){
+        throw SpException("not datetime");
+    }
+    SpDateTime* ptr = dynamic_cast<SpDateTime*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+
+#ifdef USE_DATABASE
+SpDatabase* SpValue::asDatabase()
+{
+    if(!isDatabase()){
+        throw SpException("not database");
+    }
+    SpDatabase* ptr = dynamic_cast<SpDatabase*>(pObject);
+    if(ptr == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+    return ptr;
+}
+#endif
+
+SpValue& SpValue::operator=(const SpValue& val)
+{
+    //    if(this != &val){
+    if(*this != (SpValue&)val){
+        clearObject();
+        typ = val.typ;
+        switch(typ){
+        case TypeNil:
+            pObject = NULL;
+            break;
+        case TypeBool:
+            Bool = val.Bool;
+            break;
+        case TypeInt:
+            Int = val.Int;
+            break;
+        case TypeChar:
+            Char = val.Char;
+            break;
+        case TypeReal:
+            Real = val.Real;
+            break;
+        case TypeObject:
+            RetainObject(val.pObject);
+            break;
+        }
+    }
+    return *this;
+}
+
+bool SpValue::operator==(SpValue& val)
+{
+    if(this == &val){
+        return true;
+    }else{
+        if(typ != val.typ){
+            return false;
+        }else{
+            switch(typ){
+            case TypeNil:
+                return true;
+            case TypeBool:
+                return Bool == val.Bool;
+            case TypeInt:
+                return Int == val.Int;
+            case TypeChar:
+                return Char == val.Char;
+            case TypeReal:
+                return Real == val.Real;
+            case TypeObject:
+                return *(getObject()) == *(val.getObject());
+            }
+        }
+    }
+    return false;
+}
+
+bool SpValue::operator<(SpValue& val)
+{
+    if(this == &val){
+        return false;
+    }else{
+        if(typ != val.typ){
+            return typ < val.typ;
+        }else{
+            switch(typ){
+            case TypeNil:
+                return false;
+            case TypeBool:
+                return Bool < val.Bool;
+            case TypeInt:
+                return Int < val.Int;
+            case TypeChar:
+                return Char < val.Char;
+            case TypeReal:
+                return Real < val.Real;
+            case TypeObject:
+                return *(getObject()) < *(val.getObject());
+            }
+        }
+    }
+    return false;
+}
+
+const char* SpValue::toCString()
+{
+    static char buf[1024];
+
+    switch(typ){
+    case TypeNil:
+        return "nil";
+    case TypeBool:
+        if(Bool){
+            return "true";
+        }else{
+            return "false";
+        }
+    case TypeInt:
+        sprintf(buf, "%d", Int);
+        break;
+    case TypeChar:
+        return spCharToCString(Char, *write_raw_encoder);
+    case TypeReal:
+        sprintf(buf, "%G", Real);
+        break;
+    case TypeObject:
+        return getObject()->toCString();
+    defaut:
+        throw SpException("System error: illegal object (toCString)");
+    }
+    return buf;
+}
+
+const char* SpValue::toCStringWithEncoder(WriteEncoder& encoder)
+{
+    static char buf[1024];
+
+    switch(typ){
+    case TypeNil:
+        return "nil";
+    case TypeBool:
+        if(Bool){
+            return "true";
+        }else{
+            return "false";
+        }
+    case TypeInt:
+        sprintf(buf, "%d", Int);
+        break;
+    case TypeChar:
+        return spCharToCString(Char, encoder);
+    case TypeReal:
+        sprintf(buf, "%G", Real);
+        break;
+    case TypeObject:
+        return getObject()->toCStringWithEncoder(encoder);
+    defaut:
+        throw SpException("System error: illegal object (toCStringWithEncoder)");
+    }
+    return buf;
+}
+
+SpValue& SpValue::toString()
+{
+    //    static SpValue val;
+    SpValue val;
+    if(this->isString()){
+        //        val = *this;
+        return *this;
+    }
+    //    val.setNewObject(new SpString(toCStringWithEncoder()));
+    //    return val;
+    return SpObjectResult(new SpString(toCStringWithEncoder()));
+}
+
+SpType SpValue::getType()
+{
+    if(typ == TypeObject){
+        return getObject()->getType();
+    }
+    return typ;
+}
+
+SpValue& SpValue::eval()
+{
+    if(typ == TypeObject){
+        SpObject* obj = getObject();
+        if(obj->canEval()){
+            //            return obj->eval();
+            SpValue result = obj->eval();
+            return SpValueResult(result);
+        }else{
+            return *this;
+            //            return SpValueResult(*this);
+        }
+    }
+    return *this;
+}
+
+SpValue& SpValue::onMessage(SpValue& msg)
+{
+    SpValue result;
+    if(typ == TypeObject){
+        SpObject* obj = getObject();
+        SpValue result = obj->onMessage(*this, msg);
+        return SpValueResult(result);
+    }
+    if(!msg.isSymbol()){
+        throw SpIllegalMessageException(msg);
+    }
+    switch(typ){
+    case TypeNil:
+        result = NilMsgHandler(*this, msg);
+       break;
+    case TypeBool:
+        result = BoolMsgHandler(*this, msg);
+       break;
+    case TypeInt:
+        result = IntMsgHandler(*this, msg);
+       break;
+    case TypeChar:
+        result = CharMsgHandler(*this, msg);
+       break;
+    case TypeReal:
+        result = RealMsgHandler(*this, msg);
+       break;
+    default:
+        throw SpException("system error: send message to not implemented type");
+    }
+    return SpValueResult(result);
+}
+
+/*
+ * +,-,*,/,etc
+ */
+SpValue& SpValue::uminus()
+{
+    //    static SpValue v;
+    SpValue v;
+
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator unary -");
+    case TypeInt:
+        v.typ = TypeInt;
+        v.Int = -Int;
+        break;
+    case TypeReal:
+        v.typ = TypeReal;
+        v.Real = -Real;
+        break;
+    case TypeObject:
+        v = getObject()->uminus(*this);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// +
+SpValue& SpValue::plus(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator +");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.typ = TypeInt;
+            v.Int = Int + e.Int;
+        }else if(e.typ == TypeReal){
+            v.typ = TypeReal;
+            v.Real = Int + e.Real;
+        }else{
+            throw SpException("type mismatch in +");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.typ = TypeReal;
+            v.Real = Real + e.Real;
+        }else if(e.typ == TypeInt){
+            v.typ = TypeReal;
+            v.Real = Real + e.Int;
+        }else{
+            throw SpException("type mismatch in +");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->plus(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// -
+SpValue& SpValue::minus(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator -");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.typ = TypeInt;
+            v.Int = Int - e.Int;
+        }else if(e.typ == TypeReal){
+            v.typ = TypeReal;
+            v.Real = Int - e.Real;
+        }else{
+            throw SpException("type mismatch in -");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.typ = TypeReal;
+            v.Real = Real - e.Real;
+        }else if(e.typ == TypeInt){
+            v.typ = TypeReal;
+            v.Real = Real - e.Int;
+        }else{
+            throw SpException("type mismatch in -");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->minus(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// *
+SpValue& SpValue::times(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator *");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.typ = TypeInt;
+            v.Int = Int * e.Int;
+        }else if(e.typ == TypeReal){
+            v.typ = TypeReal;
+            v.Real = Int * e.Real;
+        }else{
+            throw SpException("type mismatch in *");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.typ = TypeReal;
+            v.Real = Real * e.Real;
+        }else if(e.typ == TypeInt){
+            v.typ = TypeReal;
+            v.Real = Real * e.Int;
+        }else{
+            throw SpException("type mismatch in *");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->times(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// /
+SpValue& SpValue::div(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator /");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.typ = TypeInt;
+            v.Int = Int / e.Int;
+        }else if(e.typ == TypeReal){
+            v.typ = TypeReal;
+            v.Real = Int / e.Real;
+        }else{
+            throw SpException("type mismatch in /");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.typ = TypeReal;
+            v.Real = Real / e.Real;
+        }else if(e.typ == TypeInt){
+            v.typ = TypeReal;
+            v.Real = Real / e.Int;
+        }else{
+            throw SpException("type mismatch in /");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->div(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// %
+SpValue& SpValue::mod(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+    case TypeReal:
+        throw SpException("not defined operator %");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.typ = TypeInt;
+            v.Int = Int % e.Int;
+        }else{
+            throw SpException("type mismatch in %");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->mod(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// !
+SpValue& SpValue::boolNot()
+{
+    //    static SpValue v;
+    SpValue v;
+
+    v.typ = TypeBool;
+    switch(typ){
+    case TypeNil:
+    case TypeChar:
+    case TypeInt:
+    case TypeReal:
+        throw SpException("not defined operator !");
+    case TypeBool:
+        v.Bool = !Bool;
+        break;
+    case TypeObject:
+        v = getObject()->boolNot(*this);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// &&
+SpValue& SpValue::boolAnd(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    v.typ = TypeBool;
+    switch(typ){
+    case TypeNil:
+    case TypeChar:
+    case TypeInt:
+    case TypeReal:
+        throw SpException("not defined operator &&");
+    case TypeBool:
+        if(e.typ == TypeBool){
+            v.Bool = Bool && e.Bool;
+        }else{
+            throw SpException("type mismatch in &&");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->boolAnd(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// ||
+SpValue& SpValue::boolOr(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    v.typ = TypeBool;
+    switch(typ){
+    case TypeNil:
+    case TypeChar:
+    case TypeInt:
+    case TypeReal:
+        throw SpException("not defined operator ||");
+    case TypeBool:
+        if(e.typ == TypeBool){
+            v.Bool = Bool || e.Bool;
+        }else{
+            throw SpException("type mismatch in ||");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->boolOr(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// ==
+SpValue& SpValue::eq(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    v.typ = TypeBool;
+    v.Bool = false;
+    switch(typ){
+    case TypeNil:
+        if(e.typ == TypeNil){
+            v.Bool = true;
+        }
+        break;
+    case TypeBool:
+        if(e.typ == TypeBool){
+            v.Bool = Bool == e.Bool;
+        }
+        break;
+    case TypeChar:
+        if(e.typ == TypeChar){
+            v.Bool = Char == e.Char;
+        }
+        break;
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.Bool = Int == e.Int;
+        }else if(e.typ == TypeReal){
+            v.Bool = Int == e.Real;
+        }else{
+            throw SpException("type mismatch in ==");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.Bool = Real == e.Real;
+        }else if(e.typ == TypeInt){
+            v.Bool = Real == e.Int;
+        }else{
+            throw SpException("type mismatch in ==");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->eq(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// !=
+SpValue& SpValue::ne(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+    v = eq(e);
+    v.Bool = !v.Bool;
+    //    return v;
+    return SpValueResult(v);
+}
+
+// >
+SpValue& SpValue::gt(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    v.typ = TypeBool;
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator >");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.Bool = Int > e.Int;
+        }else if(e.typ == TypeReal){
+            v.Bool = Int > e.Real;
+        }else{
+            throw SpException("type mismatch in >");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.Bool = Real > e.Real;
+        }else if(e.typ == TypeInt){
+            v.Bool = Real > e.Int;
+        }else{
+            throw SpException("type mismatch in >");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->gt(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// >=
+SpValue& SpValue::ge(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    v.typ = TypeBool;
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator >=");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.Bool = Int >= e.Int;
+        }else if(e.typ == TypeReal){
+            v.Bool = Int >= e.Real;
+        }else{
+            throw SpException("type mismatch in >=");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.Bool = Real >= e.Real;
+        }else if(e.typ == TypeInt){
+            v.Bool = Real >= e.Int;
+        }else{
+            throw SpException("type mismatch in >=");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->ge(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// <
+SpValue& SpValue::lt(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    v.typ = TypeBool;
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator <");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.Bool = Int < e.Int;
+        }else if(e.typ == TypeReal){
+            v.Bool = Int < e.Real;
+        }else{
+            throw SpException("type mismatch in <");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.Bool = Real < e.Real;
+        }else if(e.typ == TypeInt){
+            v.Bool = Real < e.Int;
+        }else{
+            throw SpException("type mismatch in <");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->lt(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// <=
+SpValue& SpValue::le(SpValue& e)
+{
+    //    static SpValue v;
+    SpValue v;
+
+    v.typ = TypeBool;
+    switch(typ){
+    case TypeNil:
+    case TypeBool:
+    case TypeChar:
+        throw SpException("not defined operator <=");
+    case TypeInt:
+        if(e.typ == TypeInt){
+            v.Bool = Int <= e.Int;
+        }else if(e.typ == TypeReal){
+            v.Bool = Int <= e.Real;
+        }else{
+            throw SpException("type mismatch in <=");
+        }
+        break;
+    case TypeReal:
+        if(e.typ == TypeReal){
+            v.Bool = Real <= e.Real;
+        }else if(e.typ == TypeInt){
+            v.Bool = Real <= e.Int;
+        }else{
+            throw SpException("type mismatch in <=");
+        }
+        break;
+    case TypeObject:
+        v = getObject()->le(*this, e);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+// ::
+SpValue& SpValue::wcolon(SpValue& e2)
+{
+    if(!(e2.isList() || e2.isNil())){
+        throw SpException("tail is not list in ::");
+    }
+    SpCons* cons = new SpCons(*this, e2);
+    //    static SpValue v;
+    //    v.setNewObject(cons);
+    //    return v;
+    SpValue v;
+    v.setNewObject(cons);
+    //    return SpObjectResult(cons);
+    return SpValueResult(v);
+}
+
+// @
+SpValue& SpValue::at(SpValue& e2)
+{
+    //    static SpValue result;
+    SpValue result;
+
+    if(isNil()){
+        if(e2.isNil()){
+            return NilObject;
+        }else{
+            return SpValueResult(e2);
+        }
+    }
+    if(e2.isNil()){
+        result = *this;
+        //        return result;
+        return SpValueResult(result);
+    }
+
+    if(!e2.isList()){
+        throw SpException("tail is not list in @");
+    }
+    if(isCons()){
+      SpValue temp;
+      SpCons* ptr = dynamic_cast<SpCons*>(getObject());
+      //SpCons* head = new SpCons(ptr->value());
+      temp = ptr->value();
+      SpCons* head = new SpCons(temp);
+      SpCons* ptr2 = head;
+      SpValue next = ptr->nextList();
+      while(!next.isNil()){
+        SpCons* ptr = dynamic_cast<SpCons*>(next.getObject());
+        //SpCons* cons = new SpCons(ptr->value());
+       temp = ptr->value();
+        SpCons* cons = new SpCons(temp);
+        SpValue v(cons);
+        ptr2->setNext(v);
+        ptr2 = cons;
+        next = ptr->nextList();
+      }
+
+      ptr2->setNext(e2);
+      result.setNewObject(head);
+
+    }else
+    if(isList()){
+      SpAppendedList* a = new SpAppendedList(*this, e2, getCurrentNS());
+      result.setNewObject(a);
+
+    }else{
+      throw SpException("head is not list in @");
+    }
+    //    return result;
+    return SpValueResult(result);
+}
+
+
+/*
+ * pattern match
+ */
+
+bool SpValue::match(SpValue& val, SpNameSpace* ns)
+{
+    switch(typ){
+    case TypeNil:
+        if(val.typ == TypeNil){
+            return true;
+        }
+        break;
+    case TypeBool:
+        if(val.typ == TypeBool){
+            return Bool == val.Bool;
+        }
+        break;
+    case TypeChar:
+        if(val.typ == TypeChar){
+            return Char == val.Char;
+        }
+        break;
+    case TypeInt:
+        if(val.typ == TypeInt){
+            return Int == val.Int;
+        }
+        break;
+    case TypeReal:
+        if(val.typ == TypeReal){
+            return Real == val.Real;
+        }
+        break;
+    case TypeObject:
+        return getObject()->match(*this, val, ns);
+    }
+    return false;
+}
+
diff --git a/src/Prim.cpp b/src/Prim.cpp
new file mode 100644 (file)
index 0000000..597fec3
--- /dev/null
@@ -0,0 +1,443 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Prim.cpp,v 1.43 2004/05/22 05:22:34 randy Exp $
+ */
+
+#include <stdlib.h>
+#ifdef __WIN32__
+#include <process.h>
+#else
+#include <unistd.h>
+#endif /* __WIN32__ */
+
+#include "soopy.h"
+
+/*
+ * Primitive: arg length  0
+ */
+
+SpValue& SpPrim0::operator()(SpValue&)
+{
+    return func();
+}
+
+SpValue& SpPrim0::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<Primitive: arg length 0>";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * Primitive: arg length  1
+ */
+
+SpValue& SpPrim1::operator()(SpValue& arg)
+{
+    return func(arg);
+}
+
+SpValue& SpPrim1::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<Primitive: arg length 1>";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * Primitive: arg length  2
+ */
+
+SpValue& SpPrim2::operator()(SpValue& arg)
+{
+  if(arg.isTuple()){
+    SpTuple* tpl = arg.asTuple();
+    if(tpl->length() != 2){
+      throw SpException("too much args(primitive<2>)");
+    }
+    SpValue a1 = (*tpl)[0];
+    SpValue a2 = (*tpl)[1];
+    return operator()(a1, a2);
+  }
+
+  SpValue temp(this);
+  SpClosureP2* closure = new SpClosureP2(temp, arg, getCurrentNS());
+  //    static SpValue v;
+  //    v.setNewObject(closure);
+  //    return v;
+  return SpObjectResult(closure);
+}
+
+SpValue& SpPrim2::operator()(SpValue& arg1, SpValue& arg2)
+{
+    return func(arg1, arg2);
+}
+
+SpValue& SpPrim2::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<Primitive: arg length 2>";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+/*
+ * Primitive: arg length  3
+ */
+
+SpValue& SpPrim3::operator()(SpValue& arg)
+{
+  if(arg.isTuple()){
+    SpTuple* tpl = arg.asTuple();
+    if(tpl->length() != 3){
+      throw SpException("arg length mismatch(primitive<3>)");
+    }
+    SpValue a1 = (*tpl)[0];
+    SpValue a2 = (*tpl)[1];
+    SpValue a3 = (*tpl)[2];
+    return operator()(a1, a2, a3);
+  }
+
+    SpValue temp(this);
+    SpClosureP3_1* closure = new SpClosureP3_1(temp, arg, getCurrentNS());
+    //    static SpValue v;
+    //    v.setNewObject(closure);
+    //    return v;
+    return SpObjectResult(closure);
+}
+
+SpValue& SpPrim3::operator()(SpValue& arg1, SpValue& arg2)
+{
+    //    static SpValue v;
+    SpValue v;
+    if(arg2.isTuple()){
+        SpTuple* t = arg2.asTuple();
+        if(t->length() != 2){
+            throw SpException("too much args");
+        }
+        SpValue a2 = (*t)[0];
+        SpValue a3 = (*t)[1];
+        v = func(arg1, a2, a3);
+    }else{
+        SpValue temp(this);
+        SpClosureP3_2* closure = new SpClosureP3_2(temp, arg1, arg2, getCurrentNS());
+        v.setNewObject(closure);
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+SpValue& SpPrim3::operator()(SpValue& arg1, SpValue& arg2, SpValue& arg3)
+{
+    return func(arg1, arg2, arg3);
+}
+
+SpValue& SpPrim3::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<Primitive: arg length 3>";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+//
+// primitives
+//
+
+SpValue PrimPrint;
+SpValue PrimPrintLn;
+SpValue PrimLoad;
+
+SpValue& primPrint(SpValue& v)
+{
+    //*spout << v.eval().toString();
+    SpValue temp;
+    temp = v.eval();
+    temp = temp.toString();
+    *spout << temp;
+    return PrimPrint;
+}
+
+SpValue& primPrintLn(SpValue& v)
+{
+    //*spout << v.eval().toString() << "\n";
+    SpValue temp;
+    temp = v.eval();
+    temp = temp.toString();
+    *spout << temp << "\n";
+    return PrimPrintLn;
+}
+
+SpValue& primLoad(SpValue& v)
+{
+//    extern int load(const char*);
+    extern SpValue& load(const char*);
+
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (load)");
+    }
+    SpString* str = name.asString();
+    const char* filename = str->toCStringWithEncoder();
+  /*
+    int result = load(filename);
+    if(result < 0){
+        return FalseObject;
+    }
+    return TrueObject;
+  */
+  return load(filename);
+}
+
+SpValue& primOpenIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+#ifdef __WIN32__
+    fin->open(filename, ios::binary);
+#else
+    fin->open(filename);
+#endif
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+#ifdef EUC_JP
+    ReadEncoder* encoder = new EucJPReadDecoder(sr);
+#else
+    ReadEncoder* encoder = new SjisReadDecoder(sr);
+#endif
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& primOpenOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary);
+#else
+    fout->open(filename);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+#ifdef EUC_JP
+    WriteEncoder* encoder = new EucJPWriteEncoder(sw);
+#else
+    WriteEncoder* encoder = new SjisWriteEncoder(sw);
+#endif
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& primOpenAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary | ios_base::app);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+#ifdef EUC_JP
+    WriteEncoder* encoder = new EucJPWriteEncoder(sw);
+#else
+    WriteEncoder* encoder = new SjisWriteEncoder(sw);
+#endif
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& primSetReader(SpValue& reader)
+{
+  //if(reader.eq(SymSjisIn).isTrue()){
+  SpValue temp;
+  temp = reader.eq(SymSjisIn);
+  if(temp.isTrue()){
+      spin = sjisin;
+  }else if((temp = reader.eq(SymEucjpIn)).isTrue()){
+      spin = eucjpin;
+  }else{
+      throw SpException("no such a reader");
+  }
+  return TrueObject;
+}
+
+SpValue& primSystem(SpValue& arg)
+{
+    if(arg.isString()){
+        const char* cmd = arg.toCStringWithEncoder();
+        if(system(cmd) == -1){
+/*
+            switch(errno){
+            case ENOENT:
+                cout << "no entry\n";
+                break;
+            case ENOEXEC:
+                cout << "not exec\n";
+                break;
+            case ENOMEM:
+                cout << "no memory\n";
+                break;
+            default:
+                cout << "other error\n";
+            }
+*/
+            return FalseObject;
+        }
+        return TrueObject;
+    }
+    throw SpException("not string (system)");
+}
+
+SpValue& primExec(SpValue& arg)
+{
+    if(arg.isString()){
+        const char* cmd = arg.toCStringWithEncoder();
+        char* p = (char*)cmd;
+        p = strchr(p, ' ');
+        if(p == NULL){
+            p = (char*)cmd;
+            p = strchr(p, '\t');
+        }
+        if(p == NULL){
+            if(execlp(cmd,cmd,NULL) == -1){
+/*
+                switch(errno){
+                case EACCES:
+                    cout << "can't access\n";
+                    break;
+                    case EMFILE:
+                    cout << "too many opened files.\n";
+                    break;
+                case ENOENT:
+                    cout << "no entry\n";
+                    break;
+                case ENOEXEC:
+                    cout << "not exec\n";
+                    break;
+                case ENOMEM:
+                    cout << "no memory\n";
+                    break;
+                default:
+                    cout << "other error\n";
+                }
+*/
+                return FalseObject;
+            }
+        }else{
+            *p = '\0';
+            p++;
+//cout << "cmd: '" << cmd << "', p: '" << p << "'" << endl;
+            if(execlp(cmd,cmd,p,NULL) == -1){
+                return FalseObject;
+            }
+        }
+        return TrueObject;
+    }
+    throw SpException("not string (exec)");
+}
+
+SpValue& primQuit()
+{
+    exit(0);
+}
+
+void initPrim()
+{
+    // set global variables
+    SpValue SymPrint(new SpSymbol("print"));
+    PrimPrint.setNewObject(new SpPrim1(&primPrint));
+    PMainNameSpace->internConst(SymPrint, PrimPrint);
+
+    SpValue SymPrintLn(new SpSymbol("println"));
+    PrimPrintLn.setNewObject(new SpPrim1(&primPrintLn));
+    PMainNameSpace->internConst(SymPrintLn, PrimPrintLn);
+
+    SpValue SymLoad(new SpSymbol("load"));
+    PrimLoad.setNewObject(new SpPrim1(&primLoad));
+    PMainNameSpace->internConst(SymLoad, PrimLoad);
+
+    SpValue PrimOpenIn(new SpPrim1(&primOpenIn));
+    PMainNameSpace->internConst(SymOpenIn, PrimOpenIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&primOpenOut));
+    PMainNameSpace->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&primOpenAppend));
+    PMainNameSpace->internConst(SymOpenAppend, PrimOpenAppend);
+
+    SpValue SymSystem(new SpSymbol("system"));
+    SpValue PrimSystem(new SpPrim1(&primSystem));
+    PMainNameSpace->internConst(SymSystem, PrimSystem);
+
+    SpValue SymExec(new SpSymbol("exec"));
+    SpValue PrimExec(new SpPrim1(&primExec));
+    PMainNameSpace->internConst(SymExec, PrimExec);
+
+    SpValue SymQuit(new SpSymbol("quit"));
+    SpValue PrimQuit(new SpPrim0(&primQuit));
+    PMainNameSpace->internConst(SymQuit, PrimQuit);
+
+    // set 'SOOPY'
+    SpValue SymSetReader(new SpSymbol("setreader"));
+    SpValue PrimSetReader(new SpPrim1(primSetReader));
+    PSoopyNameSpace->internConst(SymSetReader, PrimSetReader);
+}
diff --git a/src/RAW.cpp b/src/RAW.cpp
new file mode 100644 (file)
index 0000000..d55e892
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: RAW.cpp,v 1.11 2004/05/22 05:22:34 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * RawFile
+ *   openIn, openOut
+ */
+
+SpValue& raw_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (RawFile.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+#ifdef __WIN32__
+    fin->open(filename, ios::binary);
+#else
+    fin->open(filename);
+#endif
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+
+    return SpObjectResult(sr);
+}
+
+SpValue& raw_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (RawFile.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary);
+#else
+    fout->open(filename);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    return SpObjectResult(sw);
+}
+
+SpValue& raw_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Raw.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    return SpObjectResult(sw);
+}
+
+void initRawFile()
+{
+    SpValue SymRawFile(new SpSymbol("raw"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSRawFile(ns);
+    PMainNameSpace->internConst(SymRawFile, NSRawFile);
+
+    SpValue PrimOpenIn(new SpPrim1(&raw_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&raw_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&raw_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+}
+
+
diff --git a/src/RW.cpp b/src/RW.cpp
new file mode 100644 (file)
index 0000000..d2b8a21
--- /dev/null
@@ -0,0 +1,943 @@
+/*
+ * Programming SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: RW.cpp,v 1.46 2007/01/29 11:46:16 randy Exp $
+ */
+
+#ifndef __BORLANDC__
+#include <stdio.h>
+#endif
+#include "soopy.h"
+
+/*
+ * class Reader
+ */
+
+/*
+ * class StreamReader
+ */
+
+SpValue& StreamReader::Read(SpInt n)
+{
+    if(eof()){
+        return NullString;
+    }
+
+    SpChar c;
+    SpString* str = new SpString;
+
+    unsigned char* buf = new unsigned char[n];
+    stream->read((char*)buf, n);
+    for(SpInt i=0; i < n; i++){
+        str->addSpChar(MakeSpChar(CodeJIS, buf[i]));
+    }
+    delete buf;
+
+    return SpObjectResult(str);
+}
+
+// n bytes \93Ç\82Ý\8d\9e\82Þ\81B
+// \8eÀ\8dÛ\82É\93Ç\82Ý\8d\9e\82ñ\82¾\83o\83C\83g\90\94\82ð\95Ô\82·
+SpValue& StreamReader::ReadByte(SpInt n, unsigned char* buf)
+{
+    if(eof()){
+        n = 0;
+    }else{
+#ifdef NO_READSOME
+      n = 0;
+      for( ; ; n++, buf++){
+        stream->read((char*)buf, 1);
+        if(stream->fail()){
+          break;
+        }
+      }
+#else
+        n = stream->readsome((char*)buf, n);
+#endif
+    }
+    if(stream->fail()){
+        throw SpFileException("can't readbyte");
+    }
+
+    return SpIntResult(n);
+}
+
+// n bytes \93Ç\82Ý\94ò\82Î\82·\81B
+// \8eÀ\8dÛ\82É\93Ç\82Ý\8d\9e\82ñ\82¾\83o\83C\83g\90\94\82ð\95Ô\82·
+SpValue& StreamReader::SkipByte(SpInt n)
+{
+    char* buf = new char[n];
+    try {
+        if(eof()){
+            n = 0;
+        }else{
+#ifdef NO_READSOME
+            n = 0;
+            for( ; ; n++, buf++){
+                stream->read((char*)buf, 1);
+                if(stream->fail()){
+                    break;
+                }
+            }
+#else
+            n = stream->readsome((char*)buf, n);
+#endif
+        }
+        if(stream->fail()){
+            throw SpFileException("can't skipbyte");
+        }
+    }catch(...){
+        delete[] buf;
+        throw;
+    }
+    delete[] buf;
+
+    return SpIntResult(n);
+}
+
+// StreamReader::ScanByte
+//   \83o\83C\83g\92P\88Ê\82Å\81A\83t\83H\81[\83}\83b\83g\82É\82µ\82½\82ª\82Á\82Ä\93Ç\82Ý\8d\9e\82Ý
+//   \92l\82ð\95Ô\82·\81B\95Ô\82·\92l\82ª\95¡\90\94\82Ì\8fê\8d\87\82É\82Í\83^\83v\83\8b\82ð\95Ô\82·\81B
+//  \81i\83o\83C\83g\82Ì\8ew\92è\82Í\95K\90{\81j
+//  ex.
+//    fin scanbyte "%4d";  # int(little endian)
+//    fin scanbyte "%4D";  # int(big endian)
+//    fin scanbyte "%4b";  # bytes \83o\83C\83g\94z\97ñ\82ð\95Ô\82·
+//    fin scanbyte "%4w";  # words (little endian) \83\8f\81[\83h\94z\97ñ\82ð\95Ô\82·
+//    fin scanbyte "%4W";  # words (big endian)    \83\8f\81[\83h\94z\97ñ\82ð\95Ô\82·
+//    fin scanbyte "?";    # skip a byte
+//    fin scanbyte "%5*";  # skip 5 bytes
+//    fin scanbyte "%8s";  # 8\83o\83C\83g\82ð\95\8e\9a\97ñ\82Æ\82µ\82Ä\93Ç\82Ý\8d\9e\82Þ
+//                         # \82à\82µfin\82ª\83G\83\93\83R\81[\83_\82Ì\82Æ\82«\82É\82Í\81A\82»\82Ì\83G\83\93\83R\81[\83_\82É\8f]\82Á\82Ä\89ð\8eß\82³\82ê\82é
+//
+//  \88È\89º\81A\83{\83c
+//    fin scanbyte "%10{sjis}";  # 10\83o\83C\83g\82ðsjis\83G\83\93\83R\81[\83_\82ð\8eg\82Á\82Ä\95\8e\9a\97ñ\82Æ\82µ\82Ä\93Ç\82Ý\8d\9e\82Þ
+//                               # {} \82Ì\82È\82©\82Ì\8e®\82Í\95]\89¿\82³\82ê\83G\83\93\83R\81[\83_\82Æ\82µ\82Ä\8eg\82í\82ê\82é(??)
+//
+SpValue& StreamReader::ScanByte(SpString* format, Reader* self)
+{
+    unsigned char byte;
+    SpValue result;
+    SpValue temp;
+    SpTuple* tpl = NULL;
+    SpCharVector::iterator it;
+
+    for(it = format->begin(); it != format->end(); it++){
+        if(*it == MakeSpChar(CodeJIS, '?')){  // '?' skip a byte
+            stream->seekg(1, ios::cur);
+            if(stream->fail()){
+                throw SpException("can't skip a byte (scanbyte)");
+            }
+        }else if(*it == MakeSpChar(CodeJIS, '%')){
+            SpInt no;
+            unsigned char* ptr;
+            uintvec bvec;
+            SpByteArray* bary;
+
+            it++;
+            if(!isDIGIT(*it)){
+                throw SpException("illegal format. not int (scanbyte)");
+            }
+            // \93Ç\82Ý\8d\9e\82Þ\83o\83C\83g\90\94\82ð\8cv\8eZ
+            int count = SpCharGetChar(*it) - '0';
+            for(it++; isDIGIT(*it); it++){
+                count = (count * 10) + SpCharGetChar(*it) - '0';
+            }
+            switch(SpCharGetChar(*it)){
+            case 'd':  // little endian
+                no = 0;
+                if(count > sizeof(SpInt)){
+                    throw SpException("too big size. (scanbyte '%d')");
+                }
+                ptr = (unsigned char*)&no;
+                for(int i=0; i < count; i++, ptr++){
+                 //#if defined(LINUX) || defined(OSX)
+                    stream->read((char*)ptr, 1);
+                   //#else
+                   //                    stream->read(ptr, 1);
+                   //#endif
+                    if(stream->fail()){
+                        throw SpException("can't read byte");
+                    }
+                }
+                // set result
+                if(result.isNil()){
+                    result.setInt(no);
+                }else if(tpl == NULL){
+                    tpl = new SpTuple(result);
+                    result.setObject(tpl);
+                    temp.setInt(no);
+                    tpl->append(temp);
+                }else{
+                    temp.setInt(no);
+                    tpl->append(temp);
+                }
+                break;
+            case 'D':  // big endian
+                no = 0;
+                if(count > sizeof(SpInt)){
+                    throw SpException("too big size. (scanbyte '%D')");
+                }
+                for(int i=0; i < count; i++){
+                 //#if defined(LINUX) || defined(OSX)
+                    stream->read((char*)&byte, 1);
+                   //#else
+                   //                    stream->read(&byte, 1);
+                   //#endif
+                    if(stream->fail()){
+                        throw SpException("can't read byte");
+                    }
+                    no = (no << 8) | byte;
+                }
+                // set result
+                if(result.isNil()){
+                    result.setInt(no);
+                }else if(tpl == NULL){
+                    tpl = new SpTuple(result);
+                    result.setObject(tpl);
+                    temp.setInt(no);
+                    tpl->append(temp);
+                }else{
+                    temp.setInt(no);
+                    tpl->append(temp);
+                }
+                break;
+            case 'b':  // byte
+                bvec.push_back(count);
+                bary = new SpByteArray(bvec);
+                ptr = bary->getBuffer();
+                for(int i=0; i < count; i++, ptr++){
+                 //#if defined(LINUX) || defined(OSX)
+                    stream->read((char*)&byte, 1);
+                   //#else
+                   //                    stream->read(&byte, 1);
+                   //#endif
+                    if(stream->fail()){
+                        throw SpException("can't read byte");
+                    }
+                    *ptr = byte;
+                }
+                // set result
+                if(result.isNil()){
+                    result.setObject(bary);
+                }else if(tpl == NULL){
+                    tpl = new SpTuple(result);
+                    result.setObject(tpl);
+                    temp.setObject(bary);
+                    tpl->append(temp);
+                }else{
+                    temp.setObject(bary);
+                    tpl->append(temp);
+                }
+                break;
+/*
+            case 'w':  // word (little endian)
+                break;
+            case 'W':  // word (little endian)
+                break;
+*/
+            case '*':  // '%n*' skip n bytes
+                stream->seekg(count, ios::cur);
+                if(stream->fail()){
+                    throw SpException("can't seek stream (scanbyte)");
+                }
+                break;
+            case 's':  // string
+                if(result.isNil()){
+                    result = self->ScanByteStr(count);
+                }else if(tpl == NULL){
+                    tpl = new SpTuple(result);
+                    result.setObject(tpl);
+                    temp = self->ScanByteStr(count);
+                    tpl->append(temp);
+                }else{
+                    temp = self->ScanByteStr(count);
+                    tpl->append(temp);
+                }
+                break;
+//            case '{':
+//                break;
+            default:
+                throw SpException("illegal format. (scanbyte)");
+            }
+        }else{
+            throw SpException("illegal format (scanbyte).");
+        }
+    }
+
+    return SpValueResult(result);
+}
+
+SpValue& StreamReader::ScanByteStr(int count)
+{
+    unsigned char byte;
+    SpValue result;
+    SpString* str = new SpString();
+    result.setNewObject(str);
+
+    for(int i=0; i < count; i++){
+      //#if defined(LINUX) || defined(OSX)
+      stream->read((char*)&byte, 1);
+      //#else
+      //        stream->read(&byte, 1);
+      //#endif
+        if(stream->fail()){
+            throw SpException("can't read string (scanbyte)");
+        }
+        str->addSpChar((SpChar)byte);
+    }
+    return SpValueResult(result);
+}
+
+class ScanByteStrReader : public Reader {
+private:
+    Reader* reader;
+    int index;
+    int max;
+
+public:
+    ScanByteStrReader(Reader* r, int n) : reader(r), max(n) {
+        index = 0;
+    }
+    SpChar readCh(){
+        if(eof()){
+            return (SpChar)NULL;
+        }
+        index++;
+        return reader->readCh();
+    }
+    bool eof(){
+        return reader->eof() || (index >= max);
+    }
+    bool is_open(){
+        return reader->is_open();
+    }
+};
+
+SpValue& ReadEncoder::ScanByteStr(int count)
+{
+    ScanByteStrReader* r = new ScanByteStrReader(reader, count);
+    SpValue taker;
+    taker.setNewObject(r);
+    SpValue result;
+
+    Reader* old_reader = reader;
+    setReader(r);
+    try{
+        result = ReadLine();
+    }catch(...){
+        setReader(old_reader);
+        throw;
+    }
+    setReader(old_reader);
+
+    return SpValueResult(result);
+}
+
+SpValue& Reader::ReadLine()
+{
+    if(eof()){
+        return NullString;
+    }
+
+    SpChar c;
+    SpString* str = new SpString;
+
+    while(true){
+        c = ReadChar();
+#ifdef __WIN32__
+        if(c == JIS(0x0d)){
+            SpChar c2 = ReadChar();
+            if(c2 == JIS(0x0a)){
+                break;
+            }else{
+                UnreadChar(c2);
+            }
+        }
+#endif
+        if(isEOL(c) || isEOF(c)){
+            break;
+        }
+        str->addSpChar(c);
+    }
+    return SpObjectResult(str);
+}
+
+SpValue& Reader::ReadLineS()
+{
+    if(eof()){
+        return NilObject;
+    }
+    SpValue line = ReadLine();
+
+    SpCons* head = new SpCons(line);
+    SpCons* ptr;
+    for(ptr=head; !eof() ; ptr=(SpCons*)ptr->next()){
+        line = ReadLine();
+        ptr->append(line);
+    }
+    return SpObjectResult(head);
+}
+
+SpValue& Reader::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<reader: '";
+    *str += getFilename();
+    *str += "'>";
+    return SpObjectResult(str);
+}
+
+SpValue& Reader::onMessage(SpValue& rec, SpValue& msg)
+{
+    return FileInMsgHandler(rec, msg);
+}
+
+// FileIn Primitives
+SpValue& Reader::prim_close(SpValue& fin)
+{
+    Reader* ptr = fin.asReader();
+    if(ptr == NULL){
+        throw SpException("not file_in (close)");
+    }
+    ptr->close();
+    return TrueObject;
+}
+
+SpValue& Reader::prim_readChar(SpValue& fin)
+{
+    Reader* ptr = fin.asReader();
+    if(ptr == NULL){
+        throw SpException("not reader (readChar)");
+    }
+    SpChar c = ptr->ReadChar();
+    return SpCharResult(c);
+}
+
+SpValue& Reader::prim_peekChar(SpValue& fin)
+{
+    Reader* ptr = fin.asReader();
+    if(ptr == NULL){
+        throw SpException("not reader (peekChar)");
+    }
+    SpChar c = ptr->ReadChar();
+    ptr->UnreadChar(c);
+    return SpCharResult(c);
+}
+
+SpValue& Reader::prim_unreadChar(SpValue& fin, SpValue& ch)
+{
+    Reader* ptr = fin.asReader();
+    if(ptr == NULL){
+        throw SpException("not reader (unreadChar)");
+    }
+    if(!ch.isChar()){
+        throw SpException("not char (unreadChar)");
+    }
+    ptr->UnreadChar(ch.getChar());
+    return TrueObject;
+}
+
+SpValue& Reader::prim_readLine(SpValue& fin)
+{
+    Reader* ptr = fin.asReader();
+    if(ptr == NULL){
+        throw SpException("not reader (readLine)");
+    }
+    return SpValueResult(ptr->ReadLine());
+}
+
+SpValue& Reader::prim_readLineS(SpValue& fin)
+{
+    Reader* ptr = fin.asReader();
+    if(ptr == NULL){
+        throw SpException("not reader (readLineS)");
+    }
+    return SpValueResult(ptr->ReadLineS());
+}
+
+SpValue& Reader::prim_eof(SpValue& fin)
+{
+    Reader* ptr = fin.asReader();
+    if(ptr == NULL){
+        throw SpException("not reader (eof)");
+    }
+    if(ptr->eof()){
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+SpValue& Reader::prim_closed(SpValue& fin)
+{
+    Reader* ptr = fin.asReader();
+    if(ptr == NULL){
+        throw SpException("not reader (closed)");
+    }
+    if(ptr->is_open()){
+        return FalseObject;
+    }
+    return TrueObject;
+}
+
+SpValue& Reader::prim_read(SpValue& fin, SpValue& n)
+{
+    Reader* ptr = fin.asReader();
+    if(!n.isInt()){
+        throw SpException("not int (read)");
+    }
+    SpInt i = n.getInt();
+    return SpValueResult(ptr->Read(i));
+}
+
+SpValue& Reader::prim_readbyte(SpValue& fin, SpValue& n, SpValue& byte_vector)
+{
+    Reader* ptr = fin.asReader();
+    if(!n.isInt()){
+        throw SpException("not int (readbyte)");
+    }
+    if(!byte_vector.isByteArray()){
+        throw SpException("not byte array(readbyte)");
+    }
+    SpInt i = n.getInt();
+    SpByteArray* ary = byte_vector.asByteArray();
+    if(i > ary->length()){
+        throw SpException("overflow (readbyte)");
+    }
+    unsigned char* buffer = ary->getBuffer();
+
+    return ptr->ReadByte(i, buffer);
+}
+
+SpValue& Reader::prim_skipbyte(SpValue& fin, SpValue& n)
+{
+    Reader* ptr = fin.asReader();
+    if(!n.isInt()){
+        throw SpException("not int (skipbyte)");
+    }
+    SpInt i = n.getInt();
+
+    return ptr->SkipByte(i);
+}
+
+SpValue& Reader::prim_scanbyte(SpValue& fin, SpValue& str)
+{
+    Reader* ptr = fin.asReader();
+    if(!str.isString()){
+        throw SpException("not string (scanbyte)");
+    }
+    SpString* s = str.asString();
+
+    return ptr->ScanByte(s, ptr);
+}
+
+// init Message Handler
+void Reader::init()
+{
+    SpValue PrimClose(new SpPrim1(prim_close));
+    FileInMsgHandler.append(SymClose, PrimClose);
+
+    SpValue SymReadChar(new SpSymbol("readchar"));
+    SpValue PrimReadChar(new SpPrim1(prim_readChar));
+    FileInMsgHandler.append(SymReadChar, PrimReadChar);
+
+    SpValue SymPeekChar(new SpSymbol("peekchar"));
+    SpValue PrimPeekChar(new SpPrim1(prim_peekChar));
+    FileInMsgHandler.append(SymPeekChar, PrimPeekChar);
+
+    SpValue SymUnreadChar(new SpSymbol("unreadchar"));
+    SpValue PrimUnreadChar(new SpPrim2(prim_unreadChar));
+    FileInMsgHandler.append(SymUnreadChar, PrimUnreadChar);
+
+    SpValue SymReadLine(new SpSymbol("readline"));
+    SpValue PrimReadLine(new SpPrim1(prim_readLine));
+    FileInMsgHandler.append(SymReadLine, PrimReadLine);
+
+    SpValue SymReadLineS(new SpSymbol("readlines"));
+    SpValue PrimReadLineS(new SpPrim1(prim_readLineS));
+    FileInMsgHandler.append(SymReadLineS, PrimReadLineS);
+
+    SpValue PrimIsEOF(new SpPrim1(prim_eof));
+    FileInMsgHandler.append(SymIsEOF, PrimIsEOF);
+
+    SpValue SymClosed(new SpSymbol("closed?"));
+    SpValue PrimClosed(new SpPrim1(prim_closed));
+    FileInMsgHandler.append(SymClosed, PrimClosed);
+
+    SpValue SymRead(new SpSymbol("read"));
+    SpValue PrimRead(new SpPrim2(prim_read));
+    FileInMsgHandler.append(SymRead, PrimRead);
+
+    SpValue SymReadByte(new SpSymbol("readbyte"));
+    SpValue PrimReadByte(new SpPrim3(prim_readbyte));
+    FileInMsgHandler.append(SymReadByte, PrimReadByte);
+
+    SpValue SymSkipByte(new SpSymbol("skipbyte"));
+    SpValue PrimSkipByte(new SpPrim2(prim_skipbyte));
+    FileInMsgHandler.append(SymSkipByte, PrimSkipByte);
+
+    SpValue SymScanByte(new SpSymbol("scanbyte"));
+    SpValue PrimScanByte(new SpPrim2(prim_scanbyte));
+    FileInMsgHandler.append(SymScanByte, PrimScanByte);
+}
+
+/*
+ * class Writer
+ */
+
+Writer& Writer::operator<<(const char* str)
+{
+  for(const char* ptr = str; *ptr; ptr++){
+    writeCh(*ptr);
+  }
+  return *this;
+}
+
+Writer& Writer::operator<<(const SpInt i)
+{
+  char buf[50];
+  sprintf(buf, "%d", i);
+  operator<<(buf);
+  return *this;
+}
+
+Writer& Writer::operator<<(const SpReal r)
+{
+  char buf[50];
+  sprintf(buf, "%g", r);
+  operator<<(buf);
+  return *this;
+}
+
+void Writer::writeTextTronCode(SpChar c)
+{
+  char buf[30];
+  sprintf(buf, "&T%06X;", c);
+  operator<<(buf);
+}
+
+void Writer::write(SpList* ptr)
+{
+    SpValue next;
+    SpList* list = ptr;
+
+    writeCh('[');
+    while(true){
+        // Write(list->value());
+        SpValue val;
+        val = list->value();
+        Write(val);
+        next = list->nextList();
+        if(next.isNil()){
+            break;
+        }
+        list = (SpList*)next.getObject();
+        writeCh(',');
+        writeCh(' ');
+    }
+    writeCh(']');
+}
+
+void Writer::write(SpObject& obj)
+{
+    SpValue v;
+    SpString* s;
+
+    if(obj.isList()){
+        SpList* list = (SpList*)&obj;
+        write(list);
+    }else{
+        if(obj.isString()){
+            s = (SpString*)&obj;
+        }else{
+            v = obj.toString();
+            s = dynamic_cast<SpString*>(v.getObject());
+        }
+        SpCharVector::iterator it;
+        for(it=s->str.begin(); it != s->str.end(); it++){
+            WriteChar(*it);
+        }
+    }
+}
+
+SpValue& Writer::Write(SpValue& val)
+{
+    if(!val.isObject()){
+        operator<<(val.toCStringWithEncoder());
+    }else{
+        SpObject* obj = val.getObject();
+        SpString* s;
+        if(obj->isList()){
+            SpList* list = (SpList*)obj;
+            write(list);
+        }else{
+            if(obj->isString()){
+                s = (SpString*)obj;
+            }else{
+                SpValue v = obj->toString();
+                s = dynamic_cast<SpString*>(v.getObject());
+            }
+            SpCharVector::iterator it;
+            for(it=s->str.begin(); it != s->str.end(); it++){
+                WriteChar(*it);
+            }
+        }
+    }
+    return TrueObject;
+}
+
+SpValue& Writer::WriteLine(SpValue& val)
+{
+    Write(val);
+    Terpri();
+    return TrueObject;
+}
+
+SpValue& Writer::WriteLineS(SpValue& list)
+{
+    if(list.isNil()){
+        return TrueObject;
+    }
+    if(!list.isList()){
+        throw SpException("not list(writer.writelines)");
+    }
+    SpList* ptr = list.asList();
+    for(; ptr != NULL; ptr = ptr->next()){
+        SpValue val;
+        val = ptr->value();
+        Write(val);
+        Terpri();
+    }
+    return TrueObject;
+}
+
+SpValue& Writer::Terpri()
+{
+    WriteChar(MakeSpChar(CodeJIS,'\n'));
+    flush();
+    return TrueObject;
+}
+
+/*
+ * class StreamWriter
+ */
+void StreamWriter::writeCh(unsigned char ch)
+{
+  *stream << (unsigned char)ch;
+}
+
+SpValue& StreamWriter::WriteByte(SpInt n, unsigned char* buf)
+{
+    stream->write((char*)buf, n);
+
+    if(stream->fail()){
+        throw SpFileException("can't writebyte");
+    }
+
+    return SpIntResult(n);
+}
+
+/*
+ * class WriteEncoder
+ */
+
+WriteEncoder& WriteEncoder::operator<<(SpValue& v)
+{
+    switch(v.typ){
+    case TypeNil:
+        *writer << "nil";
+        break;
+    case TypeBool:
+        if(v.Bool){
+            *writer << "true";
+        }else{
+            *writer << "false";
+        }
+        break;
+    case TypeInt:
+        *writer << v.Int;
+        break;
+    case TypeChar:
+        WriteChar(v.Char);
+        break;
+    case TypeReal:
+        *writer << v.Real;
+        break;
+    case TypeObject:
+        SpObject* obj = v.getObject();
+        operator<<(*obj);
+        break;
+    }
+    return *this;
+}
+
+static SpPrim2* ptrPrimWriteChar;
+static SpPrim2* ptrPrimWrite;
+static SpPrim2* ptrPrimWriteLine;
+static SpPrim2* ptrPrimWriteLineS;
+
+SpValue& Writer::toString()
+{
+    SpString* str;
+
+    str = new SpString();
+    *str = "#<output-file: '";
+    *str += getFilename();
+    *str += "'>";
+    return SpObjectResult(str);
+}
+
+SpValue& Writer::onMessage(SpValue& rec, SpValue& msg)
+{
+    return FileOutMsgHandler(rec, msg);
+}
+
+// FileOut Primitives
+SpValue& Writer::prim_close(SpValue& fout)
+{
+    Writer* ptr = fout.asWriter();
+    if(ptr == NULL){
+        throw SpException("not writer (close)");
+    }
+    ptr->close();
+    return TrueObject;
+}
+
+SpValue& Writer::prim_writeChar(SpValue& fout, SpValue& ch)
+{
+    Writer* ptr = fout.asWriter();
+    if(ptr == NULL){
+        throw SpException("not writer (writeChar)");
+    }
+    if(!ch.isChar()){
+        throw SpException("not char (writeChar)");
+    }
+    ptr->WriteChar(ch.getChar());
+    return (*ptrPrimWriteChar)(fout);
+}
+
+SpValue& Writer::prim_write(SpValue& fout, SpValue& val)
+{
+    Writer* ptr = fout.asWriter();
+    if(ptr == NULL){
+        throw SpException("not writer (write)");
+    }
+    ptr->Write(val);
+    return (*ptrPrimWrite)(fout);
+}
+
+SpValue& Writer::prim_writeLine(SpValue& fout, SpValue& val)
+{
+    Writer* ptr = fout.asWriter();
+    if(ptr == NULL){
+        throw SpException("not writer (writeLine)");
+    }
+    ptr->WriteLine(val);
+    return (*ptrPrimWriteLine)(fout);
+}
+
+SpValue& Writer::prim_writeLineS(SpValue& fout, SpValue& val)
+{
+    Writer* ptr = fout.asWriter();
+    if(ptr == NULL){
+        throw SpException("not writer (writeLine)");
+    }
+    ptr->WriteLineS(val);
+    return (*ptrPrimWriteLine)(fout);
+}
+
+SpValue& Writer::prim_flush(SpValue& fout)
+{
+    Writer* ptr = fout.asWriter();
+    if(ptr == NULL){
+        throw SpException("not writer (flush)");
+    }
+    ptr->flush();
+    return TrueObject;
+}
+
+SpValue& Writer::prim_terpri(SpValue& fout)
+{
+    Writer* ptr = fout.asWriter();
+    if(ptr == NULL){
+        throw SpException("not writer (flush)");
+    }
+    ptr->Terpri();
+    return TrueObject;
+}
+
+SpValue& Writer::prim_closed(SpValue& fout)
+{
+    Writer* ptr = fout.asWriter();
+    if(ptr == NULL){
+        throw SpException("not writer (closed)");
+    }
+    if(ptr->is_open()){
+        return FalseObject;
+    }
+    return TrueObject;
+}
+
+SpValue& Writer::prim_writebyte(SpValue& fout, SpValue& n, SpValue& byte_vector)
+{
+    Writer* ptr = fout.asWriter();
+    if(!n.isInt()){
+        throw SpException("not int (writebyte)");
+    }
+    if(!byte_vector.isByteArray()){
+        throw SpException("not byte array(writebyte)");
+    }
+    SpInt i = n.getInt();
+    SpByteArray* ary = byte_vector.asByteArray();
+    if(i > ary->length()){
+        throw SpException("overflow (writebyte)");
+    }
+    unsigned char* buffer = ary->getBuffer();
+
+    return  ptr->WriteByte(i, buffer);
+}
+
+
+// init Message Handler
+void Writer::init()
+{
+    SpValue PrimClose(new SpPrim1(prim_close));
+    FileOutMsgHandler.append(SymClose, PrimClose);
+
+    ptrPrimWriteChar = new SpPrim2(prim_writeChar);
+    SpValue PrimWriteChar(ptrPrimWriteChar);
+    FileOutMsgHandler.append(SymWriteChar, PrimWriteChar);
+
+    ptrPrimWrite = new SpPrim2(prim_write);
+    SpValue PrimWrite(ptrPrimWrite);
+    FileOutMsgHandler.append(SymWrite, PrimWrite);
+
+    ptrPrimWriteLine = new SpPrim2(prim_writeLine);
+    SpValue PrimWriteLine(ptrPrimWriteLine);
+    FileOutMsgHandler.append(SymWriteLine, PrimWriteLine);
+
+    SpValue SymWriteLineS(new SpSymbol("writelines"));
+    ptrPrimWriteLineS = new SpPrim2(prim_writeLineS);
+    SpValue PrimWriteLineS(ptrPrimWriteLineS);
+    FileOutMsgHandler.append(SymWriteLineS, PrimWriteLineS);
+
+    SpValue PrimFlush(new SpPrim1(prim_flush));
+    FileOutMsgHandler.append(SymFlush, PrimFlush);
+
+    SpValue PrimClosed(new SpPrim1(prim_closed));
+    FileOutMsgHandler.append(SymClosed, PrimClosed);
+
+    SpValue SymWriteByte(new SpSymbol("writebyte"));
+    SpValue PrimWriteByte(new SpPrim3(prim_writebyte));
+    FileOutMsgHandler.append(SymWriteByte, PrimWriteByte);
+}
+
diff --git a/src/Real.cpp b/src/Real.cpp
new file mode 100644 (file)
index 0000000..9771c1d
--- /dev/null
@@ -0,0 +1,347 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Real.cpp,v 1.7 2004/03/21 05:48:06 randy Exp $
+ */
+
+#include <math.h>
+#include "soopy.h"
+
+SpValue& real_toInt(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setInt((SpInt)v.getReal());
+    //    return res;
+    return SpIntResult((SpInt)v.getReal());
+}
+
+SpValue& real_toString(SpValue& v)
+{
+    SpString* str = new SpString;
+    *str += v;
+    //    static SpValue res;
+    //    res.setNewObject(str);
+    //    return res;
+    return SpObjectResult(str);
+}
+
+SpValue& real_acos(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(acos(v.getReal()));
+    //    return res;
+    return SpRealResult(acos(v.getReal()));
+}
+
+SpValue& real_asin(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(asin(v.getReal()));
+    //    return res;
+    return SpRealResult(asin(v.getReal()));
+}
+
+SpValue& real_atan(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(atan(v.getReal()));
+    //    return res;
+    return SpRealResult(atan(v.getReal()));
+}
+
+SpValue& real_atan2(SpValue& v, SpValue& v2)
+{
+    if(!v2.isReal()){
+        throw SpException("not real (atan2)");
+    }
+    //    static SpValue res;
+    //    res.setReal(atan2(v.getReal(), v2.getReal()));
+    //    return res;
+    return SpRealResult(atan2(v.getReal(), v2.getReal()));
+}
+
+SpValue& real_ceil(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(ceil(v.getReal()));
+    //    return res;
+    return SpRealResult(ceil(v.getReal()));
+}
+
+SpValue& real_cos(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(cos(v.getReal()));
+    //    return res;
+    return SpRealResult(cos(v.getReal()));
+}
+
+SpValue& real_cosh(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(cosh(v.getReal()));
+    //    return res;
+    return SpRealResult(cosh(v.getReal()));
+}
+
+SpValue& real_exp(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(exp(v.getReal()));
+    //    return res;
+  return SpRealResult(exp(v.getReal()));
+}
+
+SpValue& real_fabs(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(fabs(v.getReal()));
+    //    return res;
+    return SpRealResult(fabs(v.getReal()));
+}
+
+SpValue& real_floor(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(floor(v.getReal()));
+    //    return res;
+    return SpRealResult(floor(v.getReal()));
+}
+
+SpValue& real_fmod(SpValue& v, SpValue& v2)
+{
+    if(!v2.isReal()){
+        throw SpException("not real (fmod)");
+    }
+    //    static SpValue res;
+    //    res.setReal(fmod(v.getReal(), v2.getReal()));
+    //    return res;
+    return SpRealResult(fmod(v.getReal(), v2.getReal()));
+}
+
+SpValue& real_frexp(SpValue& v)
+{
+    int exponent;
+    SpReal r = frexp(v.getReal(), &exponent);
+    SpValue temp;
+    temp.setReal(r);
+    SpTuple* t = new SpTuple(temp);
+    temp.setInt(exponent);
+    t->append(temp);
+    //    static SpValue res;
+    //    res.setNewObject(t);
+    //    return res;
+    return SpObjectResult(t);
+}
+
+SpValue& real_hypot(SpValue& v, SpValue& v2)
+{
+    if(!v2.isReal()){
+        throw SpException("not real (hypot)");
+    }
+    //    static SpValue res;
+    //    res.setReal(hypot(v.getReal(), v2.getReal()));
+    //    return res;
+    return SpRealResult(hypot(v.getReal(), v2.getReal()));
+}
+
+SpValue& real_ldexp(SpValue& v, SpValue& v2)
+{
+    if(!v2.isInt()){
+        throw SpException("not int (ldexp)");
+    }
+    //    static SpValue res;
+    //    res.setReal(ldexp(v.getReal(), v2.getInt()));
+    //    return res;
+    return SpRealResult(ldexp(v.getReal(), v2.getInt()));
+}
+
+SpValue& real_log(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(log(v.getReal()));
+    //    return res;
+    return SpRealResult(log(v.getReal()));
+}
+
+SpValue& real_log10(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(log10(v.getReal()));
+    //    return res;
+    return SpRealResult(log10(v.getReal()));
+}
+
+SpValue& real_modf(SpValue& v)
+{
+    double ipart;
+    SpReal r = modf(v.getReal(), &ipart);
+    SpValue temp;
+    temp.setReal(r);
+    SpTuple* t = new SpTuple(temp);
+    temp.setReal(ipart);
+    t->append(temp);
+    //    static SpValue res;
+    //    res.setNewObject(t);
+    //    return res;
+    return SpObjectResult(t);
+}
+
+SpValue& real_pow(SpValue& v, SpValue& v2)
+{
+    if(!v2.isReal()){
+        throw SpException("not real (pow)");
+    }
+    //    static SpValue res;
+    //    res.setReal(pow(v.getReal(), v2.getReal()));
+    //    return res;
+    return SpRealResult(pow(v.getReal(), v2.getReal()));
+}
+
+SpValue& real_sin(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(sin(v.getReal()));
+    //    return res;
+  return SpRealResult(sin(v.getReal()));
+}
+
+SpValue& real_sinh(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(sinh(v.getReal()));
+    //    return res;
+    return SpRealResult(sinh(v.getReal()));
+}
+
+SpValue& real_sqrt(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(sqrt(v.getReal()));
+    //    return res;
+    return SpRealResult(sqrt(v.getReal()));
+}
+
+SpValue& real_tan(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(tan(v.getReal()));
+    //    return res;
+    return SpRealResult(tan(v.getReal()));
+}
+
+SpValue& real_tanh(SpValue& v)
+{
+    //    static SpValue res;
+    //    res.setReal(tanh(v.getReal()));
+    //    return res;
+    return SpRealResult(tanh(v.getReal()));
+}
+
+void initReal()
+{
+    RealMsgHandler.append(SymIsReal, PrimTrue);
+
+    SpValue SymToInt(new SpSymbol("toint"));
+    SpValue PrimToInt(new SpPrim1(real_toInt));
+    RealMsgHandler.append(SymToInt, PrimToInt);
+
+    SpValue PrimToString(new SpPrim1(real_toString));
+    RealMsgHandler.append(SymToString, PrimToString);
+
+    SpValue SymFabs(new SpSymbol("abs"));
+    SpValue PrimFabs(new SpPrim1(real_fabs));
+    RealMsgHandler.append(SymFabs, PrimFabs);
+
+    SpValue SymAcos(new SpSymbol("acos"));
+    SpValue PrimAcos(new SpPrim1(real_acos));
+    RealMsgHandler.append(SymAcos, PrimAcos);
+
+    SpValue SymAsin(new SpSymbol("asin"));
+    SpValue PrimAsin(new SpPrim1(real_asin));
+    RealMsgHandler.append(SymAsin, PrimAsin);
+
+    SpValue SymAtan(new SpSymbol("atan"));
+    SpValue PrimAtan(new SpPrim1(real_atan));
+    RealMsgHandler.append(SymAtan, PrimAtan);
+
+    SpValue SymAtan2(new SpSymbol("atan2"));
+    SpValue PrimAtan2(new SpPrim2(real_atan2));
+    RealMsgHandler.append(SymAtan2, PrimAtan2);
+
+    SpValue SymCeil(new SpSymbol("ceil"));
+    SpValue PrimCeil(new SpPrim1(real_ceil));
+    RealMsgHandler.append(SymCeil, PrimCeil);
+
+    SpValue SymCos(new SpSymbol("cos"));
+    SpValue PrimCos(new SpPrim1(real_cos));
+    RealMsgHandler.append(SymCos, PrimCos);
+
+    SpValue SymCosh(new SpSymbol("cosh"));
+    SpValue PrimCosh(new SpPrim1(real_cosh));
+    RealMsgHandler.append(SymCosh, PrimCosh);
+
+    SpValue SymExp(new SpSymbol("exp"));
+    SpValue PrimExp(new SpPrim1(real_exp));
+    RealMsgHandler.append(SymExp, PrimExp);
+
+    SpValue SymFloor(new SpSymbol("floor"));
+    SpValue PrimFloor(new SpPrim1(real_floor));
+    RealMsgHandler.append(SymFloor, PrimFloor);
+
+    SpValue SymFmod(new SpSymbol("fmod"));
+    SpValue PrimFmod(new SpPrim2(real_fmod));
+    RealMsgHandler.append(SymFmod, PrimFmod);
+
+    SpValue SymFrexp(new SpSymbol("frexp"));
+    SpValue PrimFrexp(new SpPrim1(real_frexp));
+    RealMsgHandler.append(SymFrexp, PrimFrexp);
+
+    SpValue SymHypot(new SpSymbol("hypot"));
+    SpValue PrimHypot(new SpPrim2(real_hypot));
+    RealMsgHandler.append(SymHypot, PrimHypot);
+
+    SpValue SymLdexp(new SpSymbol("ldexp"));
+    SpValue PrimLdexp(new SpPrim2(real_ldexp));
+    RealMsgHandler.append(SymLdexp, PrimLdexp);
+
+    SpValue SymLog(new SpSymbol("log"));
+    SpValue PrimLog(new SpPrim1(real_log));
+    RealMsgHandler.append(SymLog, PrimLog);
+
+    SpValue SymLog10(new SpSymbol("log10"));
+    SpValue PrimLog10(new SpPrim1(real_log10));
+    RealMsgHandler.append(SymLog10, PrimLog10);
+
+    SpValue SymPow(new SpSymbol("pow"));
+    SpValue PrimPow(new SpPrim2(real_pow));
+    RealMsgHandler.append(SymPow, PrimPow);
+
+    SpValue SymSin(new SpSymbol("sin"));
+    SpValue PrimSin(new SpPrim1(real_sin));
+    RealMsgHandler.append(SymSin, PrimSin);
+
+    SpValue SymSinh(new SpSymbol("sinh"));
+    SpValue PrimSinh(new SpPrim1(real_sinh));
+    RealMsgHandler.append(SymSinh, PrimSinh);
+
+    SpValue SymSqrt(new SpSymbol("sqrt"));
+    SpValue PrimSqrt(new SpPrim1(real_sqrt));
+    RealMsgHandler.append(SymSqrt, PrimSqrt);
+
+    SpValue SymTan(new SpSymbol("tan"));
+    SpValue PrimTan(new SpPrim1(real_tan));
+    RealMsgHandler.append(SymTan, PrimTan);
+
+    SpValue SymTanh(new SpSymbol("tanh"));
+    SpValue PrimTanh(new SpPrim1(real_tanh));
+    RealMsgHandler.append(SymTanh, PrimTanh);
+}
+
diff --git a/src/SendMsg.cpp b/src/SendMsg.cpp
new file mode 100644 (file)
index 0000000..6e14332
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: SendMsg.cpp,v 1.13 2004/03/26 11:17:12 randy Exp $
+ */
+
+
+#include "soopy.h"
+
+/*
+ * Class SpSendMsg
+ */
+
+SpSendMsg::~SpSendMsg()
+{
+#ifdef TEST
+    *spout << ":destroy SpSendMsg:\n";
+#endif
+}
+
+SpValue& SpSendMsg::eval()
+{
+    SpValue result;
+    SpValue val = receiver.eval();
+    if(message.isSymbol()  && !val.isFunc()){
+        //return val.onMessage(message);
+        result = val.onMessage(message);
+        return SpValueResult(result);
+    }
+    SpValue msg = message.eval();
+    //    return val.onMessage(msg);
+    result = val.onMessage(msg);
+    return SpValueResult(result);
+}
+
+SpValue& SpSendMsg::toString()
+{
+    SpString* str;
+    SpValue v1, v2;
+
+    str = new SpString();
+    //*str += "(";
+    *str += receiver.toString();
+    *str += " (";
+    *str += message.toString();
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+bool SpSendMsg::operator==(SpObject& obj)
+{
+    SpSendMsg* ptr = dynamic_cast<SpSendMsg*>(&obj);
+    if(ptr != NULL){
+        return (receiver == ptr->receiver) &&
+                (message == ptr->message);
+    }
+    return false;
+}
+
+bool SpSendMsg::operator<(SpObject& obj)
+{
+    SpSendMsg* ptr = dynamic_cast<SpSendMsg*>(&obj);
+    if(ptr != NULL){
+        if(receiver != ptr->receiver){
+            return receiver < ptr->receiver;
+        }
+        return message < ptr->message;
+    }
+    return SpObject::operator<(obj);
+}
+
diff --git a/src/SjisRW.cpp b/src/SjisRW.cpp
new file mode 100644 (file)
index 0000000..ff3df0c
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: SjisRW.cpp,v 1.28 2004/05/22 05:22:34 randy Exp $
+ */
+
+#ifdef __WIN32__
+#include <io.h>
+#else
+#include <unistd.h>
+#include <stdio.h>
+#endif
+
+#include "soopy.h"
+
+/*
+ * Class SjisReadEncoder
+ *   TronCode -> Sjis
+ */
+
+SpChar SjisReadEncoder::readCh()
+{
+    SpChar c, ch, ch2, ku, ten;
+
+    if(count >= 0){
+        return buf[count--];
+    }
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+//printf("w-code: %x\n", c);
+    if(isEOF(c)){ return (SpChar)NULL; }
+
+    if(!EqualCharCode(c, CodeJIS)){
+        return c;
+    }
+
+    ch = SpCharGetChar(c);
+    ku = (ch >> 8);
+    ten = (ch & 0xFF);
+    if(ku == 0){
+        return ten;
+    }else{
+        ku  -= 0x20;
+        ten -= 0x20;
+        // first byte
+        if(ku < 63){
+//printf("ku1: %x\n", (unsigned char)(0x81 + ((ku-1)>>1)));
+            ch2 = ((unsigned char)(0x81 + ((ku-1)>>1)));
+        }else{
+//printf("ku2: %x\n", (unsigned char)(0xE0 + ((ku-63)>>1)));
+            ch2 = ((unsigned char)(0xE0 + ((ku-63)>>1)));
+        }
+        // second byte
+        if(ku & 1){
+            if(ten < 0x3F){
+//printf("ten1: %x\n", (unsigned char)(ten + 0x3F));
+                buf[0] = ((unsigned char)(ten + 0x3F));
+            }else{
+//printf("ten2: %x\n", (unsigned char)(ten + 0x40));
+                buf[0] = ((unsigned char)(ten + 0x40));
+            }
+        }else{
+//printf("ten3: %x\n", (unsigned char)(0x9E + ten));
+            buf[0] = ((unsigned char)(0x9E + ten));
+        }
+        count = 0;
+    }
+    return ch2;
+}
+
+/*
+ * Class SjisReadDecoder
+ *   Sjis -> TronCode
+ */
+
+SpChar SjisReadDecoder::readCh()
+{
+    SpChar c;
+    int ch1, ch2;
+    int ku, ten, base1, base2;
+    if(eof()){ return (SpChar)NULL; }
+    c = reader->ReadChar();
+    if(isEOF(c)){ return (SpChar)NULL; }
+    ch1 = c & 0xff;
+    if(ch1 > 0x7F){
+        /*
+        if(0xA1 <= ch1 && ch1 <= 0xDF){ // when hankaku KANA
+            // return Zenkaku KANA
+        }
+        */
+        if((0x81 <= ch1 && ch1 <= 0x9F) 
+           || (0xE0 <= ch1 && ch1 <= 0xEF)) // JIS X 0208
+        {
+            if(eof()){ return (SpChar)NULL; }
+            c = reader->ReadChar();
+            ch2 = c & 0xff;
+            base1 = ch1 < 0xA0 ? 0x80 : 0xDF;
+            base2 = ch1 < 0xA0 ? 0 : 62;
+            //if(ch2 < 0x9E){
+            if(ch2 < 0x9F){
+                ku = ((ch1 - base1)<<1) - 1 + base2;
+                ten = ch2 - (ch2 < 0x7F ? 0x3F : 0x40);
+            }else{
+                ku = ((ch1 - base1)<<1) + base2;
+                ten = ch2 - 0x9E;
+            }
+            ku += 0x20;
+            ten += 0x20;
+//printf("ch: %x\n", MakeSpChar(CodeJIS, (ku<<8) | ten));
+            return MakeSpChar(CodeJIS, (ku<<8) | ten);
+        }else{
+            return MakeSpChar(CodeJIS, '?');
+        }
+    }
+//printf("ch2: %x\n", MakeSpChar(CodeJIS, c));
+    return MakeSpChar(CodeJIS, c);
+}
+
+/*
+ * Class SjisWriteEncoder
+ *   TronCode -> Sjis
+ */
+
+void SjisWriteEncoder::WriteChar(SpChar c)
+{
+    int ch, ku, ten;
+
+//printf("w-code--: %x\n", c);
+    if(!EqualCharCode(c, CodeJIS)){
+        writeTextTronCode(c);
+        return;
+    }
+    ch = SpCharGetChar(c);
+    ku = (ch >> 8);
+    ten = (ch & 0xFF);
+    if(ku == 0){
+        writer->WriteChar(ten);
+    }else{
+        ku  -= 0x20;
+        ten -= 0x20;
+        // put first byte
+        if(ku < 63){
+//printf("ku_1: %x\n", (unsigned char)(0x81 + ((ku-1)>>1)));
+            writer->WriteChar((unsigned char)(0x81 + ((ku-1)>>1)));
+        }else{
+//printf("ku_2: %x\n", (unsigned char)(0xE0 + ((ku-63)>>1)));
+             writer->WriteChar((unsigned char)(0xE0 + ((ku-63)>>1)));
+        }
+        // put second byte
+        if(ku & 1){
+            if(ten < 0x3F){
+//printf("ten_1: %x\n", (unsigned char)(ten + 0x3F));
+                writer->WriteChar((unsigned char)(ten + 0x3F));
+            }else{
+//printf("ten_2: %x\n", (unsigned char)(ten + 0x40));
+                writer->WriteChar((unsigned char)(ten + 0x40));
+            }
+        }else{
+//printf("ten_3: %x\n", (unsigned char)(0x9E + ten));
+            writer->WriteChar((unsigned char)(0x9E + ten));
+        }
+    }
+}
+
+
+/*
+ * Class SjisWriteDecoder
+ *   Sjis -> TronCode
+ */
+
+void SjisWriteDecoder::WriteChar(SpChar c)
+{
+    int ch2;
+    int ku, ten, base1, base2;
+
+    if(count == 0){
+        if(c > 0xFF){ // not sjis
+            if(isEOL(c)){
+                writer->WriteChar(c);
+            }else{
+                writeTextTronCode(c);
+            }
+        }else if(c > 0x7F){
+            /*
+            if(0xA1 <= ch1 && ch1 <= 0xDF){ // when hankaku KANA
+                // write Zenkaku KANA
+            }
+            */
+            ch1 = c;
+            count++;
+        }else{
+            writer->WriteChar(c);
+        }
+        return;
+    }
+    // count == 1
+    count = 0;
+    if((0x81 <= ch1 && ch1 <= 0x9F) 
+       || (0xE0 <= ch1 && ch1 <= 0xEF)) // JIS X 0208
+    {
+        ch2 = c;
+        base1 = ch1 < 0xA0 ? 0x80 : 0xDF;
+        base2 = ch1 < 0xA0 ? 0 : 62;
+        if(ch2 < 0x9F){
+            ku = ((ch1 - base1)<<1) - 1 + base2;
+            ten = ch2 - (ch2 < 0x7F ? 0x3F : 0x40);
+        }else{
+            ku = ((ch1 - base1)<<1) + base2;
+            ten = ch2 - 0x9E;
+        }
+        ku += 0x20;
+        ten += 0x20;
+        writer->WriteChar(MakeSpChar(CodeJIS, (ku<<8) | ten));
+    }else{
+        writer->WriteChar(MakeSpChar(CodeJIS, '?'));
+    }
+}
+
+
+/*
+ * SjisFile
+ *   openIn, openOut
+ */
+
+SpValue& sjis_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Sjis.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+#ifdef __WIN32__
+    fin->open(filename, ios::binary);
+#else
+    fin->open(filename);
+#endif
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new SjisReadDecoder(sr);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& sjis_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Sjis.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary);
+#else
+    fout->open(filename);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new SjisWriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& sjis_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Sjis.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new SjisWriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& sjis_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (Sjis.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new SjisReadEncoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& sjis_decoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (Sjis.decoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new SjisReadDecoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& sjis_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (Sjis.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new SjisWriteEncoder(writer);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& sjis_decoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (Sjis.decoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new SjisWriteDecoder(writer);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+// init
+void initSjisFile()
+{
+    SpValue SymSjis(new SpSymbol("sjis"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSSjis(ns);
+    PMainNameSpace->internConst(SymSjis, NSSjis);
+
+    SpValue PrimOpenIn(new SpPrim1(&sjis_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+    SpValue PrimEncoderIn(new SpPrim1(&sjis_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+    SpValue PrimDecoderIn(new SpPrim1(&sjis_decoderIn));
+    ns->internConst(SymDecoderIn, PrimDecoderIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&sjis_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+    SpValue PrimOpenAppend(new SpPrim1(&sjis_openAppend));
+    ns->internConst(SymOpenAppend, PrimOpenAppend);
+    SpValue PrimEncoderOut(new SpPrim1(&sjis_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+    SpValue PrimDecoderOut(new SpPrim1(&sjis_decoderOut));
+    ns->internConst(SymDecoderOut, PrimDecoderOut);
+}
+
diff --git a/src/Socket.cpp b/src/Socket.cpp
new file mode 100644 (file)
index 0000000..659e5fa
--- /dev/null
@@ -0,0 +1,530 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Socket.cpp,v 1.15 2007/01/30 05:00:48 randy Exp $
+ */
+
+#ifdef __WIN32__
+#include <dos.h>
+#else
+#include <unistd.h>
+#endif
+
+#include <netdb.h>
+
+#include "soopy.h"
+
+#ifdef USE_SOCKET
+
+#ifndef INVALID_SOCKET
+#define INVALID_SOCKET -1
+#endif
+
+#ifndef SOCKET_ERROR
+#define SOCKET_ERROR -1
+#endif
+
+/*
+ * Socket
+ *   -close
+ *   -eof?
+ *   -write string     -- send string
+ *   -writeline string -- write one line
+ *   -readline         -- read one line
+ *   -receive n        -- receive n byte data
+ */
+
+/*
+ * ClientSocket
+ *   +open(adr, port)  -- open socket
+ */
+
+/*
+ * ServerSocket
+ *   +open port        -- open server socket
+ *   -close
+ *   -accept           -- return Socket
+ */
+
+
+//
+// class BaseSocket
+//
+void BaseSocket::close()
+{
+    shutdown(sock, 2);
+#ifdef __WIN32__
+    closesocket(sock);
+#else
+    ::close(sock);
+#endif
+    isOpen = false;
+}
+
+//
+// class Socket
+//
+SpValue& Socket::toString()
+{
+    SpString* str = new SpString("<socket>");
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+void Socket::open()
+{
+    unsigned long serveraddr;
+    struct hostent* hent;
+    struct sockaddr_in sockadd;
+
+    /* create socket */
+    if((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET){
+        throw SpException("can't open socket");
+    }
+    serveraddr = inet_addr(hostname);
+    if(serveraddr != INADDR_NONE){
+        sockadd.sin_addr.s_addr = serveraddr;
+    }else{
+      if((hent = gethostbyname(hostname)) == NULL){
+          throw SpException("can't get hostbyname");
+      }
+      memcpy(&sockadd.sin_addr, hent->h_addr, hent->h_length);
+    }
+    sockadd.sin_family = AF_INET;
+    sockadd.sin_port = htons(port);
+
+    /* connect */
+    for(int loop=0;
+        0 != connect(sock, (struct sockaddr*)&sockadd, sizeof(sockadd));
+        loop++)
+    {
+        if(10 < loop){
+            throw SpException("can't connect socket");
+        }
+#ifdef __WIN32__
+        _sleep(1);
+#else
+        sleep(1);
+#endif
+    }
+    isOpen = true;
+    receive_end = false;
+}
+
+void Socket::read_buffer()
+{
+    read_bytes = recv(sock, buff[which_buf], BUFFSIZE-1, 0);
+    if(read_bytes == SOCKET_ERROR){
+        throw SpException("socket error");
+    }
+    if(read_bytes == 0){
+        receive_end = true;
+    }
+    if(read_bytes < 0){
+        throw SpException("can't read socket");
+    }
+    buff[which_buf][read_bytes] = '\0';
+    already_read[which_buf] = true;
+    read_point = 0;
+}
+
+SpChar Socket::readCh()
+{
+    if(eof()){
+        return (SpChar)NULL;
+    }
+    if(read_point >= read_bytes){
+        next_buf();
+    }
+    if(!already_read[which_buf]){
+        read_buffer();
+    }
+    if(receive_end){
+        return (SpChar)NULL;
+//        throw SpException("end of socket");
+    }
+    return buff[which_buf][read_point++];
+}
+
+SpValue& Socket::receive(SpInt n, unsigned char* buffer)
+{
+    read_bytes = recv(sock, buffer, n, 0);
+
+    if(read_bytes == SOCKET_ERROR){
+        throw SpException("socket error: can't receive");
+    }
+    if(read_bytes == 0){
+        receive_end = true;
+    }
+    if(read_bytes < 0){
+        throw SpException("can't read socket");
+    }
+
+    //    static SpValue result;
+    //    result.setInt(read_bytes);
+    //    return result;
+    return SpIntResult(read_bytes);
+}
+
+SpValue& Socket::send_buffer(SpInt n, unsigned char* buffer)
+{
+    int i = send(sock, buffer, n, 0);
+
+    if(i == SOCKET_ERROR){
+        throw SpException("socket error: can't write");
+    }
+
+    //    static SpValue result;
+    //    result.setInt(i);
+    //    return result;
+    return SpIntResult(i);
+}
+
+void Socket::flush()
+{
+    if(write_point <= 0){ return; }
+    int result = send(sock, wbuff, write_point, 0);
+    if(result == SOCKET_ERROR){
+        throw SpException("socket error: can't write");
+    }
+    write_point = 0;
+}
+
+void Socket::writeCh(unsigned char ch)
+{
+    wbuff[write_point] = ch;
+    write_point++;
+    if(write_point >= BUFFSIZE){
+        flush();
+    }
+}
+
+bool Socket::eof()
+{
+    if(receive_end){
+        if(read_point < (read_bytes - 1)){
+            return false;
+        }else{
+            return true;
+        }
+    }
+    return false;
+}
+
+void Socket::write(char* str)
+{
+    flush();
+    int result = send(sock, str, strlen(str), 0);
+    if(result == SOCKET_ERROR){
+        throw SpException("socket error: can't write");
+    }
+}
+
+/*
+ * primitives
+ */
+
+SpValue& Socket::prim_getname(SpValue& adr){
+    if(!adr.isString()){
+        throw SpException("not string. (socket.open)");
+    }
+    SpString* address = adr.asString();
+
+    char hbuf[NI_MAXHOST];
+    struct sockaddr_in sa;    /* input */
+    memset(&sa, 0, sizeof(sa));
+    sa.sin_family = AF_INET;
+    sa.sin_port = htons(80); // dummy
+    inet_aton((char*)address->toCStringWithEncoder(), &sa.sin_addr);
+
+//    if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf),
+    if (getnameinfo((sockaddr*)&sa, sizeof(sa), hbuf, sizeof(hbuf),
+                   NULL, 0, NI_NAMEREQD))
+    {
+       return NilObject;
+    }else{
+       return SpObjectResult(new SpString(hbuf));
+    }
+}
+
+// client Socket open
+SpValue& Socket::prim_open(SpValue& adr, SpValue& port)
+{
+    if(!adr.isString()){
+        throw SpException("not string. (socket.open)");
+    }
+    SpString* address = adr.asString();
+    if(!port.isInt()){
+        throw SpException("not int. (socket.open)");
+    }
+    SpInt port_no = port.getInt();
+
+    Socket* sock = new Socket(port_no, (char*)address->toCStringWithEncoder());
+    sock->open();
+    //    static SpValue result;
+    //    result.setNewObject(sock);
+    //    return result;
+    return SpObjectResult(sock);
+}
+
+SpValue& Socket::prim_close(SpValue& self)
+{
+    Socket* sock = self.asSocket();
+    sock->close();
+    return TrueObject;
+}
+
+SpValue& Socket::prim_eof(SpValue& self)
+{
+    Socket* sock = self.asSocket();
+    if(sock->eof()){
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+SpValue& Socket::prim_write(SpValue& self, SpValue& str)
+{
+    Socket* sock = self.asSocket();
+    if(!str.isString()){
+        throw SpException("not string (socket.write)");
+    }
+    SpString* s = str.asString();
+    sock->write((char*)s->toCStringWithEncoder());
+    return TrueObject;
+}
+
+SpValue& Socket::prim_writeline(SpValue& self, SpValue& str)
+{
+    Socket* sock = self.asSocket();
+    if(!str.isString()){
+        throw SpException("not string (socket.write)");
+    }
+    SpString* s = str.asString();
+    SpString s2(*s);
+    s2 += "\r\n";
+    sock->write((char*)s2.toCStringWithEncoder());
+    sock->flush();
+    return TrueObject;
+}
+
+SpValue& Socket::prim_receive(SpValue& self, SpValue& n, SpValue& byte_vector)
+{
+    if(!n.isInt()){
+        throw SpException("not integer(socket.receive)");
+    }
+    if(!byte_vector.isByteArray()){
+        throw SpException("not byte array(socket.receive)");
+    }
+    Socket* sock = self.asSocket();
+    SpInt i = n.getInt();
+    SpByteArray* ary = byte_vector.asByteArray();
+    if(i > ary->length()){
+        throw SpException("overflow (socket.receive)");
+    }
+    unsigned char* buffer = ary->getBuffer();
+    return sock->receive(i, buffer);
+}
+
+SpValue& Socket::prim_send(SpValue& self, SpValue& n, SpValue& byte_vector)
+{
+    if(!n.isInt()){
+        throw SpException("not integer(socket.send)");
+    }
+    if(!byte_vector.isByteArray()){
+        throw SpException("not byte array(socket.send)");
+    }
+    Socket* sock = self.asSocket();
+    SpInt i = n.getInt();
+    SpByteArray* ary = byte_vector.asByteArray();
+    if(i > ary->length()){
+        throw SpException("overflow (socket.send)");
+    }
+    unsigned char* buffer = ary->getBuffer();
+    return sock->send_buffer(i, buffer);
+}
+
+
+// init Message Handler
+SpValue& Socket::onMessage(SpValue& rec, SpValue& msg)
+{
+    return SocketMsgHandler(rec, msg);
+}
+
+void Socket::init()
+{
+    /* Client Socket */
+    // set namespace to symbol 'socket'.
+    SpNameSpace* PSocketNameSpace = new SpNameSpace;
+    SpValue SocketNS;
+    SocketNS.setNewObject(PSocketNameSpace);
+    SpValue SymSocket(new SpSymbol("socket"));
+    PMainNameSpace->internConst(SymSocket, SocketNS);
+    // Socket open adr port
+    SpValue PrimOpen(new SpPrim2(prim_open));
+    PSocketNameSpace->internFunc(SymOpen, PrimOpen);
+    // getname
+    SpValue PrimGetName(new SpPrim1(prim_getname));
+    SpValue SymGetName(new SpSymbol("getname"));
+    PSocketNameSpace->internFunc(SymGetName, PrimGetName);
+
+    // setup primitives
+    SpValue PrimClose(new SpPrim1(prim_close));
+    SocketMsgHandler.append(SymClose, PrimClose);
+
+    SpValue PrimEof(new SpPrim1(prim_eof));
+    SocketMsgHandler.append(SymIsEOF, PrimEof);
+
+    SpValue PrimWrite(new SpPrim2(prim_write));
+    SocketMsgHandler.append(SymWrite, PrimWrite);
+
+    SpValue PrimWriteLine(new SpPrim2(prim_writeline));
+    SocketMsgHandler.append(SymWriteLine, PrimWriteLine);
+
+    SpValue PrimReadLine(new SpPrim1(prim_readLine));
+    SocketMsgHandler.append(SymReadLine, PrimReadLine);
+
+    SpValue SymReceive(new SpSymbol("receive"));
+    SpValue PrimReceive(new SpPrim3(prim_receive));
+    SocketMsgHandler.append(SymReceive, PrimReceive);
+
+    SpValue SymSend(new SpSymbol("send"));
+    SpValue PrimSend(new SpPrim3(prim_send));
+    SocketMsgHandler.append(SymSend, PrimSend);
+
+    ServerSocket::init();
+
+#ifdef __WIN32__
+    WORD wVersionRequested = MAKEWORD(1, 1);
+    WSADATA wsaData;
+    int err = WSAStartup(wVersionRequested, &wsaData);
+    if(atexit((void(*)(void))(WSACleanup))){
+        throw SpException("atexit(WSACleanup)");
+    }
+    if(err != 0){
+        throw SpException("can't initialize WinSock");
+    }
+#endif
+
+}
+
+/*
+ * Server Socket
+ */
+
+SpValue& ServerSocket::toString()
+{
+    SpString* str = new SpString("<server socket>");
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+const int BACKLOG = 5;
+
+void ServerSocket::open()
+{
+    /* create socket */
+    if((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET){
+        throw SpException("can't open ServerSocket");
+    }
+    sockadd.sin_port = htons(port);
+    sockadd.sin_family = AF_INET;
+    memset(&sockadd.sin_addr, 0, sizeof(sockadd.sin_addr));
+
+    /* bind */
+    if(bind(sock, (sockaddr*)&sockadd, sizeof(sockadd)) != 0){
+        throw SpException("can't bind ServerSocket");
+    }
+    /* listen */
+    if(listen(sock, BACKLOG) != 0){
+        throw SpException("can't listen ServerSocket");
+    }
+
+    isOpen = true;
+}
+
+SpValue& ServerSocket::accept()
+{
+    /* accept */
+    SOCKET s = ::accept(sock, NULL, NULL);
+    if(s == INVALID_SOCKET){
+        throw SpException("can't accept ServerSocket");
+    }
+    Socket* ptr = new Socket(s);
+
+    //    static SpValue result;
+    //    result.setNewObject(ptr);
+    //    return result;
+    return SpObjectResult(ptr);
+}
+
+// server Socket open
+SpValue& ServerSocket::prim_open(SpValue& port)
+{
+    if(!port.isInt()){
+        throw SpException("not int. (socket.open)");
+    }
+    SpInt port_no = port.getInt();
+
+    ServerSocket* sock = new ServerSocket(port_no);
+    sock->open();
+    //    static SpValue result;
+    //    result.setNewObject(sock);
+    //    return result;
+    return SpObjectResult(sock);
+}
+
+SpValue& ServerSocket::prim_accept(SpValue& self)
+{
+    ServerSocket* sock = self.asServerSocket();
+    return sock->accept();
+}
+
+SpValue& ServerSocket::prim_close(SpValue& self)
+{
+    ServerSocket* sock = self.asServerSocket();
+    sock->close();
+    return TrueObject;
+}
+
+SpValue& ServerSocket::onMessage(SpValue& rec, SpValue& msg)
+{
+    return ServerSocketMsgHandler(rec, msg);
+}
+
+void ServerSocket::init()
+{
+    /* Server Socket */
+    // set namespace to symbol 'serversocket'.
+    SpNameSpace* PSSocketNameSpace = new SpNameSpace;
+    SpValue SSocketNS;
+    SSocketNS.setNewObject(PSSocketNameSpace);
+    SpValue SymSSocket(new SpSymbol("serversocket"));
+    PMainNameSpace->internConst(SymSSocket, SSocketNS);
+    // Socket open adr port
+    SpValue PrimSOpen(new SpPrim1(prim_open));
+    PSSocketNameSpace->internFunc(SymOpen, PrimSOpen);
+
+    // setup primitives
+    SpValue PrimClose(new SpPrim1(prim_close));
+    ServerSocketMsgHandler.append(SymClose, PrimClose);
+
+    SpValue SymAccept(new SpSymbol("accept"));
+    SpValue PrimAccept(new SpPrim1(prim_accept));
+    ServerSocketMsgHandler.append(SymAccept, PrimAccept);
+}
+
+
+#endif /* USE_SOCKET */
+
diff --git a/src/String.cpp b/src/String.cpp
new file mode 100644 (file)
index 0000000..fcbe9b6
--- /dev/null
@@ -0,0 +1,1663 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ *
+ * Copyright (C) 2002 SUZUKI Jun
+ *
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ *
+ *
+ * $Id: String.cpp,v 1.65 2004/05/18 12:47:17 randy Exp $
+ */
+
+//
+// Soopy String Class
+//
+
+#include <limits.h>
+#include "soopy.h"
+
+/*
+void SpString::append(const char* s)
+{
+//cout << "spstr.app('" << s << "')" << endl;
+    istringstream ist(s);
+    StreamReader reader(&ist);
+    while(true){
+        SpChar ch = reader.ReadChar();
+        if(ch == (SpChar)NULL){ break; }
+        str.push_back(ch);
+    }
+}
+ */
+
+//void SpString::appendWithEncoder(const char* s, ReadEncoder& encoder)
+void SpString::append(const char* s, ReadEncoder& encoder)
+{
+  //cout << "spstr.app('" << s << "')" << endl;
+  istringstream ist(s);
+  StreamReader sr(&ist);
+  Reader* old = encoder.getReader();
+  encoder.setReader(&sr);
+  while(!encoder.eof()){
+    SpChar ch = encoder.ReadChar();
+    if(ch == (SpChar)NULL){ break; }
+    str.push_back(ch);
+  }
+  encoder.setReader(old);
+}
+
+SpString::~SpString()
+{
+#ifdef TEST
+  *spout << ":destroy SpString '" << toCStringWithEncoder() << "'" << "\n";
+#endif
+}
+
+const int Buf_Size = 1024 * 4;
+
+/*
+const char* SpString::toCString()
+{
+    ostringstream ost;
+    StreamWriter writer(&ost);
+    SpCharVector::iterator it;
+    for(it = str.begin(); it < str.end(); it++){
+        writer.WriteChar(*it);
+    }
+
+    static string str;
+    str = ost.str();
+    return str.c_str();
+}
+ */
+
+const char* SpString::toCStringWithEncoder(WriteEncoder& encoder)
+{
+  ostringstream ost;
+  StreamWriter sw(&ost);
+  Writer* old = encoder.getWriter();
+  encoder.setWriter(&sw);
+  SpCharVector::iterator it;
+  for(it = str.begin(); it < str.end(); it++){
+    encoder.WriteChar(*it);
+  }
+  encoder.setWriter(old);
+
+  static string str;
+  str = ost.str();
+  return str.c_str();
+}
+
+SpValue& SpString::toString()
+{
+  SpString* str = new SpString("\"");
+  *str += toCStringWithEncoder();
+  *str += "\"";
+  //    static SpValue val;
+  //    val.setNewObject(str);
+  //    return val;
+  return SpObjectResult(str);
+}
+
+bool SpString::operator==(SpObject& obj)
+{
+  //cout << "str==  " << *this << " <-> " << obj << endl;
+  if(SpString* s = dynamic_cast<SpString*>(&obj)){
+    return str == s->str;
+  }
+  return false;
+}
+
+bool SpString::operator<(SpObject& obj)
+{
+  //cout << "str==  " << *this << " <-> " << obj << endl;
+  if(typeid(*this) == typeid(obj)){
+    if(SpString* s = dynamic_cast<SpString*>(&obj)){
+      return str < s->str;
+    }
+  }
+  return SpObject::operator<(obj);
+}
+
+SpString& SpString::operator+=(SpString& s)
+{
+  SpCharVector::iterator it;
+  for(it = s.str.begin(); it != s.str.end(); it++){
+    str.push_back(*it);
+  }
+  return *this;
+}
+
+SpValue& SpString::plus(SpValue& e1, SpValue& e2)
+{
+  SpString* s1;
+  SpString* s2;
+  SpString* s3;
+
+  if(!e2.isString()){
+    throw SpException("type mismatch in +(String, ...)");
+  }
+  s1 = dynamic_cast<SpString*>(e1.getObject());
+  s2 = dynamic_cast<SpString*>(e2.getObject());
+  s3 = new SpString(*s1);
+  *s3 += *s2;
+  //    static SpValue v;
+  //    v.setNewObject(s3);
+  //    return v;
+  return SpObjectResult(s3);
+}
+
+bool SpString::match(SpValue&, SpValue& val, SpNameSpace*)
+{
+  if(val.isObject()){
+    return operator==(*(val.getObject()));
+  }
+  return false;
+}
+
+SpValue& SpString::eq(SpValue&, SpValue& e2)
+{
+  if(!e2.isString()){
+    //throw SpException("type mismatch in ==(String, ...)");
+    return FalseObject;
+  }
+  SpString* s = e2.asString();
+  if(str == s->str){
+    return TrueObject;
+  }
+  return FalseObject;
+}
+
+SpValue& SpString::gt(SpValue&, SpValue& e2)
+{
+  if(!e2.isString()){
+    throw SpException("type mismatch in >(String, ...)");
+  }
+  SpString* s = e2.asString();
+  if(str > s->str){
+    return TrueObject;
+  }
+  return FalseObject;
+}
+
+SpValue& SpString::lt(SpValue&, SpValue& e2)
+{
+  if(!e2.isString()){
+    throw SpException("type mismatch in <(String, ...)");
+  }
+  SpString* s = e2.asString();
+  if(str < s->str){
+    return TrueObject;
+  }
+  return FalseObject;
+}
+
+// \83p\83X\82ð\83f\83B\83\8c\83N\83g\83\8a\82Æ\83t\83@\83C\83\8b\96¼\82É\95ª\82¯\82é\81B
+SpTuple* SpString::split_path_file()
+{
+  SpCharVector::iterator it   = begin();
+  SpCharVector::iterator last = end();
+
+  for(; it < end(); it++){
+#ifdef __WIN32__
+    if((*it == JIS('\\')) ||
+       (*it == JIS('/'))){
+      last = it;
+    }
+#else
+    if(*it == JIS('/')){
+      last = it;
+    }
+#endif
+  }
+  SpTuple* tuple;
+  if(last == end()){
+    SpValue temp;
+    tuple = new SpTuple(NullString);
+    temp.setNewObject(this);
+    tuple->append(temp);
+  }else{
+    SpString* pstr = new SpString; // path
+    SpString* fstr = new SpString; // filename
+    for(it = begin(); it < last; it++){
+      pstr->addSpChar(*it);
+    }
+    for(it++; it < end(); it++){
+      fstr->addSpChar(*it);
+    }
+
+    SpValue temp;
+    temp.setNewObject(pstr);
+    tuple = new SpTuple(temp);
+    temp.setNewObject(fstr);
+    tuple->append(temp);
+  }
+  return tuple;
+}
+
+// match_glob
+static bool string_match_glob(SpCharVector::iterator sbegin,
+                              SpCharVector::iterator send,
+                              SpCharVector::iterator gbegin,
+                              SpCharVector::iterator gend)
+{
+  SpCharVector::iterator it  = sbegin;
+  SpCharVector::iterator git = gbegin;
+
+  for(git; git < gend; git++){
+    if(it >= send){
+      return false;
+    }
+    switch(*git){
+    case JIS('*'):
+      git++;
+      if(git >= gend){
+        return true;
+      }
+      if(*git == JIS('*')){
+        throw SpException("illegal glob '**'");
+      }
+
+    research:
+      while(*it != *git){
+        if(it >= send){
+          return false;
+        }
+        if(*git == JIS('?')){
+          break;
+        }
+        it++;
+      }
+      if(string_match_glob(it, send, git, gend)){
+        return true;
+      }else{
+        it++;
+        goto research;
+      }
+
+      break;
+    case JIS('?'):
+      it++;
+      break;
+    case JIS('\\'):
+      git++;
+      if(git == gend){
+        throw SpException("illegal end (glob)");
+      }
+      if(*git != *it){
+        return false;
+      }
+      it++;
+      break;
+    default:
+      if(*git != *it){
+        return false;
+      }
+      it++;
+    }
+  }
+
+  if(it == send){
+    return true;
+  }
+  return false;
+}
+
+bool SpString::match_glob(SpString* glob)
+{
+  return string_match_glob(begin(), end(), glob->begin(), glob->end());
+}
+
+// split
+SpValue& SpString::split(SpChar c)
+{
+  if(length() == 0){
+    return NilObject;
+  }
+
+  SpCons* cons = NULL;
+  SpString s;
+  SpCharVector::iterator it = begin();;
+  while(it < end()){
+    s.clear();
+    for(; it < end(); it++){
+      if(*it == c){
+        it++;
+        break;
+      }
+      s.addSpChar(*it);
+    }
+    SpString* s2;
+    s2 = new SpString(s);
+    SpValue temp;
+    temp.setNewObject(s2);
+    if(cons == NULL){
+      cons = new SpCons(temp);
+    }else{
+      cons->append(temp);
+    }
+  }
+
+  //    static SpValue result;
+  //    result.setNewObject(cons);
+  //    return result;
+  return SpObjectResult(cons);
+}
+
+/*
+ * Message Handler
+ */
+
+SpValue& SpString::onMessage(SpValue& rec, SpValue& msg)
+{
+  return StringMsgHandler(rec, msg);
+}
+
+// string Primitives
+
+SpValue& str_length(SpValue& s)
+{
+  SpString* ptr = dynamic_cast<SpString*>(s.getObject());
+  if(ptr == NULL){
+    throw SpException("not string (length)");
+  }
+  //    static SpValue v;
+  //    v.setInt(ptr->length());
+  //    return v;
+  return SpIntResult(ptr->length());
+}
+
+SpValue& SpString::prim_nth(SpValue& self, SpValue& index)
+{
+  if(!index.isInt()){
+    throw SpException("not int. (tuple.nth)");
+  }
+  SpInt i = index.getInt();
+  SpString* str = self.asString();
+  if(str->length() < i + 1){
+    throw SpException("size over (string.nth)");
+  }
+  //    static SpValue result;
+  //    result.setSpChar((*str)[i]);
+  //    return result;
+  return SpCharResult((*str)[i]);
+}
+
+SpValue& SpString::prim_sub(SpValue& self, SpValue& from, SpValue& len)
+{
+  if(!from.isInt()){
+    throw SpException("not int. (string.sub)");
+  }
+  if(!len.isInt()){
+    throw SpException("not int. (string.sub)");
+  }
+  SpInt i = from.getInt();
+  SpInt j = len.getInt();
+  if(j == 0){
+    return NullString;
+  }
+  SpString* str = self.asString();
+  if(str->length() < i+1){
+    throw SpException("string is too short (string.sub)");
+  }
+  if(str->length() < i+j){
+    throw SpException("string is too short. (string.sub)");
+  }
+
+  SpCharVector vec;
+  for(int k=0; k < j; k++){
+    vec.push_back(str->str[i+k]);
+  }
+  SpString* s = new SpString(vec);
+  //    static SpValue result;
+  //    result.setNewObject(s);
+  //    return result;
+  return SpObjectResult(s);
+}
+
+SpValue& SpString::prim_split(SpValue& self, SpValue& ch)
+{
+  if(!ch.isChar()){
+    throw SpException("not char(string.split)");
+  }
+  SpChar c = ch.getChar();
+  SpString* str = self.asString();
+
+  //    static SpValue result;
+  //    result = str->split(c);
+  //    return result;
+  return SpValueResult(str->split(c));
+}
+
+SpValue& SpString::prim_split1(SpValue& self, SpValue& ch)
+{
+  if(!ch.isChar()){
+    throw SpException("not char(string.split1)");
+  }
+  SpChar c = ch.getChar();
+  SpString* str = self.asString();
+
+  if(str->length() == 0){
+    return NilObject;
+  }
+
+  SpCons* cons;
+  SpString s;
+  SpCharVector::iterator it = str->begin();;
+
+  for(; it < str->end(); it++){
+    if(*it == c){
+      it++;
+      break;
+    }
+    s.addSpChar(*it);
+  }
+  SpString* s2;
+  s2 = new SpString(s);
+  SpValue temp;
+  temp.setNewObject(s2);
+  cons = new SpCons(temp);
+  if(it < str->end()){
+    s.clear();
+    for(; it < str->end(); it++){
+      s.addSpChar(*it);
+    }
+    s2 = new SpString(s);
+    temp.setNewObject(s2);
+    cons->append(temp);
+  }else{
+    cons->append(NullString);
+  }
+
+  //    static SpValue result;
+  //    result.setNewObject(cons);
+  //    return result;
+  return SpObjectResult(cons);
+}
+
+SpValue& SpString::prim_tr(SpValue& self, SpValue& from, SpValue& to)
+{
+  if(!from.isChar()){
+    throw SpException("not char(string.tr)");
+  }
+  if(!to.isChar()){
+    throw SpException("not char(string.tr)");
+  }
+  SpChar c1 = from.getChar();
+  SpChar c2 = to.getChar();
+  SpString* str = self.asString();
+
+  SpString* s = new SpString;
+  SpCharVector::iterator it;
+  for(it = str->begin(); it < str->end(); it++){
+    if(*it == c1){
+      s->addSpChar(c2);
+    }else{
+      s->addSpChar(*it);
+    }
+  }
+
+  //    static SpValue result;
+  //    result.setNewObject(s);
+  //    return result;
+  return SpObjectResult(s);
+}
+
+SpValue& SpString::prim_reader(SpValue& self)
+{
+  SpString* str = self.asString();
+  StringReader* reader = new StringReader(str);
+
+  //    static SpValue result;
+  //    result.setNewObject(reader);
+  //    return result;
+  return SpObjectResult(reader);
+}
+
+SpValue& SpString::prim_upper(SpValue& self)
+{
+  SpString* str = self.asString();
+
+  SpString* s = new SpString;
+  SpCharVector::iterator it;
+  for(it = str->begin(); it < str->end(); it++){
+    s->addSpChar(SpChar2Upper(*it));
+  }
+
+  //    static SpValue result;
+  //    result.setNewObject(s);
+  //    return result;
+  return SpObjectResult(s);
+}
+
+SpValue& SpString::prim_lower(SpValue& self)
+{
+  SpString* str = self.asString();
+
+  SpString* s = new SpString;
+  SpCharVector::iterator it;
+  for(it = str->begin(); it < str->end(); it++){
+    s->addSpChar(SpChar2Lower(*it));
+  }
+
+  //    static SpValue result;
+  //    result.setNewObject(s);
+  //    return result;
+  return SpObjectResult(s);
+}
+
+SpValue& str2symbol(SpValue& s)
+{
+  SpString* ptr = dynamic_cast<SpString*>(s.getObject());
+  if(ptr == NULL){
+    throw SpException("not string (string.symbol)");
+  }
+  //    static SpValue v;
+  //    v.setNewObject(new SpSymbol(*ptr));
+  //    return v;
+  return SpObjectResult(new SpSymbol(*ptr));
+}
+
+SpValue& SpString::prim_toInt(SpValue& self)
+{
+  SpString* str = self.asString();
+  SpInt n = 0;
+
+  SpCharVector::iterator it = str->str.begin();
+  for(; it < str->str.end(); it++){
+    SpChar c = *it;
+    if(!isDIGIT(c)){
+      throw SpException("not digit (string.toInt)");
+    }
+    n = n * 10 + (c - JIS('0'));
+  }
+
+  //    static SpValue result;
+  //    result.setInt(n);
+  //    return result;
+  return SpIntResult(n);
+}
+
+SpValue& SpString::prim_replace(SpValue& self, SpValue& from, SpValue& to)
+{
+  if(!from.isString()){
+    throw SpException("not string(string.replace)");
+  }
+  if(!to.isString()){
+    throw SpException("not string(string.replace)");
+  }
+  SpString* src = self.asString();
+  SpString* s1 = from.asString();
+  SpString* s2 = to.asString();
+
+  SpString* res = new SpString;
+  SpCharVector::iterator sit; // source iterator
+  SpCharVector::iterator fit; // from iterator
+
+  sit = src->begin();
+  fit = s1->begin();
+  while(sit < src->end()){
+    if(*sit == *fit){
+      bool all_match = true;
+      SpCharVector::iterator it1;
+      SpCharVector::iterator it2;
+      it1 = sit;
+      it2 = fit;
+      it1++;
+      it2++;
+      while(it2 < s1->end()){
+        if(*it1 != *it2){
+          all_match = false;
+          break;
+        }
+        it1++;
+        it2++;
+      }
+      if(all_match){
+        SpCharVector::iterator it3 = s2->begin();
+        for(; it3 < s2->end(); it3++){
+          res->addSpChar(*it3);
+        }
+
+        sit += s1->length();
+      }else{
+        res->addSpChar(*sit);
+        sit++;
+      }
+    }else{
+      res->addSpChar(*sit);
+      sit++;
+    }
+  }
+
+  //    static SpValue result;
+  //    result.setNewObject(res);
+  //    return result;
+  return SpObjectResult(res);
+}
+
+SpValue& SpString::prim_replace1(SpValue& self, SpValue& from, SpValue& to)
+{
+  if(!from.isString()){
+    throw SpException("not string(string.replace1)");
+  }
+  if(!to.isString()){
+    throw SpException("not string(string.replace1)");
+  }
+  SpString* src = self.asString();
+  SpString* s1 = from.asString();
+  SpString* s2 = to.asString();
+
+  SpString* res = new SpString;
+  SpCharVector::iterator sit; // source iterator
+  SpCharVector::iterator fit; // from iterator
+
+  sit = src->begin();
+  fit = s1->begin();
+  while(sit < src->end()){
+    if(*sit == *fit){
+      bool all_match = true;
+      SpCharVector::iterator it1;
+      SpCharVector::iterator it2;
+      it1 = sit;
+      it2 = fit;
+      it1++;
+      it2++;
+      while(it2 < s1->end()){
+        if(*it1 != *it2){
+          all_match = false;
+          break;
+        }
+        it1++;
+        it2++;
+      }
+      if(all_match){
+        SpCharVector::iterator it3 = s2->begin();
+        for(; it3 < s2->end(); it3++){
+          res->addSpChar(*it3);
+        }
+        sit += s1->length();
+        for(; sit < src->end(); sit++){
+          res->addSpChar(*sit);
+        }
+        break;
+      }else{
+        res->addSpChar(*sit);
+        sit++;
+      }
+    }else{
+      res->addSpChar(*sit);
+      sit++;
+    }
+  }
+
+  //    static SpValue result;
+  //    result.setNewObject(res);
+  //    return result;
+  return SpObjectResult(res);
+}
+
+SpValue& SpString::prim_find(SpValue& self, SpValue& s, SpValue& from)
+{
+  //    static SpValue result;
+  SpValue result;
+
+  if(!s.isString()){
+    throw SpException("not string(string.find)");
+  }
+  if(!from.isInt()){
+    throw SpException("not int(string.find)");
+  }
+  SpString* src = self.asString();
+  SpString* s1 = s.asString();
+  SpInt start = from.getInt();
+
+  SpCharVector::iterator it = src->begin();;
+  //int i = 0;
+  int i = start;
+  it += start;
+  int j;
+cont:
+  for(; *it != s1->str[0]; it++, i++){
+    if(i >= src->length()){
+      result.setInt(-1);
+      //            return result;
+      return SpValueResult(result);
+    }
+  }
+  // found first char
+  SpCharVector::iterator it2 = it;
+  it2++;
+  for(j=1; j < s1->length(); j++, it2++)
+    {
+      if(i+j >= src->length()){
+        i = -1;
+        break;
+      }
+      if(*it2 != s1->str[j]){
+        it++;
+        i++;
+        goto cont;
+      }
+    }
+  result.setInt(i);
+  //    return result;
+  return SpValueResult(result);
+}
+
+//
+// format
+//    ex. "format string %s %d %f\n" format aString aInt aReal;
+//
+static SpValue PrimAdd;
+static SpValue& _prim_add(SpValue& a, SpValue& b)
+{
+  SpValue result, temp1, temp2;
+  temp1 = a.eval();
+  temp2 = b.eval();
+  result = temp1.plus(temp2);
+  return SpValueResult(result);
+}
+
+// '%s'
+class _format_make_string : public SpFunc {
+protected:
+  bool   flag;     // '-' flag(\8d\8bl)
+  int    width;
+  SpChar preChar;
+
+public:
+  _format_make_string(SpChar ch, int len, bool f)
+       : preChar(ch), width(len), flag(f)
+  {
+    argLen = 1;
+  }
+  virtual SpValue& operator()(SpValue& arg);
+  SpValue& toString();
+  const char* typeString(){ return "_format_make_string"; }
+};
+
+SpValue& _format_make_string::toString()
+{
+  SpString* str = new SpString("<make format string>");
+  return SpObjectResult(str);
+}
+
+SpValue& _format_make_string::operator()(SpValue& arg)
+{
+  SpValue temp;
+  SpValue result;
+
+  SpString* str;
+  if(!arg.isString()){
+    temp = arg.toString();
+    str  = temp.asString();
+  }else{
+    str = arg.asString();
+  }
+  int len = str->length();
+  if((width == 0) || (width <= len)){
+    result.setObject(str);
+  }else{  // width > len
+    if(flag){ // \8d\8bl
+      SpString* str2 = new SpString();
+      *str2 += *str;
+      for(int i=0; i < width - len; i++){
+        //str2->addSpChar(preChar);
+        str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+      }
+      result.setObject(str2);
+    }else{
+      SpString* str2 = new SpString();
+      for(int i=0; i < width - len; i++){
+        str2->addSpChar(preChar);
+      }
+      *str2 += *str;
+      result.setObject(str2);
+    }
+  }
+
+  return SpValueResult(result);
+}
+
+class _format_make_string_object : public _format_make_string {
+public:
+  _format_make_string_object(SpChar ch, int len, bool f) : _format_make_string(ch, len, f) {}
+  SpValue& operator()(SpValue& arg){
+    SpValue temp = arg.toString();
+    return _format_make_string::operator()(temp);
+  }
+};
+
+// '%u'
+class _format_make_unsigned_string : public _format_make_string {
+public:
+  _format_make_unsigned_string(SpChar ch, int len, bool f) : _format_make_string(ch, len, f) {}
+  SpValue& operator()(SpValue& arg);
+};
+
+SpValue& _format_make_unsigned_string::operator()(SpValue& arg)
+{
+  if(!arg.isInt()){
+    throw SpException("not int in string.format '%u'");
+  }
+  SpInt n = arg.getInt();
+  char buf[64];
+  sprintf(buf, "%u", n);
+  SpValue temp;
+  temp.setNewObject(new SpString(buf));
+  return _format_make_string::operator()(temp);
+}
+
+// '%c'
+class _format_make_char_string : public _format_make_string {
+public:
+  _format_make_char_string(SpChar ch, int w, bool f)
+       : _format_make_string(ch, w, f) {}
+  SpValue& operator()(SpValue& arg);
+  SpValue& toString()
+  {
+    SpString* str = new SpString("<make format string:char>");
+    return SpObjectResult(str);
+  }
+  const char* typeString(){ return "_format_make_char_string"; }
+};
+
+SpValue& _format_make_char_string::operator()(SpValue& arg)
+{
+  SpValue temp;
+  SpInt n;
+  SpString* str;
+
+  str = new SpString();
+  temp.setNewObject(str);
+  n = arg.getInt();
+  str->addSpChar((SpChar)n);
+
+  return _format_make_string::operator()(temp);
+}
+
+// '%f'
+class _format_make_real_string : public SpFunc {
+  char format[64];
+
+public:
+  _format_make_real_string(char* str)
+  {
+    argLen = 1;
+    strncpy(format, str, 63);
+  }
+  SpValue& operator()(SpValue& arg);
+  SpValue& toString()
+  {
+    SpString* str = new SpString("<make format string:real>");
+    return SpObjectResult(str);
+  }
+  const char* typeString(){ return "_format_make_real_string"; }
+};
+
+SpValue& _format_make_real_string::operator()(SpValue& arg)
+{
+  SpValue result;
+  SpReal real;
+  char buf[128];
+
+  if(arg.isInt()){
+    arg.setReal((SpReal)arg.getInt());
+  }
+  if(!arg.isReal()){
+    throw SpException("arg is not real in format string");
+  }
+  real = arg.getReal();
+  sprintf(buf, format, real);
+  result.setNewObject(new SpString(buf));
+
+  return SpValueResult(result);
+}
+
+// '%b'
+class _format_make_b_string : public SpFunc {
+private:
+  int width;
+  bool fSharp;
+  bool fMinus;
+  bool fZero;
+
+public:
+  _format_make_b_string(int w, bool s, bool m, bool z)
+       : width(w), fSharp(s), fMinus(m), fZero(z)
+  {
+    argLen = 1;
+  }
+  SpValue& operator()(SpValue& arg);
+  SpValue& toString()
+  {
+    SpString* str = new SpString("<make format string:b>");
+    return SpObjectResult(str);
+  }
+  const char* typeString(){ return "_format_make_b_string"; }
+};
+
+#ifndef INT_BIT
+#define INT_BIT (CHAR_BIT * (sizeof(int) / sizeof(char)))
+#endif
+
+SpValue& _format_make_b_string::operator()(SpValue& arg)
+{
+  SpValue result;
+  SpValue temp;
+  SpInt n;
+  SpString* str = NULL;
+
+  if(!arg.isInt()){
+    throw SpException("not int '%b'");
+  }
+  n = arg.getInt();
+
+  for(int i = INT_BIT-1; i >= 0; i--){
+    if(((n >> i) & 1) == 1){
+      if(str == NULL){
+        str = new SpString("1");
+        result.setObject(str);
+      }else{
+        str->addSpChar(MakeSpChar(CodeJIS, '1'));
+      }
+    }else{
+      if(str != NULL){
+        str->addSpChar(MakeSpChar(CodeJIS, '0'));
+      }
+    }
+  }
+  if(str == NULL){
+    str = new SpString();
+    result.setObject(str);
+  }
+
+  int len = str->length();
+  if(fSharp){ // '#' flag
+    if((width - 2) > len){
+      SpString* str2;
+      if(fMinus){ // \8d\8bl
+        str2 = new SpString("0b");
+        *str2 += *str;
+        for(int i=0; i < (width - 2) - len; i++){
+          str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+        }
+      }else{
+        if(fZero){
+          str2 = new SpString("0b");
+          for(int i=0; i < (width - 2) - len; i++){
+            str2->addSpChar(MakeSpChar(CodeJIS, '0'));
+          }
+        }else{
+          str2 = new SpString();
+          for(int i=0; i < (width - 2) - len; i++){
+            str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+          }
+          str2->addSpChar(MakeSpChar(CodeJIS, '0'));
+          str2->addSpChar(MakeSpChar(CodeJIS, 'b'));
+        }
+        *str2 += *str;
+      }
+      result.setObject(str2);
+    }else{
+      SpString* str2 = new SpString("0b");
+      SpValue temp;
+      temp.setObject(str2);
+      *str2 += *str;
+      result.setObject(str2);
+    }
+  }else{
+    if(width > len){
+      SpString* str2 = new SpString();
+      if(fMinus){ // \8d\8bl
+        *str2 += *str;
+        for(int i=0; i < width - len; i++){
+          str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+        }
+      }else{
+        SpChar preChar;
+        if(fZero){
+          preChar = MakeSpChar(CodeJIS, '0');
+        }else{
+          preChar = MakeSpChar(CodeJIS, ' ');
+        }
+        for(int i=0; i < width - len; i++){
+          str2->addSpChar(preChar);
+        }
+        *str2 += *str;
+      }
+      result.setObject(str2);
+    }
+  }
+
+  return SpValueResult(result);
+}
+
+// '%o'
+class _format_make_o_string : public SpFunc {
+private:
+  int width;
+  bool fSharp;
+  bool fMinus;
+  bool fZero;
+
+public:
+  _format_make_o_string(int w, bool s, bool m, bool z)
+       : width(w), fSharp(s), fMinus(m), fZero(z)
+  {
+    argLen = 1;
+  }
+  SpValue& operator()(SpValue& arg);
+  SpValue& toString()
+  {
+    SpString* str = new SpString("<make format string:o>");
+    return SpObjectResult(str);
+  }
+  const char* typeString(){ return "_format_make_o_string"; }
+};
+
+SpValue& _format_make_o_string::operator()(SpValue& arg)
+{
+  SpValue result;
+  SpValue temp;
+  SpUInt n;
+  SpString* str;
+
+  if(!arg.isInt()){
+    throw SpException("not int '%o'");
+  }
+  n = (SpUInt)arg.getInt();
+
+  str = new SpString();
+  result.setNewObject(str);
+  for(SpUInt i = n; i > 0; i >>= 3){
+    int j = i & 0x7;
+    str->insertSpChar(MakeSpChar(CodeJIS, j + '0'));
+  }
+  if(str->length() == 0){
+    str->addSpChar(MakeSpChar(CodeJIS, '0'));
+  }
+
+  int len = str->length();
+  if(fSharp){ // '#' flag
+    if((width - 2) > len){
+      SpString* str2;
+      if(fMinus){ // \8d\8bl
+        str2 = new SpString("00");
+        *str2 += *str;
+        for(int i=0; i < (width - 2) - len; i++){
+          str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+        }
+      }else{
+        if(fZero){
+          str2 = new SpString("00");
+          for(int i=0; i < (width - 2) - len; i++){
+            str2->addSpChar(MakeSpChar(CodeJIS, '0'));
+          }
+        }else{
+          str2 = new SpString();
+          for(int i=0; i < (width - 2) - len; i++){
+            str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+          }
+          str2->addSpChar(MakeSpChar(CodeJIS, '0'));
+          str2->addSpChar(MakeSpChar(CodeJIS, '0'));
+        }
+        *str2 += *str;
+      }
+      result.setObject(str2);
+    }else{
+      SpString* str2 = new SpString("00");
+      SpValue temp;
+      temp.setObject(str2);
+      *str2 += *str;
+      result.setObject(str2);
+    }
+  }else{
+    if(width > len){
+      SpString* str2 = new SpString();
+      if(fMinus){ // \8d\8bl
+        *str2 += *str;
+        for(int i=0; i < width - len; i++){
+          str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+        }
+      }else{
+        SpChar preChar;
+        if(fZero){
+          preChar = MakeSpChar(CodeJIS, '0');
+        }else{
+          preChar = MakeSpChar(CodeJIS, ' ');
+        }
+        for(int i=0; i < width - len; i++){
+          str2->addSpChar(preChar);
+        }
+        *str2 += *str;
+      }
+      result.setObject(str2);
+    }
+  }
+
+  return SpValueResult(result);
+}
+
+// '%x' '%X'
+class _format_make_hex_string : public SpFunc {
+private:
+  int width;
+  bool upper;
+  bool fSharp;
+  bool fMinus;
+  bool fZero;
+
+public:
+  _format_make_hex_string(int w, bool up, bool s, bool m, bool z)
+       : width(w), upper(up), fSharp(s), fMinus(m), fZero(z)
+  {
+    argLen = 1;
+  }
+  SpValue& operator()(SpValue& arg);
+  SpValue& toString()
+  {
+    SpString* str = new SpString("<make format string:x(X)>");
+    return SpObjectResult(str);
+  }
+  const char* typeString(){ return "_format_make_hex_string"; }
+};
+
+SpValue& _format_make_hex_string::operator()(SpValue& arg)
+{
+  SpValue result;
+  SpValue temp;
+  SpUInt n;
+  SpString* str;
+
+  if(!arg.isInt()){
+    throw SpException("not int '%x' or '%X'");
+  }
+  n = (SpUInt)arg.getInt();
+
+  str = new SpString();
+  result.setNewObject(str);
+  for(SpUInt i = n; i > 0; i >>= 4){
+    int j = i & 0xF;
+    if(j <= 9){
+      str->insertSpChar(MakeSpChar(CodeJIS, j + '0'));
+    }else{
+      if(upper){
+        str->insertSpChar(MakeSpChar(CodeJIS, j - 10 + 'A'));
+      }else{
+        str->insertSpChar(MakeSpChar(CodeJIS, j - 10 + 'a'));
+      }
+    }
+  }
+  if(str->length() == 0){
+    str->addSpChar(MakeSpChar(CodeJIS, '0'));
+  }
+
+  int len = str->length();
+  if(fSharp){ // '#' flag
+    if((width - 2) > len){
+      SpString* str2;
+      if(fMinus){ // \8d\8bl
+        if(upper){
+          str2 = new SpString("0X");
+        }else{
+          str2 = new SpString("0x");
+        }
+        *str2 += *str;
+        for(int i=0; i < (width - 2) - len; i++){
+          str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+        }
+      }else{
+        if(fZero){
+          if(upper){
+            str2 = new SpString("0X");
+          }else{
+            str2 = new SpString("0x");
+          }
+          for(int i=0; i < (width - 2) - len; i++){
+            str2->addSpChar(MakeSpChar(CodeJIS, '0'));
+          }
+        }else{
+          str2 = new SpString();
+          for(int i=0; i < (width - 2) - len; i++){
+            str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+          }
+          str2->addSpChar(MakeSpChar(CodeJIS, '0'));
+          if(upper){
+            str2->addSpChar(MakeSpChar(CodeJIS, 'X'));
+          }else{
+            str2->addSpChar(MakeSpChar(CodeJIS, 'x'));
+          }
+        }
+        *str2 += *str;
+      }
+      result.setObject(str2);
+    }else{
+      SpString* str2;
+      if(upper){
+        str2 = new SpString("0X");
+      }else{
+        str2 = new SpString("0x");
+      }
+      SpValue temp;
+      temp.setObject(str2);
+      *str2 += *str;
+      result.setObject(str2);
+    }
+  }else{
+    if(width > len){
+      SpString* str2 = new SpString();
+      if(fMinus){ // \8d\8bl
+        *str2 += *str;
+        for(int i=0; i < width - len; i++){
+          str2->addSpChar(MakeSpChar(CodeJIS, ' '));
+        }
+      }else{
+        SpChar preChar;
+        if(fZero){
+          preChar = MakeSpChar(CodeJIS, '0');
+        }else{
+          preChar = MakeSpChar(CodeJIS, ' ');
+        }
+        for(int i=0; i < width - len; i++){
+          str2->addSpChar(preChar);
+        }
+        *str2 += *str;
+      }
+      result.setObject(str2);
+    }
+  }
+
+  return SpValueResult(result);
+}
+
+// prim_format
+SpValue& SpString::prim_format(SpValue& self)
+{
+  SpCharVector vec;
+  SpChar preChar;
+  bool flagSharp = false;
+  bool flagPlus  = false;
+  bool flagSpace = false;
+  bool flagMinus = false;
+  bool flagZero  = false;
+  bool upper_hex = true;
+  int  width  = -1;  // -1 \82Ì\82Æ\82«\82É\82Í\95\9d\82Ì\8ew\92è\82Í\96³\82µ
+  int  width2 = -1;  // -1 \82Ì\82Æ\82«\82É\82Í\95\9d\82Ì\8ew\92è\82Í\96³\82µ\81A\82½\82¾\82µ\90¸\93x\82Ì\8fÈ\97ª\92l\82Í\82U
+  SpValueVector args;
+  SpCons* body = NULL;
+  SpCons* exps = NULL;
+  SpFunc* func = NULL;
+  SpValue vArgs;
+  SpValue vBody;
+  SpValue temp;
+  SpValue temp2;
+  SpValue temp3;
+  SpSymbol* sym;
+  int count = 0;
+  char buf[64];
+  char format[64];
+
+  SpString* ptr = dynamic_cast<SpString*>(self.getObject());
+  if(ptr == NULL){
+    throw SpException("not string (format)");
+  }
+  // parse format string
+  SpCharVector::iterator it;
+  it = ptr->str.begin();
+  for(; it != ptr->str.end(); it++){
+    flagSharp = false;
+    flagPlus  = false;
+    flagSpace = false;
+    flagMinus = false;
+    flagZero  = false;
+    upper_hex = true;
+    width  = -1;
+    width2 = -1;
+
+    if(*it == MakeSpChar(CodeJIS, '%')){    // parse '%'
+      it++;
+      if(it == ptr->str.end()){
+        throw SpException("illegal format string");
+      }
+      if(*it == MakeSpChar(CodeJIS, '%')){    // parse "%%"
+        vec.push_back(*it);
+        continue;
+      }
+
+      // init preChar & width
+      preChar = MakeSpChar(CodeJIS, ' ');
+      width = 0;
+      temp.setNewObject(new SpString(vec));
+      vec.clear();
+      if(exps == NULL){
+        exps = new SpCons(temp);
+      }else{
+        exps->append(temp);
+      }
+
+      // parse flag ('#', '+', ' ', '-', '0')
+parse_flags:
+      switch(*it){
+      case MakeSpChar(CodeJIS, '#'):
+        flagSharp = true;
+        it++;
+        if(it == ptr->str.end()){
+          throw SpException("illegal format string");
+        }
+        goto parse_flags;
+        break;
+      case MakeSpChar(CodeJIS, '+'):
+        flagPlus = true;
+        it++;
+        if(it == ptr->str.end()){
+          throw SpException("illegal format string");
+        }
+        goto parse_flags;
+        break;
+      case MakeSpChar(CodeJIS, ' '):
+        flagSpace = true;
+        it++;
+        if(it == ptr->str.end()){
+          throw SpException("illegal format string");
+        }
+        goto parse_flags;
+        break;
+      case MakeSpChar(CodeJIS, '-'):
+        flagMinus = true;
+        it++;
+        if(it == ptr->str.end()){
+          throw SpException("illegal format string");
+        }
+        goto parse_flags;
+        break;
+      case MakeSpChar(CodeJIS, '0'):
+        flagZero = true;
+        preChar  = *it;
+        it++;
+        if(it == ptr->str.end()){
+          throw SpException("illegal format string");
+        }
+        break;
+      }
+
+      // parse width
+      if(isDIGIT(*it)){
+        width = toINT(*it);
+        for(it++; it != ptr->str.end() && isDIGIT(*it); it++){
+          width = width * 10 + toINT(*it);
+        }
+      }
+
+      // parser width2 '.num'
+      if(*it == MakeSpChar(CodeJIS, '.')){
+        it++;
+        width2 = 0;
+        for(; it != ptr->str.end() && isDIGIT(*it); it++){
+          width2 = width2 * 10 + toINT(*it);
+        }
+      }
+
+      switch(*it){
+      case MakeSpChar(CodeJIS, 'c'): // char
+#ifdef _MICROSOFTC_
+        _snprintf(buf, 60, "a%d", count++);
+#else
+        snprintf(buf, 60, "a%d", count++);
+#endif
+        sym = new SpSymbol(buf);
+        temp2.setNewObject(sym);
+        temp.setNewObject(new _format_make_char_string(preChar, width, flagMinus));
+        temp.setNewObject(new SpSendMsg(temp, temp2));
+        exps->append(temp);
+        temp3.setNewObject(new SpArg(temp2, NilObject));
+        args.push_back(temp3);
+        break;
+      case MakeSpChar(CodeJIS, 's'): // string
+      case MakeSpChar(CodeJIS, 'p'):
+#ifdef _MICROSOFTC_
+        _snprintf(buf, 60, "a%d", count++);
+#else
+        snprintf(buf, 60, "a%d", count++);
+#endif
+        sym = new SpSymbol(buf);
+        temp2.setNewObject(sym);
+        temp.setNewObject(new _format_make_string(preChar, width, flagMinus));
+        temp.setNewObject(new SpSendMsg(temp, temp2));
+        exps->append(temp);
+        temp3.setNewObject(new SpArg(temp2, NilObject));
+        args.push_back(temp3);
+        break;
+      case MakeSpChar(CodeJIS, 'd'): // digit
+      case MakeSpChar(CodeJIS, 'i'):
+#ifdef _MICROSOFTC_
+        _snprintf(buf, 60, "a%d", count++);
+#else
+        snprintf(buf, 60, "a%d", count++);
+#endif
+        sym = new SpSymbol(buf);
+        temp2.setNewObject(sym);
+        temp.setNewObject(new _format_make_string_object(preChar, width, flagMinus));
+        temp.setNewObject(new SpSendMsg(temp, temp2));
+        exps->append(temp);
+        temp3.setNewObject(new SpArg(temp2, NilObject));
+        args.push_back(temp3);
+        break;
+      case MakeSpChar(CodeJIS, 'u'): // unsigned int
+#ifdef _MICROSOFTC_
+        _snprintf(buf, 60, "a%d", count++);
+#else
+        snprintf(buf, 60, "a%d", count++);
+#endif
+        sym = new SpSymbol(buf);
+        temp2.setNewObject(sym);
+        temp.setNewObject(new _format_make_unsigned_string(preChar, width, flagMinus));
+        temp.setNewObject(new SpSendMsg(temp, temp2));
+        exps->append(temp);
+        temp3.setNewObject(new SpArg(temp2, NilObject));
+        args.push_back(temp3);
+        break;
+      case MakeSpChar(CodeJIS, 'b'): // bin
+#ifdef _MICROSOFTC_
+        _snprintf(buf, 60, "a%d", count++);
+#else
+        snprintf(buf, 60, "a%d", count++);
+#endif
+        sym = new SpSymbol(buf);
+        temp2.setNewObject(sym);
+        temp.setNewObject(new _format_make_b_string(width, flagSharp, flagMinus, flagZero));
+        temp.setNewObject(new SpSendMsg(temp, temp2));
+        exps->append(temp);
+        temp3.setNewObject(new SpArg(temp2, NilObject));
+        args.push_back(temp3);
+        break;
+      case MakeSpChar(CodeJIS, 'o'): // oct
+#ifdef _MICROSOFTC_
+        _snprintf(buf, 60, "a%d", count++);
+#else
+        snprintf(buf, 60, "a%d", count++);
+#endif
+        sym = new SpSymbol(buf);
+        temp2.setNewObject(sym);
+        temp.setNewObject(new _format_make_o_string(width, flagSharp, flagMinus, flagZero));
+        temp.setNewObject(new SpSendMsg(temp, temp2));
+        exps->append(temp);
+        temp3.setNewObject(new SpArg(temp2, NilObject));
+        args.push_back(temp3);
+        break;
+      case MakeSpChar(CodeJIS, 'x'): // hex
+        upper_hex = false;
+      case MakeSpChar(CodeJIS, 'X'): // HEX
+#ifdef _MICROSOFTC_
+        _snprintf(buf, 60, "a%d", count++);
+#else
+        snprintf(buf, 60, "a%d", count++);
+#endif
+        sym = new SpSymbol(buf);
+        temp2.setNewObject(sym);
+        temp.setNewObject(new _format_make_hex_string(width, upper_hex, flagSharp, flagMinus, flagZero));
+        temp.setNewObject(new SpSendMsg(temp, temp2));
+        exps->append(temp);
+        temp3.setNewObject(new SpArg(temp2, NilObject));
+        args.push_back(temp3);
+        break;
+      case MakeSpChar(CodeJIS, 'f'):
+      case MakeSpChar(CodeJIS, 'e'):
+      case MakeSpChar(CodeJIS, 'E'):
+      case MakeSpChar(CodeJIS, 'g'):
+      case MakeSpChar(CodeJIS, 'G'):
+#ifdef _MICROSOFTC_
+        _snprintf(buf, 60, "a%d", count++);
+#else
+        snprintf(buf, 60, "a%d", count++);
+#endif
+        sym = new SpSymbol(buf);
+        temp2.setNewObject(sym);
+        if(width2 == -1){
+          width2 = 6;
+        }
+        if(width < 0){
+          if(flagSharp){
+            sprintf(format, "%%#.%d%c", width2, SpCharGetChar(*it));
+          }else if(flagPlus){
+            sprintf(format, "%%+.%d%c", width2, SpCharGetChar(*it));
+          }else if(flagSpace){
+            sprintf(format, "%% .%d%c", width2, SpCharGetChar(*it));
+          }else if(flagMinus){
+            sprintf(format, "%%-.%d%c", width2, SpCharGetChar(*it));
+          }else if(flagZero){
+            sprintf(format, "%%0.%d%c", width2, SpCharGetChar(*it));
+          }else{
+            sprintf(format, "%%.%d%c", width2, SpCharGetChar(*it));
+          }
+        }else{
+          if(flagSharp){
+            sprintf(format, "%%#%d.%d%c", width, width2, SpCharGetChar(*it));
+          }else if(flagPlus){
+            sprintf(format, "%%+%d.%d%c", width, width2, SpCharGetChar(*it));
+          }else if(flagSpace){
+            sprintf(format, "%% %d.%d%c", width, width2, SpCharGetChar(*it));
+          }else if(flagMinus){
+            sprintf(format, "%%-%d.%d%c", width, width2, SpCharGetChar(*it));
+          }else if(flagZero){
+            sprintf(format, "%%0%d.%d%c", width, width2, SpCharGetChar(*it));
+          }else{
+            sprintf(format, "%%%d.%d%c", width, width2, SpCharGetChar(*it));
+          }
+        }
+        temp.setNewObject(new _format_make_real_string(format));
+        temp.setNewObject(new SpSendMsg(temp, temp2));
+        exps->append(temp);
+        temp3.setNewObject(new SpArg(temp2, NilObject));
+        args.push_back(temp3);
+        break;
+      default:
+        throw SpException("illegal format string");
+      }
+
+    }else{
+      vec.push_back(*it);
+    }
+  }
+  if(vec.size() > 0){
+    if(exps == NULL){
+      temp.setNewObject(new SpString(vec));
+      body = new SpCons(temp);
+    }else{
+      SpValue recv, msg;
+      SpSendMsg* sm;
+      temp.setNewObject(new SpString(vec));
+      exps->append(temp);
+      recv.setObject(exps);
+      sm = new SpSendMsg(recv, SymFoldl);
+      recv.setObject(sm);
+      sm = new SpSendMsg(recv, PrimAdd);
+      temp.setNewObject(sm);
+      body = new SpCons(temp);
+    }
+  }else{
+    if(exps != NULL){
+      SpValue recv, msg;
+      SpSendMsg* sm;
+      recv.setObject(exps);
+      sm = new SpSendMsg(recv, SymFoldl);
+      recv.setObject(sm);
+      sm = new SpSendMsg(recv, PrimAdd);
+      temp.setNewObject(sm);
+      body = new SpCons(temp);
+    }
+  }
+
+  // make function
+  if(args.size() != 0){
+    vArgs.setNewObject(new SpTuple(args));
+  }
+  if(body != NULL){
+    vBody.setObject(body);
+  }
+
+  func = new SpUsrFunc(NilObject, vArgs, NilObject, NilObject, vBody, NilObject, NilObject);
+
+  return SpObjectResult(func);
+}
+
+// init Message Handler
+void SpString::init()
+{
+  StringMsgHandler.append(SymIsString, PrimTrue);
+
+  PrimAdd.setNewObject(new SpPrim2(_prim_add));
+
+  SpValue PrimLength(new SpPrim1(str_length));
+  StringMsgHandler.append(SymLength, PrimLength);
+
+  SpValue PrimNth(new SpPrim2(prim_nth));
+  StringMsgHandler.append(SymNth, PrimNth);
+
+  SpValue SymSub(new SpSymbol("sub"));
+  SpValue PrimSub(new SpPrim3(prim_sub));
+  StringMsgHandler.append(SymSub, PrimSub);
+
+  SpValue SymSymbol(new SpSymbol("symbol"));
+  SpValue PrimSymbol(new SpPrim1(str2symbol));
+  StringMsgHandler.append(SymSymbol, PrimSymbol);
+
+  SpValue PrimSplit(new SpPrim2(prim_split));
+  StringMsgHandler.append(SymSplit, PrimSplit);
+
+  SpValue SymTr(new SpSymbol("tr"));
+  SpValue PrimTr(new SpPrim3(prim_tr));
+  StringMsgHandler.append(SymTr, PrimTr);
+
+  SpValue PrimReader(new SpPrim1(prim_reader));
+  StringMsgHandler.append(SymReader, PrimReader);
+
+  SpValue PrimUpper(new SpPrim1(prim_upper));
+  StringMsgHandler.append(SymUpper, PrimUpper);
+
+  SpValue PrimLower(new SpPrim1(prim_lower));
+  StringMsgHandler.append(SymLower, PrimLower);
+
+  SpValue PrimReplace(new SpPrim3(prim_replace));
+  StringMsgHandler.append(SymReplace, PrimReplace);
+
+  SpValue PrimToInt(new SpPrim1(prim_toInt));
+  StringMsgHandler.append(SymToInt, PrimToInt);
+
+  SpValue PrimFind(new SpPrim3(prim_find));
+  StringMsgHandler.append(SymFind, PrimFind);
+
+  SpValue PrimSplit1(new SpPrim2(prim_split1));
+  StringMsgHandler.append(SymSplit1, PrimSplit1);
+
+  SpValue PrimReplace1(new SpPrim3(prim_replace1));
+  StringMsgHandler.append(SymReplace1, PrimReplace1);
+
+  SpValue SymFormat(new SpSymbol("format"));
+  SpValue PrimFormat(new SpPrim1(prim_format));
+  StringMsgHandler.append(SymFormat, PrimFormat);
+}
+
diff --git a/src/Symbol.cpp b/src/Symbol.cpp
new file mode 100644 (file)
index 0000000..cd57dcf
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Symbol.cpp,v 1.19 2004/03/21 05:48:06 randy Exp $
+ */
+
+//
+// Soopy Symbol Class
+//
+
+#include "soopy.h"
+
+bool SpSymbol::operator==(SpObject& obj)
+{
+    SpString* p2;
+    SpSymbol* sym = dynamic_cast<SpSymbol*>(&obj);
+    if(sym != NULL){
+//        return str == sym->str;
+        p2 = (SpString*)sym;
+        if(p2 != NULL){
+            return SpString::operator==(*p2);
+        }
+    }
+    return false;
+}
+
+bool SpSymbol::operator<(SpObject& obj)
+{
+    SpString* p2;
+    SpSymbol* sym = dynamic_cast<SpSymbol*>(&obj);
+    if(sym != NULL){
+        p2 = (SpString*)sym;
+        if(p2 != NULL){
+            return SpString::operator<(obj);
+        }
+    }
+    return SpObject::operator<(obj);
+}
+
+SpValue& SpSymbol::eval()
+{
+    SpValue val = getCurrentNS();
+    SpNameSpace* ns = dynamic_cast<SpNameSpace*>(val.getObject());
+    SpValue key(new SpSymbol(str));
+    //    static SpValue v;
+    SpValue v;
+    v = ns->lookup(key, ns);
+    if(v.isConstructor()){
+        v = v.eval();
+    }
+    //    return v;
+    return SpValueResult(v);
+}
+
+SpValue& SpSymbol::toString()
+{
+    //    static SpValue val;
+    //    val.setNewObject(new SpString(toCStringWithEncoder()));
+    //    return val;
+    return SpObjectResult(new SpString(toCStringWithEncoder()));
+}
+
+SpValue& SpSymbol::eq(SpValue&, SpValue& e2)
+{
+    if(!e2.isSymbol()){
+        throw SpException("type mismatch in ==(Symbol, ...)");
+    }
+    SpSymbol* s = e2.asSymbol();
+    if(str == s->str){
+        return TrueObject;
+    }
+    return FalseObject;
+}
+
+/*
+ * Message Handler
+ */
+
+SpValue& SpSymbol::onMessage(SpValue& rec, SpValue& msg)
+{
+    return SymbolMsgHandler(rec, msg);
+}
+
+// symbol Primitives
+
+
+// init Message Handler
+void SpSymbol::init()
+{
+}
+
+/*
+ * pattern match
+ */
+
+bool SpSymbol::match(SpValue& self, SpValue& val, SpNameSpace* ns)
+{
+/*
+    NSVar* var = new NSVar(self);
+    ns->intern(var, val);
+*/
+    ns->internVar(self, val);
+    return true;
+}
+
diff --git a/src/Thread.cpp b/src/Thread.cpp
new file mode 100644 (file)
index 0000000..7e8f7c6
--- /dev/null
@@ -0,0 +1,348 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Thread.cpp,v 1.9 2004/04/14 14:01:00 randy Exp $
+ */
+
+#include "soopy.h"
+
+//
+// Soopy Thread Class
+//
+
+#ifdef USE_PTHREAD
+
+pthread_key_t pthread_key;
+std::vector<SpValue> SpThread::all_threads;
+
+SpThread::~SpThread()
+{
+  std::vector<SpValue>::iterator it;
+  for(it = all_threads.begin(); it != all_threads.end(); it++){
+    SpThread* th = (SpThread*)it->getObject();
+    if(th == this){
+      all_threads.erase(it);
+      break;
+    }
+  }
+}
+
+void SpThread::removeContext(ThreadContext* con)
+{
+  delete con;
+}
+
+void SpThread::run()
+{
+  // create thread
+  if(pthread_create(&thread, NULL, (void*(*)(void*))start, this) != 0){
+    throw SpException("can't create thread");
+  }
+}
+
+void SpThread::start(SpThread* th)
+{
+  // create thread local data
+  ThreadContext* context = new ThreadContext();
+  pthread_setspecific(pthread_key, context);
+  pushCurrentNS(th->assoc);
+
+  // set this thread to 'current_thread'
+  SpValue curThread;
+  curThread.setObject(th);
+  SpNameSpace* ns = th->assoc.asNameSpace();
+  ns->internConst(SymCurrentThread, curThread);
+
+  // thread main
+  SpValue func = th->body;
+  SpValue taker;
+  SpFunc* f;
+  if(func.isNameSpace()){
+    SpNameSpace* ns = func.asNameSpace();
+    f = SpUsrFunc::fromNameSpace(ns);
+    taker.setObject(f);
+  }else if(func.isFunc()){
+    f = func.asFunc();
+  }else{
+    throw SpException("not function (thread.start)");
+  }
+  SpValue temp;
+  temp.setObject(th);
+  try{
+    (*f)(temp);
+  }catch(SpException& e){
+    cout << "Uncaught exception in thread: " << e.what() << endl;
+  }catch(const exception& e){
+    cout << "Exception in thread: " << e.what() << endl;
+  }
+}
+
+SpValue& SpThread::toString()
+{
+    SpString* str;
+    char buf[32];
+
+    sprintf(buf, "%X", &thread);
+    str = new SpString();
+    *str = "<thread: ";
+    *str += buf;
+    *str += ">";
+    return SpObjectResult(str);
+}
+
+//
+// primitives
+//
+SpValue& SpThread::prim_start(SpValue& body)
+{
+  SpValue result;
+  SpValue ns = getCurrentNS();
+  SpNameSpace* n = ns.asNameSpace();
+  n->setParent(getPrevNS());
+  SpThread* thread = new SpThread(ns, body);
+  result.setNewObject(thread);
+  all_threads.push_back(result);
+  thread->run();
+  return SpValueResult(result);
+}
+
+//
+// instance primitives
+//
+SpValue& SpThread::prim_join(SpValue& th)
+{
+  SpThread* ptr = dynamic_cast<SpThread*>(th.getObject());
+  if(ptr == NULL){
+    throw SpException("not thread (join)");
+  }
+  if(pthread_join(ptr->thread, NULL) != 0){
+    throw SpException("can't join thread");
+  }
+
+  return TrueObject;
+}
+
+SpValue& SpThread::prim_quit(SpValue& thread)
+{
+  SpThread* ptr = dynamic_cast<SpThread*>(thread.getObject());
+  if(ptr == NULL){
+    throw SpException("not thread (quit)");
+  }
+  pthread_exit(NULL);
+
+  return TrueObject;
+}
+
+// init
+void SpThread::init()
+{
+  // create key
+  pthread_key_create(&pthread_key, (void(*)(void*))SpThread::removeContext);
+  // make ThreadContext for main thread
+  pthread_setspecific(pthread_key, new ThreadContext());
+}
+
+void SpThread::finalize()
+{
+  pthread_key_delete(pthread_key);
+}
+
+#endif /* USE_PTHREAD */
+
+#ifdef USE_W32THREAD
+
+std::vector<SpValue> SpThread::all_threads;
+DWORD tls_key;
+
+SpThread::~SpThread()
+{
+  std::vector<SpValue>::iterator it;
+  for(it = all_threads.begin(); it != all_threads.end(); it++){
+    SpThread* th = (SpThread*)it->getObject();
+    if(th == this){
+      all_threads.erase(it);
+      break;
+    }
+  }
+  CloseHandle(hThread);
+}
+
+void SpThread::removeContext(ThreadContext* con)
+{
+  delete con;
+}
+
+void SpThread::run()
+{
+  // create thread
+  hThread = (HANDLE)_beginthreadex(NULL, 0, (unsigned(__stdcall*)(void*))start, this, 0, &id);
+  if(hThread == 0){
+    throw SpException("can't create thread");
+  }
+}
+
+unsigned __stdcall SpThread::start(SpThread* th)
+{
+  // create thread local data
+  ThreadContext* context = new ThreadContext();
+  if(TlsSetValue(tls_key, context) == 0){
+    throw SpException("can't set tls value");
+  }
+  pushCurrentNS(th->assoc);
+
+  // set this thread to 'current_thread'
+  SpValue curThread;
+  curThread.setObject(th);
+  SpNameSpace* ns = th->assoc.asNameSpace();
+  ns->internConst(SymCurrentThread, curThread);
+
+  // thread main
+  SpValue func = th->body;
+  SpValue taker;
+  SpFunc* f;
+  if(func.isNameSpace()){
+    SpNameSpace* ns = func.asNameSpace();
+    f = SpUsrFunc::fromNameSpace(ns);
+    taker.setObject(f);
+  }else if(func.isFunc()){
+    f = func.asFunc();
+  }else{
+    throw SpException("not function (thread.start)");
+  }
+  SpValue temp;
+  temp.setObject(th);
+  (*f)(temp);
+
+  return 0;
+}
+
+SpValue& SpThread::toString()
+{
+    SpString* str;
+    char buf[32];
+
+    sprintf(buf, "%X", &hThread);
+    str = new SpString();
+    *str = "<thread: ";
+    *str += buf;
+    *str += ">";
+    return SpObjectResult(str);
+}
+
+//
+// primitives (Thread)
+//
+SpValue& SpThread::prim_start(SpValue& body)
+{
+  SpValue result;
+  SpValue ns = getCurrentNS();
+  SpNameSpace* n = ns.asNameSpace();
+  n->setParent(getPrevNS());
+  SpThread* thread = new SpThread(ns, body);
+  result.setNewObject(thread);
+  all_threads.push_back(result);
+  thread->run();
+  return SpValueResult(result);
+}
+
+//
+// instance primitives
+//
+SpValue& SpThread::prim_join(SpValue& thread)
+{
+  SpThread* ptr = dynamic_cast<SpThread*>(thread.getObject());
+  if(ptr == NULL){
+    throw SpException("not thread (join)");
+  }
+  WaitForSingleObject(ptr->hThread, INFINITE);
+
+  return TrueObject;
+}
+
+SpValue& SpThread::prim_quit(SpValue& thread)
+{
+  SpThread* ptr = dynamic_cast<SpThread*>(thread.getObject());
+  if(ptr == NULL){
+    throw SpException("not thread (quit)");
+  }
+  _endthreadex(0);
+
+  return TrueObject;
+}
+
+
+// init
+
+void SpThread::init()
+{
+  // create key
+  tls_key = TlsAlloc();
+  if(tls_key == 0xffffffff){
+    throw SpException("can't get TlsKey");
+  }
+  // make ThreadContext for main thread
+  if(TlsSetValue(tls_key, new ThreadContext()) == 0){
+    TlsFree(tls_key);
+    throw SpException("can't set tls value");
+  }
+}
+
+void SpThread::finalize()
+{
+  TlsFree(tls_key);
+}
+
+#endif /* USE_W32THREAD */
+
+
+#ifdef THREAD
+
+MsgHandler ThreadMsgHandler;
+
+// onMessage
+SpValue& SpThread::onMessage(SpValue& rec, SpValue& msg)
+{
+    return ThreadMsgHandler(rec, msg);
+}
+
+//
+// init
+//
+
+
+SpNameSpace* PThreadNameSpace;
+SpValue      ThreadNS;
+
+void SpThread::init2()
+{
+  // set namespace to symbol 'thread'.
+  //  SpValue parentNS(PMainNameSpace);
+  //  PThreadNameSpace = new SpNameSpace(parentNS);
+  PThreadNameSpace = new SpNameSpace();
+  ThreadNS.setNewObject(PThreadNameSpace);
+  SpValue SymThread(new SpSymbol("thread"));
+  PMainNameSpace->internConst(SymThread, ThreadNS);
+
+  SpValue SymStart(new SpSymbol("start"));
+  SpValue PrimStart(new SpPrim1(prim_start));
+  PThreadNameSpace->internFunc(SymStart, PrimStart);
+
+  // init instance method
+  SpValue SymJoin(new SpSymbol("join"));
+  SpValue PrimJoin(new SpPrim1(prim_join));
+  ThreadMsgHandler.append(SymJoin, PrimJoin);
+
+  SpValue SymQuit(new SpSymbol("quit"));
+  SpValue PrimQuit(new SpPrim1(prim_quit));
+  ThreadMsgHandler.append(SymQuit, PrimQuit);
+}
+
+#endif /* THREAD */
+
diff --git a/src/Time.cpp b/src/Time.cpp
new file mode 100644 (file)
index 0000000..2f18f1c
--- /dev/null
@@ -0,0 +1,414 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Time.cpp,v 1.8 2004/07/04 12:32:36 randy Exp $
+ */
+
+#include <time.h>
+#include "soopy.h"
+
+void SpTime::regular()
+{
+    // minute
+    if(minute < 0){
+        while(minute < 0){
+            minute += 60;
+            hour--;
+        }
+    }else if(minute >= 60){
+        while(minute >= 60){
+            minute -= 60;
+            hour++;
+        }
+    }
+
+    // second
+    if(second < 0){
+        while(second < 0){
+            second += 60;
+            minute--;
+        }
+    }else if(second >= 60){
+        while(second >= 60){
+            second -= 60;
+            minute++;
+        }
+    }
+}
+
+SpValue& SpTime::plus(SpValue& e1, SpValue& e2)
+{
+    SpTime* t1 = e1.asTime();
+    SpTime* time;
+    if(e2.isInt()){
+        SpInt i = e2.getInt();
+        time = new SpTime(t1->hour,
+                          t1->minute,
+                          t1->second + i);
+    }else if(e2.isTime()){
+        SpTime* t2 = e2.asTime();
+        time = new SpTime(t1->hour   + t2->hour,
+                          t1->minute + t2->minute,
+                          t1->second + t2->second);
+    }else{
+        throw SpException("not time operator+");
+    }
+    time->regular();
+    //    static SpValue result;
+    //    result.setNewObject(time);
+    //    return result;
+    return SpObjectResult(time);
+}
+
+SpValue& SpTime::minus(SpValue& e1, SpValue& e2)
+{
+    SpTime* t1 = e1.asTime();
+    SpTime* time;
+    if(e2.isInt()){
+        SpInt i = e2.getInt();
+        time = new SpTime(t1->hour,
+                          t1->minute,
+                          t1->second - i);
+    }else if(e2.isTime()){
+        SpTime* t2 = e2.asTime();
+        time = new SpTime(t1->hour   - t2->hour,
+                          t1->minute - t2->minute,
+                          t1->second - t2->second);
+    }else{
+        throw SpException("not time operator-");
+    }
+    time->regular();
+    //    static SpValue result;
+    //    result.setNewObject(time);
+    //    return result;
+    return SpObjectResult(time);
+}
+
+SpValue& SpTime::eq(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isTime()){
+        return SpBoolResult(false);
+    }
+    SpTime* t1 = e1.asTime();
+    SpTime* t2 = e2.asTime();
+    return SpBoolResult((t1->hour == t2->hour) && (t1->minute == t2->minute) && (t1->second == t2->second));
+}
+
+SpValue& SpTime::ne(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isTime()){
+        return SpBoolResult(false);
+    }
+    SpTime* t1 = e1.asTime();
+    SpTime* t2 = e2.asTime();
+    return SpBoolResult((t1->hour != t2->hour) || (t1->minute != t2->minute) || (t1->second != t2->second));
+}
+
+SpValue& SpTime::gt(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isTime()){
+        throw SpException("unmatch type (Time >)");
+    }
+    SpTime* t1 = e1.asTime();
+    SpTime* t2 = e2.asTime();
+    if(t1->hour > t2->hour){
+        return SpBoolResult(true);
+    }else if(t1->hour == t2->hour){
+        if(t1->minute > t2->minute){
+            return SpBoolResult(true);
+        }else if(t1->minute == t2->minute){
+            return SpBoolResult(t1->second > t2->second);
+        }
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpTime::ge(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isTime()){
+        throw SpException("unmatch type (>=)");
+    }
+    SpTime* t1 = e1.asTime();
+    SpTime* t2 = e2.asTime();
+    if(t1->hour > t2->hour){
+        return SpBoolResult(true);
+    }else if(t1->hour == t2->hour){
+        if(t1->minute > t2->minute){
+            return SpBoolResult(true);
+        }else if(t1->minute == t2->minute){
+            return SpBoolResult(t1->second >= t2->second);
+        }
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpTime::lt(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isTime()){
+        throw SpException("unmatch type (<)");
+    }
+    SpTime* t1 = e1.asTime();
+    SpTime* t2 = e2.asTime();
+    if(t1->hour < t2->hour){
+        return SpBoolResult(true);
+    }else if(t1->hour == t2->hour){
+        if(t1->minute < t2->minute){
+            return SpBoolResult(true);
+        }else if(t1->minute == t2->minute){
+            return SpBoolResult(t1->second < t2->second);
+        }
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpTime::le(SpValue& e1, SpValue& e2)
+{
+    if(!e2.isTime()){
+        throw SpException("unmatch type (<=)");
+    }
+    SpTime* t1 = e1.asTime();
+    SpTime* t2 = e2.asTime();
+    if(t1->hour < t2->hour){
+        return SpBoolResult(true);
+    }else if(t1->hour == t2->hour){
+        if(t1->minute < t2->minute){
+            return SpBoolResult(true);
+        }else if(t1->minute == t2->minute){
+            return SpBoolResult(t1->second <= t2->second);
+        }
+    }
+    return SpBoolResult(false);
+}
+
+SpValue& SpTime::toString()
+{
+    char buf[10];
+    SpString* str = new SpString;
+    sprintf(buf, "%d", hour);
+    *str += buf;
+    sprintf(buf, ":%d", minute);
+    *str += buf;
+    sprintf(buf, ":%d", second);
+    *str += buf;
+    //    static SpValue val;
+    //    val.setNewObject(str);
+    //    return val;
+    return SpObjectResult(str);
+}
+
+void SpTime::assign(SpValue& feature, SpValue& value)
+{
+    SpValue v;
+
+    if(feature == SymHour){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign time)");
+        }
+        hour = v.getInt();
+    }else if(feature == SymMinute){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign time)");
+        }
+        minute = v.getInt();
+    }else if(feature == SymSecond){
+        v = value.eval();
+        if(!v.isInt()){
+            throw SpException("not int(assign time)");
+        }
+        second = v.getInt();
+    }else{
+        throw SpException("no such a feature(assign time)");
+    }
+}
+
+// primitives
+SpValue& SpTime::prim_now()
+{
+    SpInt h, m, s;
+    time_t t;
+    struct tm* area;
+
+    t = time(NULL);
+    area = localtime(&t);
+    h = area->tm_hour;
+    m = area->tm_min;
+    s = area->tm_sec;
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpTime(h, m, s));
+    //    return result;
+    return SpObjectResult(new SpTime(h, m, s));
+}
+
+SpValue& SpTime::prim_new(SpValue& v1, SpValue& v2, SpValue& v3)
+{
+    SpInt h, m, s;
+
+    if(!v1.isInt()){
+        throw SpException("not int (Date.new)");
+    }
+    if(!v2.isInt()){
+        throw SpException("not int (Date.new)");
+    }
+    if(!v3.isInt()){
+        throw SpException("not int (Date.new)");
+    }
+    h = v1.getInt();
+    m = v2.getInt();
+    s = v3.getInt();
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpTime(h, m, s));
+    //    return result;
+    return SpObjectResult(new SpTime(h, m, s));
+}
+
+/*
+SpValue& SpTime::prim_succ(SpValue& self)
+{
+    SpInt h, m, s;
+    SpTime* time = self.asTime();
+
+    h = time->hour;
+    m = time->minute;
+    s = time->second;
+    SpTime* time2 = new SpTime(h, m, s+1);
+    time2->regular();
+
+    static SpValue result;
+    result.setNewObject(time2);
+    return result;
+}
+
+SpValue& SpTime::prim_pred(SpValue& self)
+{
+    SpInt h, m, s;
+    SpTime* time = self.asTime();
+
+    h = time->hour;
+    m = time->minute;
+    s = time->second;
+    SpTime* time2 = new SpTime(h, m, s-1);
+    time2->regular();
+
+    static SpValue result;
+    result.setNewObject(time2);
+    return result;
+}
+*/
+
+SpValue& SpTime::prim_getHour(SpValue& self)
+{
+    SpTime* p = self.asTime();
+    //    static SpValue result;
+    //    result.setInt(p->hour);
+    //    return result;
+    return SpIntResult(p->hour);
+}
+
+SpValue& SpTime::prim_getMinute(SpValue& self)
+{
+    SpTime* p = self.asTime();
+    //    static SpValue result;
+    //    result.setInt(p->minute);
+    //    return result;
+    return SpIntResult(p->minute);
+}
+
+SpValue& SpTime::prim_getSecond(SpValue& self)
+{
+    SpTime* p = self.asTime();
+    //    static SpValue result;
+    //    result.setInt(p->second);
+    //    return result;
+    return SpIntResult(p->second);
+}
+
+SpValue& SpTime::prim_fromString(SpValue& time_str)
+{
+    SpInt h, m, s;
+    SpValue temp;
+    SpString* str = time_str.asString();
+
+    SpValue v = str->split(MakeSpChar(CodeJIS, ':'));
+    SpCons* list = (SpCons*)v.asList();
+    if(list->length() != 3){
+        throw SpException("illegal time format");
+    }
+
+    //h = int_fromString(list->value().asString());
+    temp = list->value();
+    h = int_fromString(temp.asString());
+    temp = list->nextList();
+    list = (SpCons*)temp.asList();
+    //m = int_fromString(list->value().asString());
+    temp = list->value();
+    m = int_fromString(temp.asString());
+    temp = list->nextList();
+    list = (SpCons*)temp.asList();
+    //s = int_fromString(list->value().asString());
+    temp = list->value();
+    s = int_fromString(temp.asString());
+
+    //    static SpValue result;
+    //    result.setNewObject(new SpTime(h, m, s));
+    //    return result;
+    return SpObjectResult(new SpTime(h, m, s));
+}
+
+
+// Message Handler
+SpValue& SpTime::onMessage(SpValue& rec, SpValue& msg)
+{
+    return TimeMsgHandler(rec, msg);
+}
+
+// init
+void SpTime::init()
+{
+    SpNameSpace* pTimeNS = new SpNameSpace;
+    SpValue TimeNS(pTimeNS);
+    PMainNameSpace->internConst(SymTime, TimeNS);
+
+    // for Class
+    SpValue SymNow(new SpSymbol("now"));
+    SpValue PrimNow(new SpPrim0(prim_now));
+    pTimeNS->internPrimProperty(SymNow, NilObject, PrimNow, NilObject);
+
+    SpValue SymNew(new SpSymbol("new"));
+    SpValue PrimNew(new SpPrim3(prim_new));
+    pTimeNS->internConst(SymNew, PrimNew);
+
+    SpValue SymFromString(new SpSymbol("fromstring"));
+    SpValue PrimFromString(new SpPrim1(prim_fromString));
+    pTimeNS->internConst(SymFromString, PrimFromString);
+
+    // for Object
+    SpValue GetHour(new SpPrim1(prim_getHour));
+    TimeMsgHandler.append(SymHour, GetHour);
+
+    SpValue GetMinute(new SpPrim1(prim_getMinute));
+    TimeMsgHandler.append(SymMinute, GetMinute);
+
+    SpValue GetSecond(new SpPrim1(prim_getSecond));
+    TimeMsgHandler.append(SymSecond, GetSecond);
+
+/*
+    SpValue PrimSucc(new SpPrim1(prim_succ));
+    TimeMsgHandler.append(SymSucc, PrimSucc);
+
+    SpValue PrimPred(new SpPrim1(prim_pred));
+    TimeMsgHandler.append(SymPred, PrimPred);
+*/
+}
+
+
diff --git a/src/Tuple.cpp b/src/Tuple.cpp
new file mode 100644 (file)
index 0000000..d0bb721
--- /dev/null
@@ -0,0 +1,259 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Tuple.cpp,v 1.14 2004/03/25 13:25:48 randy Exp $
+ */
+
+//
+// Soopy Tuple Class
+//
+
+#include "soopy.h"
+
+SpTuple::~SpTuple()
+{
+#ifdef TEST
+    *spout << ":destroy SpTuple: ";
+    *spout << toString() << "\n";
+#endif
+}
+
+SpValue& SpTuple::eval()
+{
+    SpValueVector::iterator it = vec.begin();
+    //    SpTuple* tuple = new SpTuple(it->eval());
+    SpValue  temp;
+    temp = it->eval();
+    SpTuple* tuple = new SpTuple(temp);
+    it++;
+    for(; it < vec.end(); it++){
+        //        tuple->append(it->eval());
+        temp = it->eval();
+        tuple->append(temp);
+    }
+
+    //    static SpValue result;
+    //    result.setNewObject(tuple);
+    //    return result;
+    return SpObjectResult(tuple);
+}
+
+SpValue& SpTuple::toString()
+{
+    SpString* str;
+    SpValueVector::iterator it = vec.begin();
+
+    str = new SpString();
+    *str = "(";
+    *str += it->toString();
+    it++;
+    for(; it < vec.end(); it++){
+        *str += ", ";
+        *str += it->toString();
+    }
+    *str += ")";
+    //    static SpValue s;
+    //    s.setNewObject(str);
+    //    return s;
+    return SpObjectResult(str);
+}
+
+bool SpTuple::operator==(SpObject& obj)
+{
+    if(SpTuple* s = dynamic_cast<SpTuple*>(&obj)){
+        SpValueVector::iterator it = vec.begin();
+        SpValueVector::iterator it2 = s->vec.begin();
+        while(true){
+            if(it == vec.end()){
+                if(it2 == s->vec.end()){
+                    return true;
+                }
+                break;
+            }
+            if(it2 == s->vec.end()){
+                break;
+            }
+            if(*it != *it2){
+                break;
+            }
+            it++;
+            it2++;
+        }
+    }
+    return false;
+}
+
+bool SpTuple::operator<(SpObject& obj)
+{
+    if(SpTuple* s = dynamic_cast<SpTuple*>(&obj)){
+        SpValueVector::iterator it = vec.begin();
+        SpValueVector::iterator it2 = s->vec.begin();
+        while(true){
+            if(it == vec.end()){
+                if(it2 == s->vec.end()){
+                    return false;
+                }
+                return true;
+            }
+            if(it2 == s->vec.end()){
+                return false;
+            }
+            if(*it != *it2){
+                return *it < *it2;
+            }
+            it++;
+            it2++;
+        }
+    }
+    return SpObject::operator<(obj);
+}
+
+bool SpTuple::match(SpValue&, SpValue& val, SpNameSpace* ns)
+{
+    if(val.isTuple()){
+        SpTuple* t = dynamic_cast<SpTuple*>(val.getObject());
+        if(length() == t->length()){
+            SpValueVector::iterator it, it2;
+            it = begin();
+            it2 = t->begin();
+            for(; it != end(); it++, it2++){
+                if(!it->match(*it2, ns)){
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
+    return false;
+}
+
+/*
+ * Message Handler
+ */
+
+SpValue& SpTuple::onMessage(SpValue& rec, SpValue& msg)
+{
+    return TupleMsgHandler(rec, msg);
+}
+
+// tuple Primitives
+
+SpValue& SpTuple::get_length(SpValue& self)
+{
+    SpTuple* t = self.asTuple();
+    //    static SpValue result;
+    //    result.setInt(t->length());
+    //    return result;
+    return SpIntResult(t->length());
+}
+
+SpValue& SpTuple::first(SpValue& self)
+{
+    SpTuple* t = self.asTuple();
+    if(t->length() < 1){
+        throw SpException("tuple size mismatch (first)");
+    }
+    //    static SpValue result;
+    //    result = (*t)[0];
+    //    return result;
+    return SpValueResult((*t)[0]);
+}
+
+SpValue& SpTuple::second(SpValue& self)
+{
+    SpTuple* t = self.asTuple();
+    if(t->length() < 2){
+        throw SpException("tuple size mismatch (second)");
+    }
+    //    static SpValue result;
+    //    result = (*t)[1];
+    //    return result;
+    return SpValueResult((*t)[1]);
+}
+
+SpValue& SpTuple::third(SpValue& self)
+{
+    SpTuple* t = self.asTuple();
+    if(t->length() < 3){
+        throw SpException("tuple size mismatch (third)");
+    }
+    //    static SpValue result;
+    //    result = (*t)[2];
+    //    return result;
+    return SpValueResult((*t)[2]);
+}
+
+SpValue& SpTuple::fourth(SpValue& self)
+{
+    SpTuple* t = self.asTuple();
+    if(t->length() < 4){
+        throw SpException("tuple size mismatch (fourth)");
+    }
+    //    static SpValue result;
+    //    result = (*t)[3];
+    //    return result;
+    return SpValueResult((*t)[3]);
+}
+
+SpValue& SpTuple::fifth(SpValue& self)
+{
+    SpTuple* t = self.asTuple();
+    if(t->length() < 5){
+        throw SpException("tuple size mismatch (fifth)");
+    }
+    //    static SpValue result;
+    //    result = (*t)[4];
+    //    return result;
+    return SpValueResult((*t)[4]);
+}
+
+SpValue& SpTuple::nth(SpValue& self, SpValue& index)
+{
+    if(!index.isInt()){
+        throw SpException("not int. (tuple.nth)");
+    }
+    SpInt i = index.getInt();
+    SpTuple* t = self.asTuple();
+    if(t->length() < i+1){
+        throw SpException("tuple size mismatch (tuple.nth)");
+    }
+    //    static SpValue result;
+    //    result = (*t)[i];
+    //    return result;
+    return SpValueResult((*t)[i]);
+}
+
+// init Message Handler
+void SpTuple::init()
+{
+    TupleMsgHandler.append(SymIsTuple, PrimTrue);
+
+    SpValue PrimLength(new SpPrim1(get_length));
+    TupleMsgHandler.append(SymLength, PrimLength);
+
+    SpValue PrimFirst(new SpPrim1(first));
+    TupleMsgHandler.append(SymFirst, PrimFirst);
+
+    SpValue PrimSecond(new SpPrim1(second));
+    TupleMsgHandler.append(SymSecond, PrimSecond);
+
+    SpValue PrimThird(new SpPrim1(third));
+    TupleMsgHandler.append(SymThird, PrimThird);
+
+    SpValue PrimFourth(new SpPrim1(fourth));
+    TupleMsgHandler.append(SymFourth, PrimFourth);
+
+    SpValue PrimFifth(new SpPrim1(fifth));
+    TupleMsgHandler.append(SymFifth, PrimFifth);
+
+    SpValue PrimNth(new SpPrim2(nth));
+    TupleMsgHandler.append(SymNth, PrimNth);
+}
+
diff --git a/src/URLEncode.cpp b/src/URLEncode.cpp
new file mode 100644 (file)
index 0000000..459d521
--- /dev/null
@@ -0,0 +1,291 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: URLEncode.cpp,v 1.6 2004/03/21 05:48:06 randy Exp $
+ */
+
+#include <stdio.h>
+#include "soopy.h"
+
+/*
+ * Class URLReader
+ */
+
+//  A-Z,a-z,0-9 & *-._   @          +$!'(), ~ \82Í\82»\82Ì\82Ü\82Ü\81B
+
+SpChar URLReadEncoder::readCh()
+{
+    switch(count){
+      case 1:
+      case 2:
+      case 3:
+      case 4:
+      case 5:
+        return results[count--];
+      default:
+        if(eof()){ return (SpChar)NULL; }
+        SpChar c = reader->ReadChar();
+
+        if(isDIGIT(c) || isAlpha(c)){
+            return c;
+        }
+        if(isdigit(c) || isalpha(c)){
+            return MakeSpChar(CodeJIS, c);
+        }
+        switch(c){
+          case JIS('*'):
+          case JIS('-'):
+          case JIS('.'):
+          case JIS('_'):
+            return c;
+          case '*':
+          case '-':
+          case '.':
+          case '_':
+            return MakeSpChar(CodeJIS, c);
+        }
+
+        char buf[5];
+        SpChar c2 = SpCharGetChar(c);
+        if(c2 >=0xFF){
+            // set 4 chars
+            sprintf(buf, "%04X", c2);
+            results[5] = MakeSpChar(CodeJIS, buf[0]);
+            results[4] = MakeSpChar(CodeJIS, buf[1]);
+            results[2] = MakeSpChar(CodeJIS, buf[2]);
+            results[1] = MakeSpChar(CodeJIS, buf[3]);
+            // set count
+            count = 5;
+        }else{
+            // set 2 chars
+            sprintf(buf, "%02X", c2);
+            results[2] = MakeSpChar(CodeJIS, buf[0]);
+            results[1] = MakeSpChar(CodeJIS, buf[1]);
+            // set count
+            count = 2;
+        }
+    }
+
+    return results[0];
+}
+
+/*
+ * Class URLWriteEncoder
+ */
+
+//void URLWriteEncoder::writeCh(unsigned char c)
+void URLWriteEncoder::WriteChar(SpChar c)
+{
+    if(isdigit(c) || isalpha(c)){
+        writer->WriteChar(c);
+        return;
+    }
+    switch(c){
+      case '*':
+      case '-':
+      case '.':
+      case '_':
+        writer->WriteChar(c);
+        return;
+    }
+
+    // set 2 chars
+    char buf[2];
+    sprintf(buf, "%02X", c);
+    writer->WriteChar(MakeSpChar(CodeJIS, '%'));
+    writer->WriteChar(MakeSpChar(CodeJIS, buf[0]));
+    writer->WriteChar(MakeSpChar(CodeJIS, buf[1]));
+}
+
+/*
+ * Class URLReader
+ */
+
+static bool isURLChar(char c)
+{
+    if(isdigit(c)){
+        return true;
+    }
+    if(isalpha(c)){
+        return true;
+    }
+    if((c == '+') ||
+       (c == '/') ||
+       (c == '='))
+    {
+        return true;
+    }
+    return false;
+}
+
+static int decodeChar(int c)
+{
+    int result;
+    if(isupper(c)){
+        result = c - 'A';
+    }else if(islower(c)){
+        result = c - 'a' + 26;
+    }else if(isdigit(c)){
+        result = c - '0' + 52;
+    }else{
+        switch(c){
+          case '+':
+            result = 62;
+            break;
+          case '/':
+            result = 63;
+            break;
+          case '=':
+            result = 0;
+            break;
+        }
+    }
+    return result;
+}
+
+SpChar URLReadDecoder::readCh()
+{
+    SpChar c = reader->ReadChar();
+    if(c != JIS('%')){
+        return c;
+    }
+
+    int i;
+    c = toHankakuLower(reader->ReadChar());
+    if(isDIGIT(c)){ // '0' - '9'
+        i = (c - JIS('0')) * 0x10;
+    }else{          // 'a' - 'f'
+        i = (c - JIS('a') + 10) * 0x10;
+    }
+    c = toHankakuLower(reader->ReadChar());
+    if(isDIGIT(c)){ // '0' - '9'
+        i = i + (c - JIS('0'));
+    }else{          // 'a' - 'f'
+        i = i + (c - JIS('a') + 10);
+    }
+    return i;
+}
+
+/*
+ * Class URLWriteDecoder
+ */
+
+void URLWriteDecoder::WriteChar(SpChar c)
+{
+    switch(count){
+      case 0:
+        if(c != '%'){
+            writer->WriteChar(c);
+            return;
+        }
+        // c == '%'
+        count++;
+        break;
+      case 1:
+        c = tolower(c);
+        if(isdigit(c)){ // '0' - '9'
+            src = (c - '0') * 0x10;
+        }else{          // 'a' - 'f'
+            src = (c - 'a' + 10) * 0x10;
+        }
+        count++;
+        break;
+      case 2:
+        c = tolower(c);
+        if(isdigit(c)){ // '0' - '9'
+            src = src + (c - '0');
+        }else{          // 'a' - 'f'
+            src = src + (c - 'a' + 10);
+        }
+        writer->WriteChar(src);
+        count = 0;
+        break;
+    }
+}
+
+/*
+ * URL
+ */
+
+SpValue& url_encoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (URL.encoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new URLReadEncoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& url_encoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (URL.encoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new URLWriteEncoder(writer);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& url_decoderIn(SpValue& v)
+{
+    SpValue r = v.eval();
+    if(!r.isReader()){
+        throw SpException("not reader (URL.decoderIn)");
+    }
+    Reader* reader = r.asReader();
+    ReadEncoder* encoder = new URLReadDecoder(reader);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& url_decoderOut(SpValue& v)
+{
+    SpValue w = v.eval();
+    if(!w.isWriter()){
+        throw SpException("not writer (URL.decoderOut)");
+    }
+    Writer* writer = w.asWriter();
+    WriteEncoder* encoder = new URLWriteDecoder(writer);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+// init
+void initURL()
+{
+    SpValue SymURLEncoder(new SpSymbol("urlencoder"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSURLEncoder(ns);
+    PMainNameSpace->internConst(SymURLEncoder, NSURLEncoder);
+
+    SpValue PrimEncoderIn(new SpPrim1(&url_encoderIn));
+    ns->internConst(SymEncoderIn, PrimEncoderIn);
+    SpValue PrimDecoderIn(new SpPrim1(&url_decoderIn));
+    ns->internConst(SymDecoderIn, PrimDecoderIn);
+
+    SpValue PrimEncoderOut(new SpPrim1(&url_encoderOut));
+    ns->internConst(SymEncoderOut, PrimEncoderOut);
+    SpValue PrimDecoderOut(new SpPrim1(&url_decoderOut));
+    ns->internConst(SymDecoderOut, PrimDecoderOut);
+}
+
diff --git a/src/Word.cpp b/src/Word.cpp
new file mode 100644 (file)
index 0000000..d3c7c40
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: Word.cpp,v 1.16 2004/05/22 05:22:34 randy Exp $
+ */
+
+#include "soopy.h"
+
+/*
+ * Word16File
+ *   openIn, openOut
+ */
+
+class Word16ReadEncoder : public ReadEncoder {
+private:
+    SpChar readCh(){
+        char c1, c2;
+//        c1 = reader->readCh();
+//        c2 = reader->readCh();
+        c1 = reader->ReadChar();
+        c2 = reader->ReadChar();
+        SpChar c = (((SpChar)c1) << 8) | c2;
+        return c;
+    }
+public:
+    Word16ReadEncoder(Reader* r) : ReadEncoder(r) {}
+};
+
+class Word16WriteEncoder : public WriteEncoder {
+private:
+    //void writeCh(SpChar c){
+    void WriteChar(SpChar c){
+//        writer->writeCh((c >> 8) & 0xff);
+//        writer->writeCh(c & 0xff);
+        writer->WriteChar((c >> 8) & 0xff);
+        writer->WriteChar(c & 0xff);
+    }
+public:
+    Word16WriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+SpValue& word16_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Word16File.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+#ifdef __WIN32__
+    fin->open(filename, ios::binary);
+#else
+    fin->open(filename);
+#endif
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new Word16ReadEncoder(sr);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& word16_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Word16File.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary);
+#else
+    fout->open(filename);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new Word16WriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& word16_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Word16.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new Word16WriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+/*
+ * Word32File
+ *   openIn, openOut
+ */
+
+class Word32ReadEncoder : public ReadEncoder {
+private:
+    SpChar readCh(){
+        SpChar c1, c2, c3, c4;
+/*
+        c1 = reader->readCh();
+        c2 = reader->readCh();
+        c3 = reader->readCh();
+        c4 = reader->readCh();
+*/
+        c1 = reader->ReadChar();
+        c2 = reader->ReadChar();
+        c3 = reader->ReadChar();
+        c4 = reader->ReadChar();
+        SpChar c = (c1 << 24) | (c2 << 16) | (c3 << 8) | c4;
+        return c;
+    }
+public:
+    Word32ReadEncoder(Reader* r) : ReadEncoder(r) {}
+};
+
+class Word32WriteEncoder : public WriteEncoder {
+private:
+    //void writeCh(SpChar c){
+    void WriteChar(SpChar c){
+//        writer->writeCh((c >> 24) & 0xff);
+//        writer->writeCh((c >> 16) & 0xff);
+//        writer->writeCh((c >> 8) & 0xff);
+//        writer->writeCh(c & 0xff);
+        writer->WriteChar((c >> 24) & 0xff);
+        writer->WriteChar((c >> 16) & 0xff);
+        writer->WriteChar((c >> 8) & 0xff);
+        writer->WriteChar(c & 0xff);
+    }
+public:
+    Word32WriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+SpValue& word32_openIn(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Word32File.openIn)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ifstream* fin = new ifstream;
+#ifdef __WIN32__
+    fin->open(filename, ios::binary);
+#else
+    fin->open(filename);
+#endif
+    if(fin->fail()){
+        delete fin;
+        throw SpException("can't open file");
+    }
+    FileStreamReader* sr = new FileStreamReader(fin, filename);
+    ReadEncoder* encoder = new Word32ReadEncoder(sr);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& word32_openOut(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Word32File.openOut)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::binary);
+#else
+    fout->open(filename);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new Word32WriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+SpValue& word32_openAppend(SpValue& v)
+{
+    SpValue name = v.eval();
+    if(!name.isString()){
+        throw SpException("filename is not string (Word32.openAppend)");
+    }
+    SpString* str = name.asString();
+    char* filename = (char*)str->toCStringWithEncoder();
+    ofstream* fout = new ofstream;
+#ifdef __WIN32__
+    fout->open(filename, ios::app | ios::binary);
+#else
+    fout->open(filename, ios::app);
+#endif
+    if(fout->fail()){
+        delete fout;
+        throw SpException("can't open file");
+    }
+    FileStreamWriter* sw = new FileStreamWriter(fout, filename);
+    WriteEncoder* encoder = new Word32WriteEncoder(sw);
+    //    static SpValue result;
+    //    result.setNewObject(encoder);
+    //    return result;
+    return SpObjectResult(encoder);
+}
+
+void initWordFile()
+{
+    // init Word16
+    SpValue SymWord16File(new SpSymbol("word16"));
+    SpNameSpace* ns = new SpNameSpace;
+    SpValue NSWord16File(ns);
+    PMainNameSpace->internConst(SymWord16File, NSWord16File);
+
+    SpValue PrimOpenIn(new SpPrim1(&word16_openIn));
+    ns->internConst(SymOpenIn, PrimOpenIn);
+
+    SpValue PrimOpenOut(new SpPrim1(&word16_openOut));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    SpValue PrimOpenAppend(new SpPrim1(&word16_openAppend));
+    ns->internConst(SymOpenOut, PrimOpenOut);
+
+    // init Word32
+    SpValue SymWord32File(new SpSymbol("word32"));
+    SpNameSpace* ns32 = new SpNameSpace;
+    SpValue NSWord32File(ns32);
+    PMainNameSpace->internConst(SymWord32File, NSWord32File);
+
+    SpValue PrimOpenIn32(new SpPrim1(&word32_openIn));
+    ns32->internConst(SymOpenIn, PrimOpenIn32);
+
+    SpValue PrimOpenOut32(new SpPrim1(&word32_openOut));
+    ns32->internConst(SymOpenOut, PrimOpenOut32);
+
+    SpValue PrimOpenAppend32(new SpPrim1(&word32_openAppend));
+    ns32->internConst(SymOpenAppend, PrimOpenAppend32);
+}
+
+
diff --git a/src/configure b/src/configure
new file mode 100755 (executable)
index 0000000..ae8c84e
--- /dev/null
@@ -0,0 +1,8111 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.61 for soopy 2.0.
+#
+# Report bugs to <jun.suzuki.japan@gmail.com>.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+if test "x$CONFIG_SHELL" = x; then
+  if (eval ":") 2>/dev/null; then
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+
+  if test $as_have_required = yes &&    (eval ":
+(as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=\$LINENO
+  as_lineno_2=\$LINENO
+  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+  :
+else
+  as_candidate_shells=
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  case $as_dir in
+        /*)
+          for as_base in sh bash ksh sh5; do
+            as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+          done;;
+       esac
+done
+IFS=$as_save_IFS
+
+
+      for as_shell in $as_candidate_shells $SHELL; do
+        # Try only shells that exist, to save several forks.
+        if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+               { ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+  CONFIG_SHELL=$as_shell
+              as_have_required=yes
+              if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+  (exit $1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+  break
+fi
+
+fi
+
+      done
+
+      if test "x$CONFIG_SHELL" != x; then
+  for as_var in BASH_ENV ENV
+        do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+        done
+        export CONFIG_SHELL
+        exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+    if test $as_have_required = no; then
+  echo This script requires a shell more modern than all the
+      echo shells that I found on your system.  Please install a
+      echo modern shell, or manually run the script under such a
+      echo shell if you do have one.
+      { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+  echo No shell found that supports shell functions.
+  echo Please tell autoconf@gnu.org about your system,
+  echo including any error possibly output before this
+  echo message
+}
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir
+fi
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s='ln -s'
+  # ... but there are two gotchas:
+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+  # In both cases, we have to default to `cp -p'.
+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+    as_ln_s='cp -p'
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+        test -d "$1/.";
+      else
+       case $1 in
+        -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+exec 7<&0 </dev/null 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Identity of this package.
+PACKAGE_NAME='soopy'
+PACKAGE_TARNAME='soopy'
+PACKAGE_VERSION='2.0'
+PACKAGE_STRING='soopy 2.0'
+PACKAGE_BUGREPORT='jun.suzuki.japan@gmail.com'
+
+ac_unique_file="soopy.cpp"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL
+PATH_SEPARATOR
+PACKAGE_NAME
+PACKAGE_TARNAME
+PACKAGE_VERSION
+PACKAGE_STRING
+PACKAGE_BUGREPORT
+exec_prefix
+prefix
+program_transform_name
+bindir
+sbindir
+libexecdir
+datarootdir
+datadir
+sysconfdir
+sharedstatedir
+localstatedir
+includedir
+oldincludedir
+docdir
+infodir
+htmldir
+dvidir
+pdfdir
+psdir
+libdir
+localedir
+mandir
+DEFS
+ECHO_C
+ECHO_N
+ECHO_T
+LIBS
+build_alias
+host_alias
+target_alias
+INSTALL_PROGRAM
+INSTALL_SCRIPT
+INSTALL_DATA
+am__isrc
+CYGPATH_W
+PACKAGE
+VERSION
+ACLOCAL
+AUTOCONF
+AUTOMAKE
+AUTOHEADER
+MAKEINFO
+install_sh
+STRIP
+INSTALL_STRIP_PROGRAM
+mkdir_p
+AWK
+SET_MAKE
+am__leading_dot
+AMTAR
+am__tar
+am__untar
+CXX
+CXXFLAGS
+LDFLAGS
+CPPFLAGS
+ac_ct_CXX
+EXEEXT
+OBJEXT
+DEPDIR
+am__include
+am__quote
+AMDEP_TRUE
+AMDEP_FALSE
+AMDEPBACKSLASH
+CXXDEPMODE
+am__fastdepCXX_TRUE
+am__fastdepCXX_FALSE
+CC
+CFLAGS
+ac_ct_CC
+CCDEPMODE
+am__fastdepCC_TRUE
+am__fastdepCC_FALSE
+YACC
+YFLAGS
+ALLOCA
+CPP
+GREP
+EGREP
+LIBOBJS
+LTLIBOBJS'
+ac_subst_files=''
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CXX
+CXXFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CCC
+CC
+CFLAGS
+YACC
+YFLAGS
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)   ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
+    eval enable_$ac_feature=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
+    eval enable_$ac_feature=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
+    eval with_$ac_package=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
+    eval with_$ac_package=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  { echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute directory names.
+for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
+               datadir sysconfdir sharedstatedir localstatedir includedir \
+               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+               libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; }
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  { echo "$as_me: error: Working directory cannot be determined" >&2
+   { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  { echo "$as_me: error: pwd does not report name of working directory" >&2
+   { (exit 1); exit 1; }; }
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$0" ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$0" : 'X\(//\)[^/]' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$0" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+   { (exit 1); exit 1; }; }
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+       cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2
+   { (exit 1); exit 1; }; }
+       pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures soopy 2.0 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                         [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                         [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR           user executables [EPREFIX/bin]
+  --sbindir=DIR          system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR       program executables [EPREFIX/libexec]
+  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
+  --libdir=DIR           object code libraries [EPREFIX/lib]
+  --includedir=DIR       C header files [PREFIX/include]
+  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
+  --datarootdir=DIR      read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR          read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR          info documentation [DATAROOTDIR/info]
+  --localedir=DIR        locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR           man documentation [DATAROOTDIR/man]
+  --docdir=DIR           documentation root [DATAROOTDIR/doc/soopy]
+  --htmldir=DIR          html documentation [DOCDIR]
+  --dvidir=DIR           dvi documentation [DOCDIR]
+  --pdfdir=DIR           pdf documentation [DOCDIR]
+  --psdir=DIR            ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of soopy 2.0:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+
+Some influential environment variables:
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  YACC        The `Yet Another C Compiler' implementation to use. Defaults to
+              the first program found out of: `bison -y', `byacc', `yacc'.
+  YFLAGS      The list of arguments that will be passed by default to $YACC.
+              This script will default YFLAGS to the empty string to avoid a
+              default value of `-d' given by some make applications.
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <jun.suzuki.japan@gmail.com>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" || continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+soopy configure 2.0
+generated by GNU Autoconf 2.61
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by soopy $as_me 2.0, which was
+generated by GNU Autoconf 2.61.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  echo "PATH: $as_dir"
+done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+    2)
+      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      ac_configure_args="$ac_configure_args '$ac_arg'"
+      ;;
+    esac
+  done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+       "s/'\''/'\''\\\\'\'''\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=\$$ac_var
+       case $ac_val in
+       *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       esac
+       echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      echo "$as_me: caught signal $ac_signal"
+    echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -n "$CONFIG_SITE"; then
+  set x "$CONFIG_SITE"
+elif test "x$prefix" != xNONE; then
+  set x "$prefix/share/config.site" "$prefix/etc/config.site"
+else
+  set x "$ac_default_prefix/share/config.site" \
+       "$ac_default_prefix/etc/config.site"
+fi
+shift
+for ac_site_file
+do
+  if test -r "$ac_site_file"; then
+    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+       { echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
+echo "$as_me:   former value:  $ac_old_val" >&2;}
+       { echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
+echo "$as_me:   current value: $ac_new_val" >&2;}
+       ac_cache_corrupted=:
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+am__api_version='1.10'
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  if test -f "$ac_dir/install-sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f "$ac_dir/install.sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f "$ac_dir/shtool"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
+echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+  ./ | .// | /cC/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+           break 3
+         fi
+       fi
+      done
+    done
+    ;;
+esac
+done
+IFS=$as_save_IFS
+
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5
+echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t $srcdir/configure conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      { { echo "$as_me:$LINENO: error: ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" >&5
+echo "$as_me: error: ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" >&2;}
+   { (exit 1); exit 1; }; }
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
+Check your system clock" >&5
+echo "$as_me: error: newly created file is older than distributed files!
+Check your system clock" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+{ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.  echo might interpret backslashes.
+# By default was `s,x,x', remove it if useless.
+cat <<\_ACEOF >conftest.sed
+s/[\\$]/&&/g;s/;s,x,x,$//
+_ACEOF
+program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
+rm -f conftest.sed
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
+echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
+echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in mkdir gmkdir; do
+        for ac_exec_ext in '' $ac_executable_extensions; do
+          { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir (GNU coreutils) '* | \
+            'mkdir (coreutils) '* | \
+            'mkdir (fileutils) '4.1*)
+              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              break 3;;
+          esac
+        done
+       done
+done
+IFS=$as_save_IFS
+
+fi
+
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    test -d ./--version && rmdir ./--version
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5
+echo "${ECHO_T}$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { echo "$as_me:$LINENO: result: $AWK" >&5
+echo "${ECHO_T}$AWK" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; }
+set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+  SET_MAKE=
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE=soopy
+ VERSION=1.0.0
+
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+
+# Checks for programs.
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+echo "${ECHO_T}$ac_ct_CXX" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+echo "$as_me:$LINENO: checking for C++ compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5
+echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" >&6; }
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+#
+# List of possible output files, starting from the most likely.
+# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
+# only as a last resort.  b.out is created by i960 compilers.
+ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
+#
+# The IRIX 6 linker writes into existing files which may not be
+# executable, retaining their permissions.  Remove them first so a
+# subsequent execution test works.
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       then :; else
+          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       fi
+       # We set ac_cv_exeext here because the later test for it is not
+       # safe: cross compilers may not add the suffix if given an `-o'
+       # argument, so we may need to know it at that point already.
+       # Even if this section looks crufty: it has the advantage of
+       # actually working.
+       break;;
+    * )
+       break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+
+{ echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6; }
+if test -z "$ac_file"; then
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C++ compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C++ compiler cannot create executables
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5
+echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6; }
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C++ compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+  fi
+fi
+{ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6; }
+
+{ echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; }
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         break;;
+    * ) break;;
+  esac
+done
+else
+  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+{ echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; }
+if test "${ac_cv_objext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
+GXX=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       CXXFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+        CXXFLAGS="-g"
+        cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo done
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
+echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+   am__include=include
+   am__quote=
+   _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+      am__include=.include
+      am__quote="\""
+      _am_result=BSD
+   fi
+fi
+
+
+{ echo "$as_me:$LINENO: result: $_am_result" >&5
+echo "${ECHO_T}$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CXX"  am_compiler_list=
+
+{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; }
+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO: checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       CFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_c89=$ac_arg
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6; } ;;
+  xno)
+    { echo "$as_me:$LINENO: result: unsupported" >&5
+echo "${ECHO_T}unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CC"   am_compiler_list=
+
+{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+for ac_prog in 'bison -y' byacc
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_YACC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$YACC"; then
+  ac_cv_prog_YACC="$YACC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_YACC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+YACC=$ac_cv_prog_YACC
+if test -n "$YACC"; then
+  { echo "$as_me:$LINENO: result: $YACC" >&5
+echo "${ECHO_T}$YACC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$YACC" && break
+done
+test -n "$YACC" || YACC="yacc"
+
+
+# Checks for libraries.
+
+# Checks for header files.
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # Extract the first word of "grep ggrep" to use in msg output
+if test -z "$GREP"; then
+set dummy grep ggrep; ac_prog_name=$2
+if test "${ac_cv_path_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_GREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in grep ggrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+    # Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_GREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+GREP="$ac_cv_path_GREP"
+if test -z "$GREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     # Extract the first word of "egrep" to use in msg output
+if test -z "$EGREP"; then
+set dummy egrep; ac_prog_name=$2
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_EGREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in egrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+    # Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_EGREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+EGREP="$ac_cv_path_EGREP"
+if test -z "$EGREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+
+   fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f -r conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f -r conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+# for constant arguments.  Useless!
+{ echo "$as_me:$LINENO: checking for working alloca.h" >&5
+echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6; }
+if test "${ac_cv_working_alloca_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+                         if (p) return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_working_alloca_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_working_alloca_h=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5
+echo "${ECHO_T}$ac_cv_working_alloca_h" >&6; }
+if test $ac_cv_working_alloca_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ALLOCA_H 1
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for alloca" >&5
+echo $ECHO_N "checking for alloca... $ECHO_C" >&6; }
+if test "${ac_cv_func_alloca_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# ifdef _MSC_VER
+#  include <malloc.h>
+#  define alloca _alloca
+# else
+#  ifdef HAVE_ALLOCA_H
+#   include <alloca.h>
+#  else
+#   ifdef _AIX
+ #pragma alloca
+#   else
+#    ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+#    endif
+#   endif
+#  endif
+# endif
+#endif
+
+int
+main ()
+{
+char *p = (char *) alloca (1);
+                                   if (p) return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_func_alloca_works=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_func_alloca_works=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5
+echo "${ECHO_T}$ac_cv_func_alloca_works" >&6; }
+
+if test $ac_cv_func_alloca_works = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ALLOCA 1
+_ACEOF
+
+else
+  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+# that cause trouble.  Some versions do not even contain alloca or
+# contain a buggy version.  If you still want to use their alloca,
+# use ar to extract alloca.o from them instead of compiling alloca.c.
+
+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
+
+cat >>confdefs.h <<\_ACEOF
+#define C_ALLOCA 1
+_ACEOF
+
+
+{ echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5
+echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6; }
+if test "${ac_cv_os_cray+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#if defined CRAY && ! defined CRAY2
+webecray
+#else
+wenotbecray
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "webecray" >/dev/null 2>&1; then
+  ac_cv_os_cray=yes
+else
+  ac_cv_os_cray=no
+fi
+rm -f -r conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5
+echo "${ECHO_T}$ac_cv_os_cray" >&6; }
+if test $ac_cv_os_cray = yes; then
+  for ac_func in _getb67 GETB67 getb67; do
+    as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define CRAY_STACKSEG_END $ac_func
+_ACEOF
+
+    break
+fi
+
+  done
+fi
+
+{ echo "$as_me:$LINENO: checking stack direction for C alloca" >&5
+echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6; }
+if test "${ac_cv_c_stack_direction+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_c_stack_direction=0
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+find_stack_direction ()
+{
+  static char *addr = 0;
+  auto char dummy;
+  if (addr == 0)
+    {
+      addr = &dummy;
+      return find_stack_direction ();
+    }
+  else
+    return (&dummy > addr) ? 1 : -1;
+}
+
+int
+main ()
+{
+  return find_stack_direction () < 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_stack_direction=1
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_c_stack_direction=-1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5
+echo "${ECHO_T}$ac_cv_c_stack_direction" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+_ACEOF
+
+
+fi
+
+
+
+
+
+
+ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5
+echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+  { echo "$as_me:$LINENO: checking for library containing opendir" >&5
+echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_search_opendir=$ac_res
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then
+  :
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
+echo "${ECHO_T}$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+  { echo "$as_me:$LINENO: checking for library containing opendir" >&5
+echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_search_opendir=$ac_res
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then
+  :
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
+echo "${ECHO_T}$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f -r conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f -r conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+
+
+
+
+
+
+
+
+
+
+for ac_header in arpa/inet.h libintl.h limits.h malloc.h netdb.h netinet/in.h stddef.h stdlib.h sys/socket.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ----------------------------------------- ##
+## Report this to jun.suzuki.japan@gmail.com ##
+## ----------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+#ヘッダファイルの存在確認
+
+for ac_header in stdio.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ----------------------------------------- ##
+## Report this to jun.suzuki.japan@gmail.com ##
+## ----------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_STDIO_H 1
+_ACEOF
+
+else
+  { { echo "$as_me:$LINENO: error: Sorry, can't do anything for you" >&5
+echo "$as_me: error: Sorry, can't do anything for you" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+done
+
+
+for ac_header in string.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ----------------------------------------- ##
+## Report this to jun.suzuki.japan@gmail.com ##
+## ----------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_STRING_H 1
+_ACEOF
+
+else
+  { { echo "$as_me:$LINENO: error: Sorry, can't do anything for you" >&5
+echo "$as_me: error: Sorry, can't do anything for you" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+done
+
+
+
+# Checks for typedefs, structures, and compiler characteristics.
+{ echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5
+echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdbool_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdbool.h>
+#ifndef bool
+ "error: bool is not defined"
+#endif
+#ifndef false
+ "error: false is not defined"
+#endif
+#if false
+ "error: false is not 0"
+#endif
+#ifndef true
+ "error: true is not defined"
+#endif
+#if true != 1
+ "error: true is not 1"
+#endif
+#ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+#endif
+
+       struct s { _Bool s: 1; _Bool t; } s;
+
+       char a[true == 1 ? 1 : -1];
+       char b[false == 0 ? 1 : -1];
+       char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+       char d[(bool) 0.5 == true ? 1 : -1];
+       bool e = &s;
+       char f[(_Bool) 0.0 == false ? 1 : -1];
+       char g[true];
+       char h[sizeof (_Bool)];
+       char i[sizeof s.t];
+       enum { j = false, k = true, l = false * true, m = true * 256 };
+       _Bool n[m];
+       char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+       char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+#      if defined __xlc__ || defined __GNUC__
+        /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+           reported by James Lemley on 2005-10-05; see
+           http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+           This test is not quite right, since xlc is allowed to
+           reject this program, as the initializer for xlcbug is
+           not one of the forms that C requires support for.
+           However, doing the test right would require a runtime
+           test, and that would make cross-compilation harder.
+           Let us hope that IBM fixes the xlc bug, and also adds
+           support for this kind of constant expression.  In the
+           meantime, this test will reject xlc, which is OK, since
+           our stdbool.h substitute should suffice.  We also test
+           this with GCC, where it should work, to detect more
+           quickly whether someone messes up the test in the
+           future.  */
+        char digs[] = "0123456789";
+        int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+#      endif
+       /* Catch a bug in an HP-UX C compiler.  See
+          http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+          http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+        */
+       _Bool q = true;
+       _Bool *pq = &q;
+
+int
+main ()
+{
+
+       *pq |= q;
+       *pq |= ! q;
+       /* Refer to every declared value, to avoid compiler optimizations.  */
+       return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+               + !m + !n + !o + !p + !q + !pq);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_header_stdbool_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_header_stdbool_h=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5
+echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; }
+{ echo "$as_me:$LINENO: checking for _Bool" >&5
+echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; }
+if test "${ac_cv_type__Bool+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef _Bool ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type__Bool=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_type__Bool=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5
+echo "${ECHO_T}$ac_cv_type__Bool" >&6; }
+if test $ac_cv_type__Bool = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE__BOOL 1
+_ACEOF
+
+
+fi
+
+if test $ac_cv_header_stdbool_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_STDBOOL_H 1
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; }
+if test "${ac_cv_c_const+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset cs;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *pcpcc;
+  char **ppc;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  pcpcc = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++pcpcc;
+  ppc = (char**) pcpcc;
+  pcpcc = (char const *const *) ppc;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+    if (s) return 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+    if (!foo) return 0;
+  }
+  return !cs[0] && !zero.x;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_const=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_c_const=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6; }
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for inline" >&5
+echo $ECHO_N "checking for inline... $ECHO_C" >&6; }
+if test "${ac_cv_c_inline+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_inline=$ac_kw
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
+echo "${ECHO_T}$ac_cv_c_inline" >&6; }
+
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+{ echo "$as_me:$LINENO: checking for size_t" >&5
+echo $ECHO_N "checking for size_t... $ECHO_C" >&6; }
+if test "${ac_cv_type_size_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef size_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_size_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_type_size_t=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+echo "${ECHO_T}$ac_cv_type_size_t" >&6; }
+if test $ac_cv_type_size_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5
+echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6; }
+if test "${ac_cv_struct_tm+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <time.h>
+
+int
+main ()
+{
+struct tm tm;
+                                    int *p = &tm.tm_sec;
+                                    return !p;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_struct_tm=time.h
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_struct_tm=sys/time.h
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
+echo "${ECHO_T}$ac_cv_struct_tm" >&6; }
+if test $ac_cv_struct_tm = sys/time.h; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TM_IN_SYS_TIME 1
+_ACEOF
+
+fi
+
+
+# Checks for library functions.
+{ echo "$as_me:$LINENO: checking whether closedir returns void" >&5
+echo $ECHO_N "checking whether closedir returns void... $ECHO_C" >&6; }
+if test "${ac_cv_func_closedir_void+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_closedir_void=yes
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header_dirent>
+#ifndef __cplusplus
+int closedir ();
+#endif
+
+int
+main ()
+{
+return closedir (opendir (".")) != 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_closedir_void=no
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_closedir_void=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_closedir_void" >&5
+echo "${ECHO_T}$ac_cv_func_closedir_void" >&6; }
+if test $ac_cv_func_closedir_void = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define CLOSEDIR_VOID 1
+_ACEOF
+
+fi
+
+
+for ac_header in stdlib.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ----------------------------------------- ##
+## Report this to jun.suzuki.japan@gmail.com ##
+## ----------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+{ echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5
+echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6; }
+if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_malloc_0_nonnull=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+char *malloc ();
+#endif
+
+int
+main ()
+{
+return ! malloc (0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_malloc_0_nonnull=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_malloc_0_nonnull=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5
+echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6; }
+if test $ac_cv_func_malloc_0_nonnull = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MALLOC 1
+_ACEOF
+
+else
+  cat >>confdefs.h <<\_ACEOF
+#define HAVE_MALLOC 0
+_ACEOF
+
+   case " $LIBOBJS " in
+  *" malloc.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS malloc.$ac_objext"
+ ;;
+esac
+
+
+cat >>confdefs.h <<\_ACEOF
+#define malloc rpl_malloc
+_ACEOF
+
+fi
+
+
+
+{ echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5
+echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6; }
+if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  rm -f conftest.sym conftest.file
+echo >conftest.file
+if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_lstat_dereferences_slashed_symlink=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+struct stat sbuf;
+     /* Linux will dereference the symlink and fail.
+       That is better in the sense that it means we will not
+       have to compile and use the lstat wrapper.  */
+     return lstat ("conftest.sym/", &sbuf) == 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_lstat_dereferences_slashed_symlink=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_lstat_dereferences_slashed_symlink=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+else
+  # If the `ln -s' command failed, then we probably don't even
+  # have an lstat function.
+  ac_cv_func_lstat_dereferences_slashed_symlink=no
+fi
+rm -f conftest.sym conftest.file
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5
+echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; }
+
+test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
+
+cat >>confdefs.h <<_ACEOF
+#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
+_ACEOF
+
+
+if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
+  case " $LIBOBJS " in
+  *" lstat.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS lstat.$ac_objext"
+ ;;
+esac
+
+fi
+
+{ echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5
+echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; }
+if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_stat_empty_string_bug=yes
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+struct stat sbuf;
+  return stat ("", &sbuf) == 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_stat_empty_string_bug=no
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_stat_empty_string_bug=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5
+echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; }
+if test $ac_cv_func_stat_empty_string_bug = yes; then
+  case " $LIBOBJS " in
+  *" stat.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS stat.$ac_objext"
+ ;;
+esac
+
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STAT_EMPTY_STRING_BUG 1
+_ACEOF
+
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+for ac_func in atexit floor getcwd gethostbyname memset mkdir modf pow rmdir socket sqrt strchr
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { echo "$as_me:$LINENO: updating cache $cache_file" >&5
+echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir
+fi
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s='ln -s'
+  # ... but there are two gotchas:
+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+  # In both cases, we have to default to `cp -p'.
+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+    as_ln_s='cp -p'
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+        test -d "$1/.";
+      else
+       case $1 in
+        -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+
+# Save the log message, to keep $[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by soopy $as_me 2.0, which was
+generated by GNU Autoconf 2.61.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+  -q, --quiet      do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+  --file=FILE[:TEMPLATE]
+                  instantiate the configuration file FILE
+  --header=FILE[:TEMPLATE]
+                  instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <bug-autoconf@gnu.org>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+soopy config.status 2.0
+configured by $0, generated by GNU Autoconf 2.61,
+  with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2006 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value.  By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    echo "$ac_cs_version"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    { echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) { echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; } ;;
+
+  *) ac_config_targets="$ac_config_targets $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+  echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+  CONFIG_SHELL=$SHELL
+  export CONFIG_SHELL
+  exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+
+  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} ||
+{
+   echo "$me: cannot create a temporary directory in ." >&2
+   { (exit 1); exit 1; }
+}
+
+#
+# Set up the sed scripts for CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "$CONFIG_FILES"; then
+
+_ACEOF
+
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
+SHELL!$SHELL$ac_delim
+PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim
+PACKAGE_NAME!$PACKAGE_NAME$ac_delim
+PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim
+PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim
+PACKAGE_STRING!$PACKAGE_STRING$ac_delim
+PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim
+exec_prefix!$exec_prefix$ac_delim
+prefix!$prefix$ac_delim
+program_transform_name!$program_transform_name$ac_delim
+bindir!$bindir$ac_delim
+sbindir!$sbindir$ac_delim
+libexecdir!$libexecdir$ac_delim
+datarootdir!$datarootdir$ac_delim
+datadir!$datadir$ac_delim
+sysconfdir!$sysconfdir$ac_delim
+sharedstatedir!$sharedstatedir$ac_delim
+localstatedir!$localstatedir$ac_delim
+includedir!$includedir$ac_delim
+oldincludedir!$oldincludedir$ac_delim
+docdir!$docdir$ac_delim
+infodir!$infodir$ac_delim
+htmldir!$htmldir$ac_delim
+dvidir!$dvidir$ac_delim
+pdfdir!$pdfdir$ac_delim
+psdir!$psdir$ac_delim
+libdir!$libdir$ac_delim
+localedir!$localedir$ac_delim
+mandir!$mandir$ac_delim
+DEFS!$DEFS$ac_delim
+ECHO_C!$ECHO_C$ac_delim
+ECHO_N!$ECHO_N$ac_delim
+ECHO_T!$ECHO_T$ac_delim
+LIBS!$LIBS$ac_delim
+build_alias!$build_alias$ac_delim
+host_alias!$host_alias$ac_delim
+target_alias!$target_alias$ac_delim
+INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
+INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
+INSTALL_DATA!$INSTALL_DATA$ac_delim
+am__isrc!$am__isrc$ac_delim
+CYGPATH_W!$CYGPATH_W$ac_delim
+PACKAGE!$PACKAGE$ac_delim
+VERSION!$VERSION$ac_delim
+ACLOCAL!$ACLOCAL$ac_delim
+AUTOCONF!$AUTOCONF$ac_delim
+AUTOMAKE!$AUTOMAKE$ac_delim
+AUTOHEADER!$AUTOHEADER$ac_delim
+MAKEINFO!$MAKEINFO$ac_delim
+install_sh!$install_sh$ac_delim
+STRIP!$STRIP$ac_delim
+INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim
+mkdir_p!$mkdir_p$ac_delim
+AWK!$AWK$ac_delim
+SET_MAKE!$SET_MAKE$ac_delim
+am__leading_dot!$am__leading_dot$ac_delim
+AMTAR!$AMTAR$ac_delim
+am__tar!$am__tar$ac_delim
+am__untar!$am__untar$ac_delim
+CXX!$CXX$ac_delim
+CXXFLAGS!$CXXFLAGS$ac_delim
+LDFLAGS!$LDFLAGS$ac_delim
+CPPFLAGS!$CPPFLAGS$ac_delim
+ac_ct_CXX!$ac_ct_CXX$ac_delim
+EXEEXT!$EXEEXT$ac_delim
+OBJEXT!$OBJEXT$ac_delim
+DEPDIR!$DEPDIR$ac_delim
+am__include!$am__include$ac_delim
+am__quote!$am__quote$ac_delim
+AMDEP_TRUE!$AMDEP_TRUE$ac_delim
+AMDEP_FALSE!$AMDEP_FALSE$ac_delim
+AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim
+CXXDEPMODE!$CXXDEPMODE$ac_delim
+am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim
+am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim
+CC!$CC$ac_delim
+CFLAGS!$CFLAGS$ac_delim
+ac_ct_CC!$ac_ct_CC$ac_delim
+CCDEPMODE!$CCDEPMODE$ac_delim
+am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim
+am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim
+YACC!$YACC$ac_delim
+YFLAGS!$YFLAGS$ac_delim
+ALLOCA!$ALLOCA$ac_delim
+CPP!$CPP$ac_delim
+GREP!$GREP$ac_delim
+EGREP!$EGREP$ac_delim
+LIBOBJS!$LIBOBJS$ac_delim
+LTLIBOBJS!$LTLIBOBJS$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 89; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+:end
+s/|#_!!_#|//g
+CEOF$ac_eof
+_ACEOF
+
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[         ]*VPATH[        ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[    ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[      ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+fi # test -n "$CONFIG_FILES"
+
+
+for ac_tag in  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
+echo "$as_me: error: Invalid tag $ac_tag." >&2;}
+   { (exit 1); exit 1; }; };;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+        # (if the path is not absolute).  The absolute path cannot be DOS-style,
+        # because $ac_f cannot contain `:'.
+        test -f "$ac_f" ||
+          case $ac_f in
+          [\\/$]*) false;;
+          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+          esac ||
+          { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+   { (exit 1); exit 1; }; };;
+      esac
+      ac_file_inputs="$ac_file_inputs $ac_f"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input="Generated from "`IFS=:
+         echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    fi
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin";;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  { as_dir="$ac_dir"
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+case `sed -n '/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+' $ac_file_inputs` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+    s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF
+  sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s&@configure_input@&$configure_input&;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out"; rm -f "$tmp/out";;
+  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
+  esac
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+_ACEOF
+
+# Transform confdefs.h into a sed script `conftest.defines', that
+# substitutes the proper values into config.h.in to produce config.h.
+rm -f conftest.defines conftest.tail
+# First, append a space to every undef/define line, to ease matching.
+echo 's/$/ /' >conftest.defines
+# Then, protect against being on the right side of a sed subst, or in
+# an unquoted here document, in config.status.  If some macros were
+# called several times there might be several #defines for the same
+# symbol, which is useless.  But do not sort them, since the last
+# AC_DEFINE must be honored.
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
+# NAME is the cpp macro being defined, VALUE is the value it is being given.
+# PARAMS is the parameter list in the macro definition--in most cases, it's
+# just an empty string.
+ac_dA='s,^\\([  #]*\\)[^        ]*\\([  ]*'
+ac_dB='\\)[     (].*,\\1define\\2'
+ac_dC=' '
+ac_dD=' ,'
+
+uniq confdefs.h |
+  sed -n '
+       t rset
+       :rset
+       s/^[     ]*#[    ]*define[       ][      ]*//
+       t ok
+       d
+       :ok
+       s/[\\&,]/\\&/g
+       s/^\('"$ac_word_re"'\)\(([^()]*)\)[      ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
+       s/^\('"$ac_word_re"'\)[  ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
+  ' >>conftest.defines
+
+# Remove the space that was appended to ease matching.
+# Then replace #undef with comments.  This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+# (The regexp can be short, since the line contains either #define or #undef.)
+echo 's/ $//
+s,^[    #]*u.*,/* & */,' >>conftest.defines
+
+# Break up conftest.defines:
+ac_max_sed_lines=50
+
+# First sed command is:         sed -f defines.sed $ac_file_inputs >"$tmp/out1"
+# Second one is:        sed -f defines.sed "$tmp/out1" >"$tmp/out2"
+# Third one will be:    sed -f defines.sed "$tmp/out2" >"$tmp/out1"
+# et cetera.
+ac_in='$ac_file_inputs'
+ac_out='"$tmp/out1"'
+ac_nxt='"$tmp/out2"'
+
+while :
+do
+  # Write a here document:
+    cat >>$CONFIG_STATUS <<_ACEOF
+    # First, check the format of the line:
+    cat >"\$tmp/defines.sed" <<\\CEOF
+/^[     ]*#[    ]*undef[        ][      ]*$ac_word_re[  ]*/b def
+/^[     ]*#[    ]*define[       ][      ]*$ac_word_re[(         ]/b def
+b
+:def
+_ACEOF
+  sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+    sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
+  ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
+  sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
+  grep . conftest.tail >/dev/null || break
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines conftest.tail
+
+echo "ac_result=$ac_in" >>$CONFIG_STATUS
+cat >>$CONFIG_STATUS <<\_ACEOF
+  if test x"$ac_file" != x-; then
+    echo "/* $configure_input  */" >"$tmp/config.h"
+    cat "$ac_result" >>"$tmp/config.h"
+    if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
+      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f $ac_file
+      mv "$tmp/config.h" $ac_file
+    fi
+  else
+    echo "/* $configure_input  */"
+    cat "$ac_result"
+  fi
+  rm -f "$tmp/out12"
+# Compute $ac_file's index in $config_headers.
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $ac_file | $ac_file:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $ac_file" >`$as_dirname -- $ac_file ||
+$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X$ac_file : 'X\(//\)[^/]' \| \
+        X$ac_file : 'X\(//\)$' \| \
+        X$ac_file : 'X\(/\)' \| . 2>/dev/null ||
+echo X$ac_file |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { echo "$as_me:$LINENO: executing $ac_file commands" >&5
+echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
+  # Strip MF so we end up with the name of the file.
+  mf=`echo "$mf" | sed -e 's/:.*$//'`
+  # Check whether this is an Automake generated Makefile or not.
+  # We used to match only the files named `Makefile.in', but
+  # some people rename them; so instead we look at the file content.
+  # Grep'ing the first line is not enough: some people post-process
+  # each Makefile.in and add a new line on top of each file to say so.
+  # Grep'ing the whole file is not good either: AIX grep has a line
+  # limit of 2048, but all sed's we know have understand at least 4000.
+  if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
+    dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$mf" : 'X\(//\)[^/]' \| \
+        X"$mf" : 'X\(//\)$' \| \
+        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  else
+    continue
+  fi
+  # Extract the definition of DEPDIR, am__include, and am__quote
+  # from the Makefile without running `make'.
+  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  am__include=`sed -n 's/^am__include = //p' < "$mf"`
+  test -z "am__include" && continue
+  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n 's/^U = //p' < "$mf"`
+  # Find all dependency output files, they are included files with
+  # $(DEPDIR) in their names.  We invoke sed twice because it is the
+  # simplest approach to changing $(DEPDIR) to its actual value in the
+  # expansion.
+  for file in `sed -n "
+    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+    # Make sure the directory exists.
+    test -f "$dirpart/$file" && continue
+    fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$file" : 'X\(//\)[^/]' \| \
+        X"$file" : 'X\(//\)$' \| \
+        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    { as_dir=$dirpart/$fdir
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+    # echo "creating $dirpart/$file"
+    echo '# dummy' > "$dirpart/$file"
+  done
+done
+ ;;
+
+  esac
+done # for ac_tag
+
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || { (exit 1); exit 1; }
+fi
+
diff --git a/src/configure.in b/src/configure.in
new file mode 100644 (file)
index 0000000..3b3ac48
--- /dev/null
@@ -0,0 +1,41 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.61)
+AC_INIT(soopy, 2.0, jun.suzuki.japan@gmail.com)
+AM_INIT_AUTOMAKE(soopy, 1.0.0, no-define)
+AC_CONFIG_SRCDIR([soopy.cpp])
+AC_CONFIG_HEADER([config.h])
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_YACC
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_FUNC_ALLOCA
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_CHECK_HEADERS([arpa/inet.h libintl.h limits.h malloc.h netdb.h netinet/in.h stddef.h stdlib.h sys/socket.h unistd.h])
+#ヘッダファイルの存在確認
+AC_CHECK_HEADERS([stdio.h],[AC_DEFINE(HAVE_STDIO_H)],[AC_MSG_ERROR([Sorry, can't do anything for you])])
+AC_CHECK_HEADERS([string.h],[AC_DEFINE(HAVE_STRING_H)],[AC_MSG_ERROR([Sorry, can't do anything for you])])
+
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_CONST
+AC_C_INLINE
+AC_TYPE_SIZE_T
+AC_STRUCT_TM
+
+# Checks for library functions.
+AC_FUNC_CLOSEDIR_VOID
+AC_FUNC_MALLOC
+AC_FUNC_STAT
+AC_CHECK_FUNCS([atexit floor getcwd gethostbyname memset mkdir modf pow rmdir socket sqrt strchr])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/src/pack.sp b/src/pack.sp
new file mode 100644 (file)
index 0000000..03f137c
--- /dev/null
@@ -0,0 +1,31 @@
+#!./soopy
+
+fun usage(){
+  do: [
+    println "usage: soopy pack.sp Version";
+    println "  ex. soopy pack.sp 0.5.1";
+  ];
+};
+
+fun pack(ver:string){
+  var:[name];
+  do: [
+    println("pack verion " + ver);
+    name = "soopy-" + ver + "-linux";
+    system("mkdir pack/" + name);
+    println("mkdir pack/" + name + " .. done.");
+    system("mkdir pack/" + name + "/examples");
+    println("mkdir pack/" + name + "/examples .. done.");
+    system("cp soopy pack/" + name);
+    system("cp test/*.sp pack/" + name + "/examples");
+    system("cp test/*.cgi pack/" + name + "/examples");
+    Dir chdir("pack");
+    system("tar cvf " + name + ".tar " + name);
+    system("gzip " + name + ".tar");
+  ];
+};
+
+match(Soopy CommandLine){
+  [ver]: pack(ver);
+  else: usage();
+};
diff --git a/src/parser.ypp b/src/parser.ypp
new file mode 100644 (file)
index 0000000..cff67f7
--- /dev/null
@@ -0,0 +1,803 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: parser.y,v 1.59 2004/03/27 05:59:44 randy Exp $
+ */
+
+%{
+#ifdef AQUA
+  //#include "../../soopy.h"
+#include "soopy.h"
+#else
+#include "soopy.h"
+#endif
+
+extern int yylex();
+extern SpValue program;
+
+static vector<bool> PublicVector;
+
+int yyerror(char* str)
+{
+    throw SpException(str);
+}
+
+void pushPublicVector()
+{
+    PublicVector.push_back(true);
+}
+
+void popPublicVector()
+{
+    PublicVector.pop_back();
+}
+
+void setPublic(bool p){
+    PublicVector.back() = p;
+}
+
+bool getPublic(){
+    return PublicVector.back();
+}
+
+void checkAllSymbols(SpValue& list)
+{
+    if(list.isSymbol() || list.isNil()){
+        return;
+    }
+    if(!list.isList()){
+        throw SpException("not symbol (list). fun{var:...}");
+    }
+    SpValue v = list;
+    while(!v.isNil()){
+        SpList* list = v.asList();
+        /* if(!(list->value().isSymbol())){ */
+        SpValue temp;
+        temp = list->value();
+        if(!(temp.isSymbol())){
+            throw SpException("syntax error. local var is not symbol");
+        }
+        v = list->nextList();
+    }
+}
+
+%}
+
+
+%token INT
+%token REAL
+%token CHAR
+%token STRING SYMBOL
+%token TokTRUE TokFALSE NIL
+%token FUN PROPERTY CONSTANT
+%token MATCH LOOP EXIT NEXT RETRY LET
+%token PRIVATE PUBLIC LARROW
+%token LB RB LP RP LC RC COMMA COLON SEMI DOT BAR
+%token EndOfStream
+%token ARRAY DATATYPE DOLL
+
+%right ASSIGN
+%left OR
+%left AND
+%right NOT
+%left EQ NE
+%left GT GE LT LE
+%left PLUS MINUS
+%left TIMES DIV MOD
+%right UMINUS
+%right WDOT WSLASH WCOLON AT /* AT = '@' */
+
+%%
+
+program : { pushPublicVector(); } stmt SEMI   {
+            program = $2;
+           /* SpValueResult(program); */
+            popPublicVector();
+            return 1;
+          }
+        | EndOfStream { return 0; }
+;
+
+stmt    : expr        { $$ = $1; }
+        | assign      { $$ = $1; }
+        | constant {
+            NSPairAdaptor* adapt = dynamic_cast<NSPairAdaptor*>($1.getObject());
+            SpValue v0 = getCurrentNS();
+            SpNameSpace* ns = dynamic_cast<SpNameSpace*>(v0.getObject());
+            SpValue val = adapt->pair->second;
+            ns->setValue(adapt->pair->first, val, ns);
+            $$ = val;
+          }
+        | function {
+            SpUsrFunc* f = dynamic_cast<SpUsrFunc*>($1.getObject());
+           //            SpValue place(new NSFunc(f->getName()));
+           SpValue temp;
+           temp = f->getName();
+            SpValue place(new NSFunc(temp));
+
+            SpValue v0 = getCurrentNS();
+            SpNameSpace* ns = dynamic_cast<SpNameSpace*>(v0.getObject());
+            ns->setValue(place, $1, ns);
+
+            $$ = $1;
+          }
+        | datatype {
+            SpDataType* dt = $1.asDataType();
+            SpValue v0 = getCurrentNS();
+            SpNameSpace* ns = v0.asNameSpace();
+            dt->mapping2ns($1, ns);
+            $$ = $1;
+          }
+;
+
+expr    : object { $$ = $1; }
+        | sendMessage { $$ = $1; }
+        | LP stmt RP { $$ = $2; }
+        | quoted { $$ = $1; }
+        | RETRY {
+            $$.setNewObject(new SpRetry());
+          }
+        | MINUS expr %prec UMINUS {
+            ExprUMinus* exp = new ExprUMinus($2);
+            $$.setNewObject(exp);
+          }
+        | expr PLUS expr {
+            ExprPlus* exp = new ExprPlus($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr MINUS expr {
+            ExprMinus* exp = new ExprMinus($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr TIMES expr {
+            ExprTimes* exp = new ExprTimes($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr DIV expr {
+            ExprDiv* exp = new ExprDiv($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr MOD expr {
+            ExprMod* exp = new ExprMod($1, $3);
+            $$.setNewObject(exp);
+          }
+        | NOT expr {
+            ExprNOT* exp = new ExprNOT($2);
+            $$.setNewObject(exp);
+          }
+        | expr OR expr {
+            ExprOR* exp = new ExprOR($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr AND expr {
+            ExprAND* exp = new ExprAND($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr EQ expr {
+            ExprEQ* exp = new ExprEQ($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr NE expr {
+            ExprNE* exp = new ExprNE($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr GT expr {
+            ExprGT* exp = new ExprGT($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr GE expr {
+            ExprGE* exp = new ExprGE($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr LT expr {
+            ExprLT* exp = new ExprLT($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr LE expr {
+            ExprLE* exp = new ExprLE($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr WCOLON expr {
+            ExprWColon* exp = new ExprWColon($1, $3);
+            $$.setNewObject(exp);
+          }
+        | expr AT expr {
+            ExprAT* exp = new ExprAT($1, $3);
+            $$.setNewObject(exp);
+          }
+/*
+        | IF LP expr RP match_assoc_body {
+            SpIf* exp = new SpIf($3, $5);
+            $$.setNewObject(exp);
+          }
+*/
+        | MATCH LP expr RP match_assoc_body {
+            SpIf* exp = new SpIf($3, $5);
+            $$.setNewObject(exp);
+          }
+        | loop { $$ = $1; }
+        | exit { $$ = $1; }
+        | next { $$ = $1; }
+;
+
+object  : INT       { $$ = $1; }
+        | NIL       { $$ = NilObject; }
+        | REAL      { $$ = $1; }
+        | CHAR      { $$ = $1; }
+        | TokTRUE   { $$ = TrueObject; }
+        | TokFALSE  { $$ = FalseObject; }
+        | STRING    { $$ = $1; }
+        | SYMBOL    { $$ = $1; }
+        | LP RP     { $$ = NilObject; }
+        | tuple     { $$ = $1; }
+        | list      { $$ = $1; }
+        | namespace {
+            $$.setNewObject(new MakeNameSpace($1));
+          }
+        | array     { $$ = $1; }
+;
+
+
+quoted  : DOLL SYMBOL { $$.setNewObject(new SpQuote($2)); }
+;
+
+/*
+ * Tuple
+ */
+
+tuple   : LP expr list_separator exprVector RP {
+            SpValueVector vec;
+            vec.push_back($2);
+            SpTuple* ptr = dynamic_cast<SpTuple*>($4.getObject());
+            vec.insert(vec.end(), ptr->vec.begin(), ptr->vec.end());
+            $$.setNewObject(new SpTuple(vec));
+          }
+;
+
+exprVector
+        : expr {
+            SpValueVector vec;
+            vec.push_back($1);
+            $$.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+          }
+        | exprVector list_separator expr {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+/*
+ * List, Range
+ */
+
+list    : LB RB                                    { $$ = NilObject; }
+        | LB expr_or_assign_list RB                { $$ = $2; }
+        | LB expr_or_assign_list list_separator RB { $$ = $2; }
+        | LB expr WDOT expr RB {
+            SpMakeRange* range = new SpMakeRange($2, $4);
+            $$.setNewObject(range);
+          }
+        | LB expr WDOT expr WDOT expr RB {
+            SpMakeRange* range = new SpMakeRange($2, $6, $4);
+            $$.setNewObject(range);
+          }
+        | LB expr WDOT RB {
+            SpMakeRange* range = new SpMakeRange($2, NilObject, true);
+            $$.setNewObject(range);
+          }
+        | LB expr WDOT expr WDOT RB {
+            SpMakeRange* range = new SpMakeRange($2, NilObject, $4, true);
+            $$.setNewObject(range);
+          }
+        | LB expr BAR list_creator_list RB {
+            $$.setNewObject(new SpListCompreCreator($2, $4, NilObject));
+          }
+        | LB expr BAR list_creator_list list_separator expr_list RB {
+            $$.setNewObject(new SpListCompreCreator($2, $4, $6));
+          }
+        | LB expr WSLASH list_creator_list RB {
+            $$.setNewObject(new SpListCompreDiagCreator($2, $4, NilObject));
+          }
+        | LB expr WSLASH list_creator_list list_separator expr_list RB {
+            $$.setNewObject(new SpListCompreCreator($2, $4, $6));
+          }
+;
+
+list_creator_list
+        : list_creator {
+            SpValueVector vec;
+            vec.push_back($1);
+            $$.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+          }
+        | list_creator_list list_separator list_creator {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+list_creator
+        : SYMBOL LARROW expr {
+            SpListCreator* ptr = new SpListCreator($1, $3);
+            $$.setNewObject(ptr);
+          }
+;
+
+expr_list
+        : /* nothing */ { $$ = NilObject; }
+        | exprs         { $$ = $1; }
+;
+
+exprs   : expr {
+            SpValueVector vec;
+            vec.push_back($1);
+            $$.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+          }
+        | exprVector list_separator expr {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+expr_or_assign
+        : expr   { $$ = $1; }
+        | assign { $$ = $1; }
+;
+
+expr_or_assign_list
+        : expr_or_assign {
+            SpCons* list = new SpCons($1);
+            $$.setNewObject(list);
+          }
+        | expr_or_assign_list list_separator expr_or_assign {
+            SpCons* ptr = dynamic_cast<SpCons*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+list_separator
+        : COMMA
+        | SEMI
+;
+
+/*
+ * NameSpace
+ */
+
+namespace
+        : LC { pushPublicVector(); } assocMap RC {
+            NSMapAdaptor* map_adapt = dynamic_cast<NSMapAdaptor*>($3.getObject());
+            NSMap* map = map_adapt->map;
+            SpNameSpace* ns = new SpNameSpace(*map, getCurrentNS());
+            $$.setNewObject(ns);
+            popPublicVector();
+          }
+;
+
+assocMap: /* nothing */ {
+            NSMap* map = new NSMap;
+            NSMapAdaptor* map_adapt = new NSMapAdaptor(map);
+            $$.setNewObject(map_adapt);
+          }
+        | assocMap assoc SEMI {
+            NSMapAdaptor* map_adapt = dynamic_cast<NSMapAdaptor*>($1.getObject());
+            NSMap* map = map_adapt->map;
+            NSPairAdaptor* adapt = dynamic_cast<NSPairAdaptor*>($2.getObject());
+            NSPair* pair = adapt->pair;
+            NSMap::iterator it = map->find(pair->first);
+            if(it != map->end()){
+                map->erase(it);
+            }
+            (*map)[pair->first] = pair->second;
+            $$ = $1;
+          }
+        | assocMap PRIVATE {
+            setPublic(false);
+            $$ = $1;
+          }
+        | assocMap PUBLIC  {
+            setPublic(true);
+            $$ = $1;
+          }
+;
+
+
+assoc   : pattern COLON assocValue {
+            NSPair* pair = new NSPair;
+            pair->first.setNewObject(new NSVar($1, getPublic()));
+            pair->second = $3;
+            NSPairAdaptor* adapt = new NSPairAdaptor(pair);
+            $$.setNewObject(adapt);
+          }
+        | constant { $$ = $1; }
+        | property { $$ = $1; }
+        | function {
+            NSPair* pair = new NSPair;
+            SpUsrFunc* f = dynamic_cast<SpUsrFunc*>($1.getObject());
+           //            pair->first.setNewObject(new NSFunc(f->getName(), getPublic()));
+           SpValue temp;
+           temp = f->getName();
+            pair->first.setNewObject(new NSFunc(temp, getPublic()));
+            pair->second = $1;
+            NSPairAdaptor* adapt = new NSPairAdaptor(pair);
+            $$.setNewObject(adapt);
+          }
+        | datatype {
+            NSPair* pair = new NSPair;
+            SpDataType* dt = $1.asDataType();
+            pair->first.setNewObject(new NSDataType(dt->symbol, getPublic()));
+            pair->second = $1;
+            NSPairAdaptor* adapt = new NSPairAdaptor(pair);
+            $$.setNewObject(adapt);
+          }
+;
+
+assocValue
+        : stmt { $$ = $1; }
+;
+
+match_assoc_body
+        : LC RC                 { $$ = NilObject; }
+        | LC match_assoc_vector RC { $$ = $2; }
+;
+
+match_assoc_vector
+        : match_assoc SEMI {
+            SpValueVector vec;
+            vec.push_back($1);
+            $$.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+          }
+        | match_assoc_vector match_assoc SEMI {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($1.getObject());
+            ptr->append($2);
+            $$ = $1;
+          }
+;
+
+match_assoc
+        : pattern COLON assocValue {
+            NSPair* pair = new NSPair;
+            pair->first = $1;
+            pair->second = $3;
+            NSPairAdaptor* adapt = new NSPairAdaptor(pair);
+            $$.setNewObject(adapt);
+          }
+;
+
+pattern : SYMBOL   { $$ = $1; }
+        | INT      { $$ = $1; }
+        | CHAR     { $$ = $1; }
+        | STRING   { $$ = $1; }
+        | TokTRUE  { $$ = TrueObject; }
+        | TokFALSE { $$ = FalseObject; }
+        | NIL      { $$ = NilObject; }
+        | LP RP    { $$ = NilObject; }
+        | list_pattern  { $$ = $1; }
+        | tuple_pattern { $$ = $1; }
+        | pattern WCOLON pattern {
+            SpPatternWColon* pat = new SpPatternWColon($1, $3);
+            $$.setNewObject(pat);
+          }
+        | list_pattern AT list_pattern {
+            SpPatternAt* pat = new SpPatternAt($1,$3);
+            $$.setNewObject(pat);
+          }
+        | con_pattern { $$ = $1; }
+;
+
+list_patterns
+        : pattern {
+            SpCons* list = new SpCons($1);
+            $$.setNewObject(list);
+          }
+        | list_patterns list_separator pattern {
+            SpCons* ptr = dynamic_cast<SpCons*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+list_pattern
+        : LB RB { $$ = NilObject; }
+        | LB list_patterns RB { $$ = $2; }
+;
+
+tuple_pattern
+        : LP pattern list_separator tuple_patterns RP {
+            SpValueVector vec;
+            vec.push_back($2);
+            SpTuple* ptr = dynamic_cast<SpTuple*>($4.getObject());
+            vec.insert(vec.end(), ptr->vec.begin(), ptr->vec.end());
+            $$.setNewObject(new SpTuple(vec));
+          }
+;
+
+tuple_patterns
+        : pattern {
+            SpValueVector vec;
+            vec.push_back($1);
+            $$.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+          }
+        | tuple_patterns list_separator pattern {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+con_pattern
+        : SYMBOL LP pattern RP {
+            SpValueVector vec;
+            vec.push_back($3);
+            SpValue v(new SpTuple(vec));
+            SpPatternCon* con = new SpPatternCon($1, v);
+            $$.setNewObject(con);
+          }
+        | SYMBOL tuple_pattern {
+            SpPatternCon* con = new SpPatternCon($1, $2);
+            $$.setNewObject(con);
+          }
+;
+
+type    : SYMBOL { $$ = $1; }
+;
+
+typ     : /* nothing */ { $$ = NilObject; }
+        | COLON type    { $$ = $2; }
+;
+
+constant: CONSTANT SYMBOL ASSIGN expr {
+            NSPair* pair = new NSPair;
+            SpValue v = $4.eval();
+            pair->first.setNewObject(new NSConst($2, getPublic(), v.getType()));
+            pair->second = v;
+            NSPairAdaptor* adapt = new NSPairAdaptor(pair);
+            $$.setNewObject(adapt);
+          }
+;
+
+property: PROPERTY SYMBOL typ namespace {
+            SpValue setter, getter;
+            SpNameSpace* ns = dynamic_cast<SpNameSpace*>($4.getObject());
+            getter = ns->lookup(SymGet);
+            setter = ns->lookup(SymSet);
+
+            NSPair* pair = new NSPair;
+            pair->first.setNewObject(new NSProperty($2, getter, setter, getPublic()));
+            pair->second = NilObject; /* no use */
+            NSPairAdaptor* adapt = new NSPairAdaptor(pair);
+            $$.setNewObject(adapt);
+          }
+;
+
+symbols : SYMBOL COMMA SYMBOL {
+            SpValueVector vec;
+            vec.push_back($1);
+            vec.push_back($3);
+            $$.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+          }
+        | symbols COMMA SYMBOL {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+assign  : SYMBOL ASSIGN expr {
+            $$.setNewObject(new SpAssign($1, $3));
+          }
+        | LET SYMBOL ASSIGN expr {
+            $$.setNewObject(new SpAssign($2, $4));
+          }
+        | LET LP symbols RP ASSIGN expr {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($3.getObject());
+            $$.setNewObject(new SpAssignS(ptr->vec, $6));
+          }
+        | LET LB symbols RB ASSIGN expr {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($3.getObject());
+            $$.setNewObject(new SpAssignList(ptr->vec, $6));
+          }
+        | LET SYMBOL WCOLON SYMBOL ASSIGN expr {
+            $$.setNewObject(new SpAssignHT($2, $4, $6));
+          }
+        | sendMessage ASSIGN expr {
+            $$.setNewObject(new SpAssignSM($1, $3));
+          }
+;
+
+receiver: object     { $$ = $1; }
+        | LP stmt RP { $$ = $2; }
+;
+
+message : object     { $$ = $1; }
+        | LP stmt RP { $$ = $2; }
+;
+
+sendMessage
+        : receiver message {
+            $$.setNewObject(new SpSendMsg($1, $2));
+          } 
+        | sendMessage message {
+            $$.setNewObject(new SpSendMsg($1, $2));
+          } 
+;
+
+arg     : SYMBOL typ {
+            $$.setNewObject(new SpArg($1, $2));
+          }
+;
+
+arg_list: arg {
+            SpValueVector vec;
+            vec.push_back($1);
+            $$.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+          }
+        | arg_list COMMA arg {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+args    : /* nothing */ { $$ = NilObject; }
+        | arg_list      { $$ = $1; }
+;
+
+argList : /* nothing */ { $$ = NilObject; }
+        | LP args RP    { $$ = $2; }
+;
+
+function: FUN SYMBOL argList namespace {
+            SpValue vars, require, body, ensure, rescue;
+
+            SpNameSpace* ns = dynamic_cast<SpNameSpace*>($4.getObject());
+            vars    = ns->lookup(SymVar);
+            checkAllSymbols(vars);
+            require = ns->lookup(SymRequire);
+            body    = ns->lookup(SymDo);
+            ensure  = ns->lookup(SymEnsure);
+            rescue  = ns->lookup(SymRescue);
+
+            $$.setNewObject(new SpUsrFunc($2,
+                                          $3,
+                                          vars,
+                                          require,
+                                          body,
+                                          ensure,
+                                          rescue));
+          }
+;
+
+
+loop    : LOOP namespace {
+            SpValue from, step, body, wcond, ucond, variant, invariant;
+
+            SpNameSpace* ns = dynamic_cast<SpNameSpace*>($2.getObject());
+            from      = ns->lookup(SymFrom);
+            step      = ns->lookup(SymStep);
+            body      = ns->lookup(SymDo);
+            wcond     = ns->lookup(SymWhile);
+            ucond     = ns->lookup(SymUntil);
+            variant   = ns->lookup(SymVariant);
+            invariant = ns->lookup(SymInvariant);
+            $$.setNewObject(new SpLoop(NilObject,
+                                       from,
+                                       step,
+                                       body,
+                                       wcond,
+                                       ucond,
+                                       variant,
+                                       invariant));
+          }
+        | LOOP SYMBOL namespace {
+            SpValue from, step, body, wcond, ucond, variant, invariant;
+
+            SpNameSpace* ns = dynamic_cast<SpNameSpace*>($3.getObject());
+            from      = ns->lookup(SymFrom);
+            step      = ns->lookup(SymStep);
+            body      = ns->lookup(SymDo);
+            wcond     = ns->lookup(SymWhile);
+            ucond     = ns->lookup(SymUntil);
+            variant   = ns->lookup(SymVariant);
+            invariant = ns->lookup(SymInvariant);
+            $$.setNewObject(new SpLoop($2,
+                                       from,
+                                       step,
+                                       body,
+                                       wcond,
+                                       ucond,
+                                       variant,
+                                       invariant));
+          }
+;
+
+exit    : EXIT {
+            $$.setNewObject(new SpExit());
+          }
+        | SYMBOL DOT EXIT {
+            $$.setNewObject(new SpExit($1));
+          }
+        | EXIT LP expr RP {
+            $$.setNewObject(new SpExit(NilObject, $3));
+          }
+        | SYMBOL DOT EXIT LP expr RP {
+            $$.setNewObject(new SpExit($1, $5));
+          }
+;
+
+next    : NEXT {
+            $$.setNewObject(new SpNext());
+          }
+        | SYMBOL DOT NEXT {
+            $$.setNewObject(new SpNext($1));
+          }
+;
+
+array   : ARRAY typ LP exprVector RP {
+            $$.setNewObject(new MakeArray($2, $4));
+          }
+;
+
+datatype: DATATYPE SYMBOL ASSIGN dtype_list {
+            SpTuple* p = dynamic_cast<SpTuple*>($4.getObject());
+            if(p == NULL){ throw SpSystemError(__FILE__, __LINE__); }
+            SpDataType* dt = new SpDataType($2, p->vec);
+            $$.setNewObject(dt);
+            /* set datatype to constructor */
+            SpValueVector::iterator it;
+            it = p->begin();
+            for(; it != p->end(); it++){
+               SpConstructor* con = it->asConstructor();
+               con->setDataType(dt);
+            }
+          }
+        | DATATYPE SYMBOL namespace ASSIGN dtype_list {
+            SpTuple* p = $5.asTuple();
+            SpDataType* dt = new SpDataType($2, p->vec);
+            $$.setNewObject(dt);
+            /* set datatype to constructor */
+            SpValueVector::iterator it;
+            it = p->begin();
+            for(; it != p->end(); it++){
+               SpConstructor* con = it->asConstructor();
+               con->setDataType(dt);
+               if(con->ns.isNil()){
+                       con->ns = $3;
+               }else{
+                       SpNameSpace* ns = con->ns.asNameSpace();
+                       ns->parentNS = $3;
+               }
+            }
+          }
+;
+
+dtype_list
+        : dtype {
+            SpValueVector vec;
+            vec.push_back($1);
+            $$.setNewObject(new SpTuple(vec)); /* this tuple can't print */
+          }
+        | dtype_list BAR dtype {
+            SpTuple* ptr = dynamic_cast<SpTuple*>($1.getObject());
+            ptr->append($3);
+            $$ = $1;
+          }
+;
+
+dtype   : SYMBOL argList {
+            $$.setNewObject(new SpConstructor($1, $2, NilObject));
+          }
+        | SYMBOL argList namespace {
+            $$.setNewObject(new SpConstructor($1, $2, $3));
+          }
+;
diff --git a/src/soopy.cpp b/src/soopy.cpp
new file mode 100644 (file)
index 0000000..f7c24f9
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ * 
+ * Copyright (C) 2002 SUZUKI Jun
+ * 
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ * 
+ * 
+ * $Id: soopy.cpp,v 1.9 2004/05/10 09:58:17 randy Exp $
+ */
+
+#include "soopy.h"
+
+
+//extern int load(const char* filename);
+extern SpValue& load(const char* filename);
+extern int interaction(bool p=true);
+
+int main(int argc, char* argv[], char* env[])
+{
+    extern int yyparse();
+    int result, status;
+
+    SpInit(argc-2, argv+2, env);
+
+    if(argc > 1){
+        load(argv[1]);
+    }else{
+        status = interaction();
+    }
+
+    SpFinalize();
+
+    return status;
+}
diff --git a/src/soopy.h b/src/soopy.h
new file mode 100644 (file)
index 0000000..6e06bd9
--- /dev/null
@@ -0,0 +1,4108 @@
+/*
+ * Programming Language SOOPY
+ *   (Simple Object Oriented Programming sYstem)
+ *
+ * Copyright (C) 2002,2003 SUZUKI Jun
+ *
+ * URL: http://sourceforge.jp/projects/soopy/
+ * License: GPL(GNU General Public License)
+ *
+ *
+ * $Id: soopy.h,v 1.228 2007/01/30 05:00:48 randy Exp $
+ */
+
+#ifndef __SOOPY_H
+#define __SOOPY_H
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <fstream>
+#include <string>
+#include <vector>
+#include <map>
+#include <exception>
+#include <typeinfo>
+#include <stdio.h>
+
+#ifdef USE_SOCKET
+
+#include <sys/types.h>
+#ifdef __WIN32__
+#include <dir.h>
+#include "winsock.h"
+#else
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#endif
+
+#endif /* USE_SOCKET */
+
+#ifdef USE_PTHREAD
+
+#include <pthread.h>
+
+#ifndef THREAD
+#define THREAD
+#endif
+
+#endif /* USE_PTHREAD */
+
+#ifdef USE_W32THREAD
+
+#include <process.h>
+#include <windows.h>
+
+#ifndef THREAD
+#define THREAD
+#endif /* USE_W32THREAD */
+
+#endif
+
+#ifdef __WIN32__
+#define PATH_DELIMIT ';'
+#endif
+
+#define CR 0x0d
+#define LF 0x0a
+
+using namespace std;
+
+typedef bool SpBool;
+typedef long int SpInt;
+typedef unsigned long int SpUInt;
+typedef double SpReal;
+typedef unsigned long int SpChar; // high16bit = CodeType,
+// low16bit  = CharCode
+
+#ifndef MAXPATH
+#define MAXPATH 2048
+#endif
+
+#ifdef __WIN32__
+const int SP_NAME_MAX = MAXPATH+4;
+#else
+#define SP_NAME_MAX (MAXPATH+4)
+#endif
+
+extern unsigned int lineno;
+extern char Filename[SP_NAME_MAX];
+inline void setFilename(char* s)
+{
+  strncpy(Filename, s, SP_NAME_MAX-2);
+  Filename[SP_NAME_MAX-2] = '\0';
+  Filename[SP_NAME_MAX-1] = '\0';
+}
+
+const int MaxLibPath = 20;
+const int MaxLibPathBuffer = 1024 * 4;
+extern int NumberOfLibPath;
+extern char* LibPaths[];
+
+inline void warning(char* str)
+{
+  cerr << "Warning: " << str << endl;
+}
+
+inline SpChar SpCharGetCode(SpChar ch){
+  return ch & 0xFFFF0000;
+}
+inline SpChar SpCharGetChar(SpChar ch){
+  return ch & 0x0000FFFF;
+}
+inline bool EqualCharCode(SpChar ch, SpChar code){
+  return SpCharGetCode(ch) == code;
+}
+/*
+inline SpChar MakeSpChar(SpChar code, SpChar ch){
+    return (SpChar)(code | ch);
+}
+ */
+#define MakeSpChar(code, ch)  ((SpChar)(code | ch))
+
+
+// Code number from TronCode
+const SpChar CodeJIS       = 0x00210000;
+const SpChar CodeGT1       = 0x00220000;
+const SpChar CodeGT2       = 0x00230000;
+const SpChar CodeCNS       = 0x00260000;
+const SpChar CodeDAIKANWA1 = 0x00280000;
+const SpChar CodeDAIKANWA2 = 0x00290000;
+const SpChar CodeTONPA     = 0x002a0000;
+const SpChar CodeUNICODE1  = 0x00300000;
+const SpChar CodeUNICODE2  = 0x00310000;
+
+/*
+ * Define Soopy's Types
+ */
+enum SpType {
+  TypeNil,
+  TypeBool,
+  TypeInt,
+  TypeChar,
+  TypeReal,
+  TypeString,
+  TypeSymbol,
+  TypeList,
+  TypeTuple,
+  TypeNameSpace,
+  TypeExpr,
+  TypeArray,
+  TypeDType,
+  TypeObject,
+  TypePersistent
+};
+
+class SpValue;
+class Writer;
+class WriteEncoder;
+class Reader;
+class ReadEncoder;
+class SpTuple;
+class SpNameSpace;
+class SpDataType;
+class SpConstructor;
+class SpArg;
+class SpDType;
+class NSKey;
+class SpList;
+class SpString;
+class SpFileOut;
+class SpFunc;
+class SpArray;
+class SpByteArray;
+class SpSymbol;
+class SpDir;
+class SpAssign;
+#ifdef USE_CLX
+class SpComponent;
+#endif
+#ifdef AQUA
+class SpComponent;
+#endif
+#ifdef USE_SOCKET
+class Socket;
+class ServerSocket;
+#endif
+class SpDate;
+class SpTime;
+class SpDateTime;
+#ifdef USE_DATABASE
+class SpDatabase;
+#endif
+
+extern WriteEncoder* spout;
+extern ReadEncoder* spin;
+extern SpValue NilObject;
+extern SpValue TrueObject;
+extern SpValue FalseObject;
+extern SpValue NullString;
+extern SpValue ObjectZero;
+extern SpValue ObjectOne;
+extern SpValue ObjectTwo;
+
+//
+// util routines
+//
+#define JIS(c) (CodeJIS | c)
+
+const char* spCharToCString(SpChar ch, WriteEncoder& writer = *spout);
+bool isWhiteSpace(SpChar c);
+bool isAlpha(SpChar c);
+bool isDIGIT(SpChar c);
+bool isEOL(SpChar c);
+bool isEOF(SpChar c);
+int toINT(SpChar c);
+SpChar toHankakuLower(SpChar c);
+SpInt int_fromString(SpString* str);
+
+inline bool isUpper(SpChar c)
+{
+  return (JIS('A') <= c) && (c <= JIS('Z'));
+}
+
+inline bool isLower(SpChar c)
+{
+  return (JIS('a') <= c) && (c <= JIS('z'));
+}
+
+inline SpChar SpChar2Lower(SpChar c)
+{
+  if(isUpper(c)){
+    c = c - ('A' - 'a');
+  }
+  return c;
+}
+
+inline SpChar SpChar2Upper(SpChar c)
+{
+  if(isLower(c)){
+    c = c + ('A' - 'a');
+  }
+  return c;
+}
+
+
+/*
+ * Soopy Base Exception Class
+ */
+
+class SpException {
+protected:
+  const char* str;
+  char file[SP_NAME_MAX];
+  unsigned int line;
+public:
+  SpException(const char* s){
+    str = s;
+    //file = Filename;
+    strcpy(file, Filename);
+    line = lineno;
+  }
+  virtual ~SpException(){}
+  virtual const char* what() const throw();
+};
+
+
+/*
+ * Soopy Base Class
+ */
+class SpObject {
+private:
+  unsigned int links;
+#ifdef USE_PTHREAD
+  pthread_mutex_t obj_mutex;
+#endif
+#ifdef USE_W32THREAD
+  HANDLE obj_mutex;
+#endif
+
+public:
+  SpObject(){
+    links = 0;
+#ifdef USE_PTHREAD
+    pthread_mutex_init(&obj_mutex, NULL);
+#endif /* USE_PTHREAD */
+#ifdef USE_W32THREAD
+    obj_mutex = CreateMutex(NULL, FALSE, NULL);
+    if(obj_mutex == NULL){
+      throw SpException("can't create mutex for Object");
+    }
+#endif /* USE_W32THREAD */
+  }
+  virtual ~SpObject(){
+#ifdef USE_PTHREAD
+    pthread_mutex_destroy(&obj_mutex);
+#endif /* USE_PTHREAD */
+#ifdef USE_W32THREAD
+    CloseHandle(obj_mutex);
+#endif /* USE_W32THREAD */
+  }
+
+  static void init();
+  //  static void finalize();
+
+  //virtual const char* toCString(); // only SpString should override
+  virtual const char* toCString(WriteEncoder& writer=*spout); // only SpString should override
+  virtual const char* toCStringWithEncoder(WriteEncoder& writer=*spout); // only SpString should override
+  virtual const char* typeString() = 0;
+  virtual SpValue& toString() = 0;
+
+  virtual bool operator==(SpObject& obj){ return false; }
+  virtual bool operator<(SpObject& obj);
+
+  virtual SpValue& uminus(SpValue& e);
+  virtual SpValue& plus(SpValue& e1, SpValue& e2);
+  virtual SpValue& minus(SpValue& e1, SpValue& e2);
+  virtual SpValue& times(SpValue& e1, SpValue& e2);
+  virtual SpValue& div(SpValue& e1, SpValue& e2);
+  virtual SpValue& mod(SpValue& e1, SpValue& e2);
+  virtual SpValue& boolNot(SpValue& e1);
+  virtual SpValue& boolAnd(SpValue& e1, SpValue& e2);
+  virtual SpValue& boolOr(SpValue& e1, SpValue& e2);
+  virtual SpValue& eq(SpValue& e1, SpValue& e2);
+  virtual SpValue& ne(SpValue& e1, SpValue& e2);
+  virtual SpValue& gt(SpValue& e1, SpValue& e2);
+  virtual SpValue& ge(SpValue& e1, SpValue& e2);
+  virtual SpValue& lt(SpValue& e1, SpValue& e2);
+  virtual SpValue& le(SpValue& e1, SpValue& e2);
+
+  virtual bool isString(){ return false; }
+  virtual bool isSymbol(){ return false; }
+  virtual bool isTuple(){ return false; }
+  virtual bool isList(){ return false; }
+  virtual bool isCons(){ return false; }
+  virtual bool isNameSpace(){ return false; }
+  virtual bool isSendMsg(){ return false; }
+  virtual bool isArray(){ return false; }
+  virtual bool isByteArray(){ return false; }
+  virtual bool isConstructor(){ return false; }
+  virtual bool isDataType(){ return false; }
+  virtual bool isArg(){ return false; }
+  virtual bool isDType(){ return false; }
+  virtual bool isNSKey(){ return false; }
+  virtual bool isFunc(){ return false; }
+  //virtual bool isFileIn(){ return false; }
+  virtual bool isReader(){ return false; }
+  //virtual bool isFileOut(){ return false; }
+  virtual bool isWriter(){ return false; }
+  virtual bool isDir(){ return false; }
+  virtual bool isAssign(){ return false; }
+#ifdef USE_CLX
+  virtual bool isComponent(){ return false; }
+#endif
+#ifdef AQUA
+  virtual bool isComponent(){ return false; }
+#endif
+#ifdef USE_SOCKET
+  virtual bool isSocket(){ return false; }
+  virtual bool isServerSocket(){ return false; }
+#endif
+  virtual bool isDate(){ return false; }
+  virtual bool isTime(){ return false; }
+  virtual bool isDateTime(){ return false; }
+#ifdef USE_DATABASE
+  virtual bool isDatabase(){ return false; }
+#endif
+
+  virtual SpValue& eval(){ return NilObject; }
+  virtual bool canEval(){ return false; }
+  virtual SpType getType(){ return TypeObject; }
+  virtual SpValue& onMessage(SpValue& rec, SpValue& msg);
+  virtual bool match(SpValue& self, SpValue& val, SpNameSpace* ns){ return false; }
+
+  // primitives
+  static SpValue& prim_toString(SpValue& self);
+
+  friend class SpValue;
+  friend class ReadEncoder;
+  friend class WriteEncoder;
+};
+
+#ifndef THREAD
+#define LOCK(obj)
+#define UNLOCK(obj)
+#endif /* not THREAD */
+
+#ifdef USE_W32THREAD
+#define LOCK(obj)   (WaitForSingleObject(obj->obj_mutex, INFINITE))
+#define UNLOCK(obj) (ReleaseMutex(obj->obj_mutex))
+#endif /* USE_W32THREAD */
+
+#ifdef USE_PTHREAD
+#define LOCK(obj)   (pthread_mutex_lock(&obj->obj_mutex))
+#define UNLOCK(obj) (pthread_mutex_unlock(&obj->obj_mutex))
+#endif /* USE_PTHREAD */
+
+/*
+ * Soopy Class for shared pointer
+ */
+class SpValue {
+private:
+  SpType typ;
+  union {
+    SpBool Bool;
+    SpInt Int;
+    SpChar Char;
+    SpReal Real;
+    SpObject* pObject;
+  };
+
+  void RetainObject(SpObject* obj){
+    pObject = obj;
+    if(pObject != NULL){
+      LOCK(pObject);
+      pObject->links++;
+      UNLOCK(pObject);
+    }
+  }
+
+  void ReleaseObject(){
+    if(pObject != NULL){
+      LOCK(pObject);
+      pObject->links--;
+      int links = pObject->links;
+      UNLOCK(pObject);
+      if(links == 0){
+        delete pObject;
+      }
+    }
+  }
+
+  void clearObject(){
+    if(typ == TypeObject){
+      ReleaseObject();
+    }
+  }
+
+public:
+  SpValue(){ typ = TypeNil; pObject = NULL; } // create Nil
+  SpValue(bool p){ typ = TypeBool; Bool = p; }
+  SpValue(int i){ typ = TypeInt; Int = i; }
+  SpValue(char c, ReadEncoder& reader=*spin);
+  /*
+#ifdef EUC_JP
+    SpValue(char c, ReadEncoder& reader=(ReadEncoder&)*eucjpin);
+#else
+    SpValue(char c, ReadEncoder& reader=(ReadEncoder&)*sjisin);
+#endif
+   */
+  SpValue(double d){ typ = TypeReal; Real = d; }
+  SpValue(const SpValue& val);
+  SpValue(SpObject* obj){
+    typ = TypeObject;
+    RetainObject(obj);
+  }
+  ~SpValue(){ clearObject(); }
+
+  void Clear(){ clearObject(); typ = TypeNil; }
+
+  SpValue& operator=(const SpValue& val);
+  /*
+    SpValue& operator=(SpValue* val){ operator=(*val); return *this; };
+    SpValue& operator=(SpObject* obj){ // BUG¤Î¸µ
+        cout << "operator=, BUG!!" << endl;
+        throw SpException("illegal use SpValue& operator=(SpObject*)");
+        return *this;
+    }
+    SpValue& operator=(const bool p);
+    SpValue& operator=(const int i);
+    SpValue& operator=(const char c);
+    SpValue& operator=(const char* str);
+    SpValue& operator=(const double d);
+   */
+  void setBool(SpBool p){
+    clearObject();
+    typ = TypeBool;
+    Bool = p;
+  }
+  void setSpChar(SpChar c){
+    clearObject();
+    typ = TypeChar;
+    Char = c;
+  }
+  void setInt(SpInt i){
+    clearObject();
+    typ = TypeInt;
+    Int = i;
+  }
+  void setReal(SpReal r){
+    clearObject();
+    typ = TypeReal;
+    Real = r;
+  }
+  void setNewObject(SpObject* obj){
+    if(isObject() && (pObject == obj)){
+      return;
+    }
+    clearObject();
+    typ = TypeObject;
+    RetainObject(obj);
+  }
+  void setObject(SpObject* obj){
+    if(isObject() && (pObject == obj)){
+      return;
+    }
+    clearObject();
+    typ = TypeObject;
+    RetainObject(obj);
+  }
+  SpBool getBool(){ return Bool; }
+  SpChar getChar(){ return Char; }
+  SpInt  getInt(){ return Int; }
+  SpReal getReal(){ return Real; }
+  SpObject* getObject();
+
+  SpInt asInt();
+  SpTuple* asTuple();
+  SpNameSpace* asNameSpace();
+  SpDataType* asDataType();
+  SpConstructor* asConstructor();
+  SpArg* asArg();
+  SpDType* asDType();
+  NSKey* asNSKey();
+  SpList* asList();
+  SpString* asString();
+  //SpFileIn* asFileIn();
+  Reader* asReader();
+  //SpFileOut* asFileOut();
+  Writer* asWriter();
+  SpFunc* asFunc();
+  SpArray* asArray();
+  SpByteArray* asByteArray();
+  SpSymbol* asSymbol();
+  SpDir* asDir();
+  SpAssign* asAssign();
+#ifdef USE_CLX
+  SpComponent* asComponent();
+#endif
+#ifdef AQUA
+  SpComponent* asComponent();
+#endif
+#ifdef USE_SOCKET
+  Socket* asSocket();
+  ServerSocket* asServerSocket();
+#endif
+  SpDate* asDate();
+  SpTime* asTime();
+  SpDateTime* asDateTime();
+#ifdef USE_DATABASE
+  SpDatabase* asDatabase();
+#endif
+
+  SpValue& uminus();
+  SpValue& plus(SpValue& e1);
+  SpValue& minus(SpValue& e1);
+  SpValue& times(SpValue& e1);
+  SpValue& div(SpValue& e1);
+  SpValue& mod(SpValue& e1);
+  SpValue& boolNot();
+  SpValue& boolAnd(SpValue& e1);
+  SpValue& boolOr(SpValue& e1);
+  SpValue& eq(SpValue& e1);
+  SpValue& ne(SpValue& e1);
+  SpValue& gt(SpValue& e1);
+  SpValue& ge(SpValue& e1);
+  SpValue& lt(SpValue& e1);
+  SpValue& le(SpValue& e1);
+  SpValue& wcolon(SpValue& e1);
+  SpValue& at(SpValue& e1);
+
+  bool operator==(SpValue& key);
+  bool operator!=(SpValue& key){ return ! operator==(key); }
+  bool operator<(SpValue& key);
+
+  bool isNil(){ return typ == TypeNil; }
+  bool isBool(){ return typ == TypeBool; }
+  bool isInt(){ return typ == TypeInt; }
+  bool isReal(){ return typ == TypeReal; }
+  bool isChar(){ return typ == TypeChar; }
+  bool isObject(){ return typ == TypeObject; }
+  bool isTrue(){
+    if(typ == TypeBool){
+      return Bool;
+    }
+    return false;
+  }
+  bool isFalse(){
+    if(typ == TypeBool){
+      return !Bool;
+    }
+    return false;
+  }
+  bool isString(){
+    if(typ == TypeObject){
+      return getObject()->isString();
+    }
+    return false;
+  }
+  bool isSymbol(){
+    if(typ == TypeObject){
+      return getObject()->isSymbol();
+    }
+    return false;
+  }
+  bool isTuple(){
+    if(typ == TypeObject){
+      return getObject()->isTuple();
+    }
+    return false;
+  }
+  bool isList(){
+    if(typ == TypeObject){
+      return getObject()->isList();
+    }
+    return false;
+  }
+  bool isCons(){
+    if(typ == TypeObject){
+      return getObject()->isCons();
+    }
+    return false;
+  }
+  bool isNameSpace(){
+    if(typ == TypeObject){
+      return getObject()->isNameSpace();
+    }
+    return false;
+  }
+  bool isSendMsg(){
+    if(typ == TypeObject){
+      return getObject()->isSendMsg();
+    }
+    return false;
+  }
+  bool isArray(){
+    if(typ == TypeObject){
+      return getObject()->isArray();
+    }
+    return false;
+  }
+  bool isByteArray(){
+    if(typ == TypeObject){
+      return getObject()->isByteArray();
+    }
+    return false;
+  }
+  bool isConstructor(){
+    if(typ == TypeObject){
+      return getObject()->isConstructor();
+    }
+    return false;
+  }
+  bool isDataType(){
+    if(typ == TypeObject){
+      return getObject()->isDataType();
+    }
+    return false;
+  }
+  bool isArg(){
+    if(typ == TypeObject){
+      return getObject()->isArg();
+    }
+    return false;
+  }
+  bool isDType(){
+    if(typ == TypeObject){
+      return getObject()->isDType();
+    }
+    return false;
+  }
+  bool isNSKey(){
+    if(typ == TypeObject){
+      return getObject()->isNSKey();
+    }
+    return false;
+  }
+  bool isFunc(){
+    if(typ == TypeObject){
+      return getObject()->isFunc();
+    }
+    return false;
+  }
+  bool isReader(){
+    if(typ == TypeObject){
+      return getObject()->isReader();
+    }
+    return false;
+  }
+  bool isWriter(){
+    if(typ == TypeObject){
+      return getObject()->isWriter();
+    }
+    return false;
+  }
+  bool isDir(){
+    if(typ == TypeObject){
+      return getObject()->isDir();
+    }
+    return false;
+  }
+  bool isAssign(){
+    if(typ == TypeObject){
+      return getObject()->isAssign();
+    }
+    return false;
+  }
+#ifdef USE_CLX
+  bool isComponent(){
+    if(typ == TypeObject){
+      return getObject()->isComponent();
+    }
+    return false;
+  }
+#endif
+#ifdef AQUA
+  bool isComponent(){
+    if(typ == TypeObject){
+      return getObject()->isComponent();
+    }
+    return false;
+  }
+#endif
+#ifdef USE_SOCKET
+  bool isSocket(){
+    if(typ == TypeObject){
+      return getObject()->isSocket();
+    }
+    return false;
+  }
+  bool isServerSocket(){
+    if(typ == TypeObject){
+      return getObject()->isServerSocket();
+    }
+    return false;
+  }
+#endif
+  bool isDate(){
+    if(typ == TypeObject){
+      return getObject()->isDate();
+    }
+    return false;
+  }
+  bool isTime(){
+    if(typ == TypeObject){
+      return getObject()->isTime();
+    }
+    return false;
+  }
+  bool isDateTime(){
+    if(typ == TypeObject){
+      return getObject()->isDateTime();
+    }
+    return false;
+  }
+#ifdef USE_DATABASE
+  bool isDatabase(){
+    if(typ == TypeObject){
+      return getObject()->isDatabase();
+    }
+    return false;
+  }
+#endif
+
+  SpValue& toString();
+  const char* toCString();
+  const char* toCStringWithEncoder(WriteEncoder& writer=*spout);
+  const char* typeString();
+  SpValue& eval();
+  SpType getType();
+  SpValue& onMessage(SpValue& msg);
+  bool match(SpValue& val, SpNameSpace* ns);
+
+  friend class WriteEncoder;
+  friend class RawReadEncoder;
+  friend int yyparse();
+  friend void SpInit(int,char**);
+  friend SpValue& char_toInt(SpValue& v);
+  friend SpValue& int_toChar(SpValue& v);
+};
+/*
+inline ostream& operator<<(ostream& out, SpValue& spVal)
+{
+  if(spVal.isList()){
+    SpList* list = spVal.asList();
+    out << list;
+  }else{
+    out << spVal.toCString();
+  }
+  return out;
+};
+ */
+
+
+extern SpValue NilObject;
+
+/*
+ * Soopy Exception Class
+ */
+
+class SpIllegalMessageException : public SpException {
+private:
+  SpValue msg;
+
+public:
+  SpIllegalMessageException(SpValue& v)
+       : SpException("illegal message"), msg(v) {}
+  const char* what() const throw();
+};
+
+class SpSystemError : public SpException {
+private:
+  char* filename;
+  int lineno;
+public:
+  SpSystemError(char* f, int l)
+       : SpException("system error"), filename(f), lineno(l) {}
+  const char* what() const throw();
+};
+
+class SpFileException : public SpException {
+public:
+  SpFileException(const char* s)
+       : SpException(s) {}
+};
+
+class SpAccessException : public SpException {
+public:
+  SpAccessException(const char* s)
+       : SpException(s) {}
+};
+
+class SpKeyException : public SpException {
+private:
+  const char* key;
+public:
+  SpKeyException(const char* s, const char* k)
+       : SpException(s) , key(k) {}
+  const char* what() const throw();
+};
+
+class SpTypeException : public SpException {
+private:
+  const char* rtype; // require type
+  const char* vtype; // value type
+public:
+  SpTypeException(const char* s, const char* r, const char* v)
+       : SpException(s) , rtype(r), vtype(v) {}
+  const char* what() const throw();
+};
+
+class SpRequireException : public SpException {
+public:
+  SpRequireException(const char* s)
+       : SpException(s) {}
+};
+
+class SpEnsureException : public SpException {
+public:
+  SpEnsureException(const char* s)
+       : SpException(s) {}
+};
+
+class SpRetryException : public SpException {
+public:
+  SpRetryException(const char* s)
+       : SpException(s) {}
+};
+
+class SpLoopVariantException : public SpException {
+public:
+  SpLoopVariantException(const char* s)
+       : SpException(s) {}
+};
+
+class SpLoopInvariantException : public SpException {
+public:
+  SpLoopInvariantException(const char* s)
+       : SpException(s) {}
+};
+
+class SpNoMethodException : public SpException {
+private:
+  char* receiver;
+  char* message;
+public:
+  SpNoMethodException(const char* s,
+                      char* rec,
+                      char* mes)
+       : SpException(s), receiver(rec), message(mes) {}
+  const char* what() const throw();
+};
+
+class SpExitException : public SpException {
+private:
+  SpValue symbol, val;
+public:
+  SpExitException(SpValue& sym, SpValue& v, const char* s)
+       : SpException(s), symbol(sym), val(v) {}
+  friend class SpLoop;
+  friend class SpUsrFunc;
+};
+
+class SpNextException : public SpException {
+private:
+  SpValue symbol;
+public:
+  SpNextException(SpValue& sym, const char* s)
+       : SpException(s), symbol(sym) {}
+  friend class SpLoop;
+};
+
+class SpNoLengthException : public SpException {
+public:
+  SpNoLengthException(const char* s)
+       : SpException(s) {}
+};
+
+/*
+class SpNullListCreator : public SpException {
+public:
+  SpNullListCreator(const char* s) : SpException(s) {}
+};
+ */
+
+/*
+ * Thread
+ */
+
+struct ThreadContext {
+  SpValue gResult;
+  vector<SpValue> Frame;
+};
+
+#ifdef USE_PTHREAD
+
+extern pthread_key_t pthread_key;
+
+class SpThread : public SpObject {
+private:
+  pthread_t thread;
+  SpValue   assoc;
+  SpValue   body;
+  static    std::vector<SpValue> all_threads;  // GC¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¥¹¥ì¥Ã¥É¤òÊÝ»ý¤·¤Æ¤ª¤¯¾ì½ê
+
+  static void removeContext(ThreadContext* con);
+  static void start(SpThread* th);
+  void run();
+  // primitives
+  static SpValue& prim_start(SpValue& body);
+  static SpValue& prim_join(SpValue& thread);
+  static SpValue& prim_quit(SpValue& thread);
+
+public:
+  SpThread(SpValue& ns, SpValue& b) : assoc(ns), body(b) {}
+  ~SpThread();
+
+  bool isThread(){ return true; }
+  const char* typeString(){ return "thread"; }
+  SpValue& toString();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+
+  static void init();
+  static void init2();
+  static void finalize();
+};
+
+inline SpValue* getCurrentResult(){
+  ThreadContext* context;
+  context = (ThreadContext*)pthread_getspecific(pthread_key);
+  return &(context->gResult);
+}
+
+class SpMutex : public SpObject {
+private:
+  pthread_mutex_t* mutex;
+
+  static SpValue& prim_synchronize(SpValue& mutex, SpValue& func);
+  static SpValue& prim_new();
+
+public:
+  SpMutex(){
+    mutex = (pthread_mutex_t*)malloc(sizeof(pthread_mutex_t));
+    pthread_mutex_init(mutex, NULL);
+  }
+  ~SpMutex(){
+    if(mutex != NULL){
+      pthread_mutex_destroy(mutex);
+      free(mutex);
+    }
+  }
+
+  void lock(){
+    pthread_mutex_lock(mutex);
+  }
+  void unlock(){
+    pthread_mutex_unlock(mutex);
+  }
+
+  bool isMutex(){ return true; }
+  const char* typeString(){ return "mutex"; }
+  SpValue& toString();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+
+  static void init();
+};
+
+#endif  /* USE_PTHREAD */
+
+#ifdef USE_W32THREAD
+
+extern DWORD tls_key;
+
+class SpThread : public SpObject {
+private:
+  HANDLE  hThread;
+  unsigned id;
+  SpValue assoc;
+  SpValue body;
+  static  std::vector<SpValue> all_threads;  // GC¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¥¹¥ì¥Ã¥É¤òÊݤäƤª¤¯¾ì½ê
+
+  static void removeContext(ThreadContext* con);
+  static unsigned __stdcall start(SpThread* th);
+  void run();
+  // primitives
+  static SpValue& prim_start(SpValue& body);
+  static SpValue& prim_join(SpValue& thread);
+  static SpValue& prim_quit(SpValue& thread);
+
+public:
+  SpThread(SpValue& ns, SpValue& b) : assoc(ns), body(b) {}
+  ~SpThread();
+
+  bool isThread(){ return true; }
+  const char* typeString(){ return "thread"; }
+  SpValue& toString();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+
+  static void init();
+  static void init2();
+  static void finalize();
+};
+
+inline SpValue* getCurrentResult(){
+  ThreadContext* context;
+  //  context = (ThreadContext*)pthread_getspecific(pthread_key);
+  context = (ThreadContext*)TlsGetValue(tls_key);
+  return &(context->gResult);
+}
+
+class SpMutex : public SpObject {
+private:
+  HANDLE mutex;
+
+  static SpValue& prim_synchronize(SpValue& mutex, SpValue& func);
+  static SpValue& prim_new();
+
+public:
+  SpMutex(){
+    mutex = CreateMutex(NULL, FALSE, NULL);
+    if(mutex == NULL){
+      throw SpException("can't create mutex");
+    }
+  }
+  ~SpMutex(){
+    CloseHandle(mutex);
+  }
+
+  void lock(){
+    WaitForSingleObject(mutex, INFINITE);
+  }
+  void unlock(){
+    ReleaseMutex(mutex);
+  }
+
+  bool isMutex(){ return true; }
+  const char* typeString(){ return "mutex"; }
+  SpValue& toString();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+
+  static void init();
+};
+
+#endif  /* USE_W32THREAD */
+
+#ifndef THREAD
+
+extern SpValue gResult;
+
+inline SpValue* getCurrentResult(){
+  return &gResult;
+}
+
+#endif /* not THREAD */
+
+inline SpValue& SpBoolResult(SpBool p){
+  SpValue* res = getCurrentResult();
+  res->setBool(p);
+  return *res;
+}
+inline SpValue& SpIntResult(SpInt i){
+  SpValue* res = getCurrentResult();
+  res->setInt(i);
+  return *res;
+}
+inline SpValue& SpCharResult(SpChar c){
+  SpValue* res = getCurrentResult();
+  res->setSpChar(c);
+  return *res;
+}
+inline SpValue& SpRealResult(SpReal r){
+  SpValue* res = getCurrentResult();
+  res->setReal(r);
+  return *res;
+}
+inline SpValue& SpObjectResult(SpObject* obj){
+  SpValue* res = getCurrentResult();
+  res->setObject(obj);
+  return *res;
+}
+inline SpValue& SpValueResult(SpValue& val){
+  SpValue* res = getCurrentResult();
+  *res = val;
+  return *res;
+}
+
+/*
+ * Readers for SOOPY
+ */
+
+class Reader : public virtual SpObject {
+private:
+  bool unread;
+  SpChar unreadChar;
+
+protected:
+  virtual char* getFilename(){ return "a reader"; }
+
+public:
+  Reader(){ unread=false; }
+
+  virtual SpChar fromChar(char c)
+    {
+      return MakeSpChar(CodeJIS, c);
+    }
+  virtual SpChar readCh() = 0;
+  virtual bool eof() = 0;
+  virtual bool is_open() = 0;
+  virtual void close(){}
+  virtual void setReader(Reader* r){
+    throw SpException("reader does not have a reader (setReader)");
+  }
+  virtual Reader* getReader(){
+    throw SpException("reader does not have a reader (getReader)");
+    return NULL;
+  }
+  SpChar ReadChar(){
+    if(!unread){
+      unreadChar = readCh();
+    }
+    unread = false;
+    return unreadChar;
+  }
+  void UnreadChar(SpChar ch){
+    unread = true;
+    if(unreadChar != ch){
+      throw SpException("not match unreadChar");
+    }
+  }
+  virtual SpValue& Read(SpInt n){
+    throw SpException("reader does not have a function 'Read'");
+    return NilObject;
+  }
+  virtual SpValue& ReadByte(SpInt n, unsigned char* buf){
+    throw SpException("reader does not have a function 'ReadByte'");
+    return NilObject;
+  }
+  SpValue& ReadLine();
+  SpValue& ReadLineS();
+  virtual SpValue& ScanByte(SpString*, Reader*){
+    throw SpException("reader does not have a function 'ScanByte'");
+    return NilObject;
+  }
+  virtual SpValue& SkipByte(SpInt n){
+    throw SpException("reader does not have a function 'SkipByte'");
+    return NilObject;
+  }
+  virtual SpValue& ScanByteStr(int count){
+    throw SpException("reader does not have a function 'ScanByte'");
+    return NilObject;
+  }
+
+  SpChar ReadAsLowerChar(){
+    SpChar c = ReadChar();
+    return toHankakuLower(c);
+  }
+  void UnreadAsLowerChar(SpChar ch){
+    unread = true;
+  }
+
+  bool isReader(){ return true; }
+  SpValue& toString();
+  const char* typeString(){ return "reader"; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  static void init();
+
+  // primitives
+  static SpValue& prim_close(SpValue& fin);
+  static SpValue& prim_closed(SpValue& fin);
+  static SpValue& prim_readChar(SpValue& fin);
+  static SpValue& prim_unreadChar(SpValue& fin, SpValue& ch);
+  static SpValue& prim_peekChar(SpValue& fin);
+  static SpValue& prim_readLine(SpValue& fin);
+  static SpValue& prim_readLineS(SpValue& fin);
+  static SpValue& prim_read(SpValue& fin, SpValue& n);
+  static SpValue& prim_readbyte(SpValue& fin, SpValue& n, SpValue& byte_vector);
+  static SpValue& prim_eof(SpValue& fin);
+  static SpValue& prim_skipbyte(SpValue& fin, SpValue& n);
+  static SpValue& prim_scanbyte(SpValue& fin, SpValue& str);
+
+  friend class ReadEncoder;
+};
+
+class StreamReader : public Reader {
+protected:
+  istream* stream;
+  SpValue& ScanByteStr(int count);
+
+public:
+  StreamReader(istream* s) : stream(s) {}
+
+  void setStream(istream* s){ stream = s; }
+  istream* getStream(){ return stream; }
+
+#ifdef OSX
+  bool eof(){ return stream->eof(); }
+#else
+  bool eof(){
+    unsigned char c;
+    stream->read((char*)&c, 1);
+    bool p = stream->eof();
+    stream->unget();
+    return p;
+  }
+#endif
+  bool is_open(){ return true; }
+  SpChar readCh(){
+    unsigned char c;
+    stream->read((char*)&c, 1);
+    return (SpChar)c;
+  }
+  SpValue& Read(SpInt n);
+  SpValue& ReadByte(SpInt n, unsigned char* buf);
+  SpValue& SkipByte(SpInt n);
+  SpValue& ScanByte(SpString* format, Reader* self);
+};
+
+class FileStreamReader : public StreamReader {
+private:
+  char* filename;
+  char* getFilename(){ return filename; }
+public:
+  FileStreamReader(ifstream* s, char* n)
+       : StreamReader(s),
+         filename(n)
+    {}
+
+  bool is_open(){ return ((ifstream*)stream)->is_open(); }
+  void close(){ ((ifstream*)stream)->close(); }
+};
+
+class ReadEncoder : public Reader {
+protected:
+  SpValue taker;
+  Reader* reader;
+  char* getFilename(){ return reader->getFilename(); }
+  SpValue& ScanByteStr(int count);
+public:
+  ReadEncoder(Reader* r) : reader(r) { taker.setObject(r); }
+
+  virtual void setReader(Reader* r){
+    reader = r;
+  }
+  Reader* getReader(){ return reader; }
+
+  bool eof(){ return reader->eof(); }
+  void close(){ reader->close(); }
+  bool is_open(){ return reader->is_open(); }
+  SpChar fromChar(char c){ return reader->fromChar(c); }
+  SpValue& Read(SpInt n){ return reader->Read(n); }
+  SpValue& ReadByte(SpInt n, unsigned char* buf){ return reader->ReadByte(n, buf); }
+  SpValue& SkipByte(SpInt n){ return reader->SkipByte(n); }
+  SpValue& ScanByte(SpString* format, Reader*){
+      return reader->ScanByte(format, this);
+  }
+};
+
+class RawReadEncoder : public ReadEncoder {
+private:
+  SpChar readCh(){ return reader->ReadChar(); }
+public:
+  RawReadEncoder(Reader* r) : ReadEncoder(r) {}
+};
+
+class SjisReadEncoder : public ReadEncoder {
+private:
+  SpChar buf[1];
+  int count;
+  SpChar readCh();
+public:
+  SjisReadEncoder(Reader* r) : ReadEncoder(r) { count=-1; }
+  bool eof(){ return (count < 0) && reader->eof(); }
+
+  friend class JapaneseReadEncoder;
+};
+
+class SjisReadDecoder : public ReadEncoder {
+private:
+  SpChar readCh();
+public:
+  SjisReadDecoder(Reader* r) : ReadEncoder(r) {}
+
+  friend class JapaneseReadEncoder;
+};
+
+class EucJPReadEncoder : public ReadEncoder {
+private:
+  SpChar buf[1];
+  int count;
+  SpChar readCh();
+public:
+  EucJPReadEncoder(Reader* r) : ReadEncoder(r) { count=-1; }
+  bool eof(){ return (count < 0) && reader->eof(); }
+
+  friend class JapaneseReadEncoder;
+};
+
+class EucJPReadDecoder : public ReadEncoder {
+private:
+  SpChar readCh();
+public:
+  EucJPReadDecoder(Reader* r) : ReadEncoder(r) {}
+
+  friend class JapaneseReadEncoder;
+};
+
+const int kCodeASCII    = 0;
+const int kCodeJISX0208 = 1;
+const int kCodeUNKNOWN  = 2;
+const int kCodeESCAPE   = 3; // escape sequence
+
+class ISO2022JPReadEncoder : public ReadEncoder {
+private:
+  SpChar buf[5];
+  int count;
+  int out_now;
+  SpChar readCh();
+public:
+  ISO2022JPReadEncoder(Reader* r) : ReadEncoder(r) {
+    out_now  = kCodeASCII;
+    count = -1;
+  }
+  bool eof(){ return (count < 0) && reader->eof(); }
+};
+
+class ISO2022JPReadDecoder : public ReadEncoder {
+private:
+  int in_now;
+  SpChar readCh();
+public:
+  ISO2022JPReadDecoder(Reader* r) : ReadEncoder(r) {
+    in_now  = kCodeASCII;
+  }
+};
+
+class JapaneseReadDecoder : public ReadEncoder {
+private:
+  SpValue EncTaker;
+  ReadEncoder* encoder;
+
+  SpChar readCh();
+public:
+  JapaneseReadDecoder(Reader* r) : ReadEncoder(r) {
+    encoder = NULL;
+  }
+  void setEncoder(ReadEncoder* e){
+    encoder = e;
+    EncTaker.setObject(encoder);
+  }
+  virtual void setReader(Reader* r){
+    reader = r;
+    if(encoder != NULL){
+      encoder->setReader(r);
+    }
+  }
+};
+
+class CRLF2LFReadEncoder : public ReadEncoder {
+private:
+  SpChar readCh();
+public:
+  CRLF2LFReadEncoder(Reader* r) : ReadEncoder(r) {}
+};
+
+class CRLF2CRReadEncoder : public ReadEncoder {
+private:
+  SpChar readCh();
+public:
+  CRLF2CRReadEncoder(Reader* r) : ReadEncoder(r) {}
+};
+
+class LF2CRLFReadEncoder : public ReadEncoder {
+private:
+  bool prevLF;
+  SpChar readCh();
+public:
+  LF2CRLFReadEncoder(Reader* r) : ReadEncoder(r) { prevLF = false; }
+};
+
+class CR2CRLFReadEncoder : public ReadEncoder {
+private:
+  bool prevCR;
+  SpChar readCh();
+public:
+  CR2CRLFReadEncoder(Reader* r) : ReadEncoder(r) { prevCR = false; }
+};
+
+class CR2LFReadEncoder : public ReadEncoder {
+private:
+  SpChar readCh();
+public:
+  CR2LFReadEncoder(Reader* r) : ReadEncoder(r) {}
+};
+
+class LF2CRReadEncoder : public ReadEncoder {
+private:
+  SpChar readCh();
+public:
+  LF2CRReadEncoder(Reader* r) : ReadEncoder(r) {}
+};
+
+class Base64ReadEncoder : public ReadEncoder {
+private:
+  int count;
+  SpChar results[4];
+
+  SpChar readCh();
+public:
+  Base64ReadEncoder(Reader* r) : ReadEncoder(r) {
+    count = 0;
+  }
+};
+
+class Base64ReadDecoder : public ReadEncoder {
+private:
+  int count;
+  SpChar results[3];
+
+  SpChar readCh();
+public:
+  Base64ReadDecoder(Reader* r) : ReadEncoder(r) {
+    count = 0;
+  }
+};
+
+class URLReadEncoder : public ReadEncoder {
+private:
+  int count;
+  SpChar results[6];
+
+  SpChar readCh();
+public:
+  URLReadEncoder(Reader* r) : ReadEncoder(r) {
+    count = 0;
+    results[0] = MakeSpChar(CodeJIS, '%');
+    results[3] = MakeSpChar(CodeJIS, '%');
+  }
+  bool eof(){ return (count == 0) && reader->eof(); }
+};
+
+class URLReadDecoder : public ReadEncoder {
+private:
+  SpChar readCh();
+public:
+  URLReadDecoder(Reader* r) : ReadEncoder(r) {}
+};
+
+/*
+ * Writers for SOOPY
+ */
+
+class Writer : public virtual SpObject {
+protected:
+  void write(SpObject& obj);
+  void write(SpList* list);
+  virtual char* getFilename(){ return "a writer"; }
+  virtual void writeCh(unsigned char ch) = 0;
+public:
+  virtual void setWriter(Writer* w){
+    throw SpException("writer don't have a writer (setWriter)");
+  }
+  virtual Writer* getWriter(){
+    throw SpException("writer don't have a writer (getWriter)");
+    return NULL; // not reached
+  }
+  //    virtual void WriteChar(SpChar c) = 0;
+  virtual void WriteChar(SpChar c){
+    writeCh(c);
+  }
+  virtual bool is_open() = 0;
+  virtual void close(){}
+  virtual void flush(){}
+  SpValue& Write(SpValue& val);
+  SpValue& WriteLine(SpValue& val);
+  SpValue& WriteLineS(SpValue& list);
+  SpValue& Terpri();
+  virtual SpValue& WriteByte(SpInt n, unsigned char* buf){
+    throw SpException("writer does not have a function 'WriteByte'");
+    return NilObject;
+  }
+
+  Writer& operator<<(const char* str);
+  Writer& operator<<(const SpInt i);
+  Writer& operator<<(const SpReal r);
+  void writeTextTronCode(SpChar c);
+
+  bool isWriter(){ return true; }
+  SpValue& toString();
+  const char* typeString(){ return "writer"; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  static void init();
+
+  // primitives
+  static SpValue& prim_close(SpValue& fout);
+  static SpValue& prim_closed(SpValue& fout);
+  static SpValue& prim_writeChar(SpValue& fout, SpValue& ch);
+  static SpValue& prim_write(SpValue& fout, SpValue& val);
+  static SpValue& prim_writeLine(SpValue& fout, SpValue& val);
+  static SpValue& prim_writeLineS(SpValue& fout, SpValue& val);
+  static SpValue& prim_flush(SpValue& fout);
+  static SpValue& prim_terpri(SpValue& fout);
+  static SpValue& prim_writebyte(SpValue& fout, SpValue& n, SpValue& byte_vector);
+
+  friend class WriteEncoder;
+};
+
+class StreamWriter : public Writer {
+protected:
+  ostream* stream;
+public:
+  StreamWriter(ostream* s) : stream(s) {}
+
+  void setStream(ostream* s){ stream = s; }
+  ostream* getStream(){ return stream; }
+  bool is_open(){ return true; };
+  void close(){}
+  //    void WriteChar(SpChar ch);
+  void writeCh(unsigned char ch);
+  //void writeCh(SpChar ch);
+  SpValue& WriteByte(SpInt n, unsigned char* buf);
+};
+
+class FileStreamWriter : public StreamWriter {
+private:
+  char* filename;
+  char* getFilename(){ return filename; }
+public:
+  FileStreamWriter(ofstream* s, char* n)
+       : StreamWriter(s),
+         filename(n)
+    {}
+  ~FileStreamWriter(){
+    if(is_open()){
+      close();
+    }
+  }
+
+  bool is_open(){ return ((ofstream*)stream)->is_open(); }
+  void close(){ ((ofstream*)stream)->close(); }
+  void flush(){ ((ofstream*)stream)->flush(); }
+};
+
+class WriteEncoder : public Writer {
+protected:
+  Writer* writer;
+  void writeCh(unsigned char ch){ writer->writeCh(ch); }
+  char* getFilename(){ return writer->getFilename(); }
+public:
+  WriteEncoder(Writer* w) : writer(w) { writer->links++; }
+  ~WriteEncoder(){ writer->links--; }
+
+  void WriteChar(SpChar ch){ writer->WriteChar(ch); }
+  SpValue& WriteByte(SpInt n, unsigned char* buf){ return writer->WriteByte(n, buf); }
+  virtual void setWriter(Writer* w){
+    writer = w;
+  }
+  virtual Writer* getWriter(){
+    return writer;
+  }
+  bool is_open(){ return writer->is_open(); }
+  void close(){ flush(); writer->close(); }
+  void flush(){ writer->flush(); }
+
+  WriteEncoder& operator<<(const char* str){
+    *writer << str;
+    return *this;
+  }
+  WriteEncoder& operator<<(const SpInt i){
+    *writer << i;
+    return *this;
+  }
+  WriteEncoder& operator<<(const SpReal r){
+    *writer << r;
+    return *this;
+  }
+  WriteEncoder& operator<<(SpObject& obj){
+    write(obj);
+    return *this;
+  }
+  WriteEncoder& operator<<(SpValue& v);
+};
+
+class RawWriteEncoder : public WriteEncoder {
+public:
+  RawWriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+class SjisWriteEncoder : public WriteEncoder {
+private:
+  void WriteChar(SpChar c);
+public:
+  SjisWriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+class SjisWriteDecoder : public WriteEncoder {
+private:
+  int count;
+  SpChar ch1;
+  void WriteChar(SpChar c);
+public:
+  SjisWriteDecoder(Writer* w) : WriteEncoder(w) { count=0; }
+};
+
+class EucJPWriteEncoder : public WriteEncoder {
+private:
+  void WriteChar(SpChar c);
+public:
+  EucJPWriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+class EucJPWriteDecoder : public WriteEncoder {
+private:
+  int count;
+  SpChar ch1;
+  void WriteChar(SpChar c);
+public:
+  EucJPWriteDecoder(Writer* w) : WriteEncoder(w) { count=0; }
+};
+
+class ISO2022JPWriteEncoder : public WriteEncoder {
+private:
+  int out_now;
+
+  void WriteChar(SpChar c);
+public:
+  ISO2022JPWriteEncoder(Writer* w) : WriteEncoder(w) {
+    out_now = kCodeASCII;
+  }
+};
+
+class ISO2022JPWriteDecoder : public WriteEncoder {
+private:
+  int in_now;
+  int count;
+  SpChar ch1, ch2;
+  void WriteChar(SpChar c);
+public:
+  ISO2022JPWriteDecoder(Writer* w) : WriteEncoder(w) {
+    in_now = kCodeASCII;
+    count = 0;
+  }
+};
+
+class CRLF2LFWriteEncoder : public WriteEncoder {
+private:
+  bool prevCR;
+  void WriteChar(SpChar c);
+public:
+  CRLF2LFWriteEncoder(Writer* w) : WriteEncoder(w) { prevCR = false; }
+};
+
+class CRLF2CRWriteEncoder : public WriteEncoder {
+private:
+  bool prevCR;
+  void WriteChar(SpChar c);
+public:
+  CRLF2CRWriteEncoder(Writer* w) : WriteEncoder(w) { prevCR = false; }
+};
+
+class LF2CRLFWriteEncoder : public WriteEncoder {
+private:
+  void WriteChar(SpChar c);
+public:
+  LF2CRLFWriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+class CR2CRLFWriteEncoder : public WriteEncoder {
+private:
+  void WriteChar(SpChar c);
+public:
+  CR2CRLFWriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+class CR2LFWriteEncoder : public WriteEncoder {
+private:
+  void WriteChar(SpChar c);
+public:
+  CR2LFWriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+class LF2CRWriteEncoder : public WriteEncoder {
+private:
+  void WriteChar(SpChar c);
+public:
+  LF2CRWriteEncoder(Writer* w) : WriteEncoder(w) {}
+};
+
+class Base64WriteEncoder : public WriteEncoder {
+private:
+  int src, count;
+
+  //void writeCh(unsigned char ch);
+public:
+  Base64WriteEncoder(Writer* w) : WriteEncoder(w) {
+    count = 0;
+  }
+  void WriteChar(SpChar ch);
+  void flush();
+};
+
+class Base64WriteDecoder : public WriteEncoder {
+private:
+  int src, count;
+  bool eof;
+
+  //void writeCh(unsigned char ch);
+public:
+  Base64WriteDecoder(Writer* w) : WriteEncoder(w) {
+    count = 0;
+    eof = false;
+  }
+  void WriteChar(SpChar ch);
+  void flush();
+};
+
+class URLWriteEncoder : public WriteEncoder {
+private:
+  //void writeCh(unsigned char ch);
+public:
+  URLWriteEncoder(Writer* w) : WriteEncoder(w) {}
+  void WriteChar(SpChar ch);
+};
+
+class URLWriteDecoder : public WriteEncoder {
+private:
+  int count;
+  unsigned char src;
+
+  //void writeCh(unsigned char ch);
+public:
+  URLWriteDecoder(Writer* w) : WriteEncoder(w) {
+    count = 0;
+  }
+  void WriteChar(SpChar ch);
+};
+
+class IO : public Reader, public Writer {
+public:
+  SpValue& toString() = 0;
+  const char* typeString() = 0;
+  SpValue& onMessage(SpValue& rec, SpValue& msg) = 0;
+};
+
+/*
+ * Soopy String Class
+ */
+
+typedef vector<SpChar> SpCharVector;
+
+class SpString : public SpObject {
+protected:
+  SpCharVector str;
+
+  void append(const char* s, ReadEncoder& reader = *spin);
+public:
+  SpString(){};
+  //SpString(const char* s){ append(s); }
+  SpString(const char* s, ReadEncoder& enc=*spin){ append(s, enc); }
+  SpString(SpCharVector& vec){ str = vec; }
+  SpString(SpString& s2){ str = s2.str; }
+  ~SpString();
+
+  SpValue& toString();
+  void clear(){ str.clear(); }
+  SpCharVector::iterator begin(){ return str.begin(); }
+  SpCharVector::iterator end(){ return str.end(); }
+  //SpCharVector::iterator find(SpString* s);
+  const char* toCStringWithEncoder(WriteEncoder& writer=*spout);
+  const char* toCString(WriteEncoder& writer=*spout){
+    return toCStringWithEncoder(writer);
+  }
+  const char* typeString(){ return "string"; }
+  bool isString(){ return true; }
+  int length(){ return str.size(); }
+  SpType getType(){ return TypeString; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  SpValue& plus(SpValue& e1, SpValue& e2);
+  bool match(SpValue& self, SpValue& val, SpNameSpace* ns);
+  SpValue& eq(SpValue& e1, SpValue& e2);
+  SpValue& gt(SpValue& e1, SpValue& e2);
+  SpValue& lt(SpValue& e1, SpValue& e2);
+  SpTuple* split_path_file();
+  bool match_glob(SpString* glob);
+  SpValue& split(SpChar c);
+
+  void addSpChar(SpChar c){
+    str.push_back(c);
+  }
+
+  void insertSpChar(SpChar c){
+    str.insert(str.begin(), c);
+  }
+
+  SpString& operator=(const char* s)
+    {
+      str.clear();
+      append(s);
+      return *this;
+    }
+
+  SpString& operator+=(const char* s)
+    {
+      append(s);
+      return *this;
+    }
+  SpString& operator+=(SpValue& s)
+    {
+      append(s.toCString());
+      return *this;
+    }
+  SpString& operator+=(SpString& s);
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+  SpChar operator[](unsigned int index){ return str[index]; }
+
+  static void init();
+  // primitives
+  static SpValue& prim_nth(SpValue& self, SpValue& index);
+  static SpValue& prim_sub(SpValue& self, SpValue& from, SpValue& len);
+  static SpValue& prim_split(SpValue& self, SpValue& ch);
+  static SpValue& prim_split1(SpValue& self, SpValue& ch);
+  static SpValue& prim_tr(SpValue& self, SpValue& ch1, SpValue& ch2);
+  static SpValue& prim_reader(SpValue& self);
+  static SpValue& prim_upper(SpValue& self);
+  static SpValue& prim_lower(SpValue& self);
+  static SpValue& prim_replace(SpValue& self, SpValue& s1, SpValue& s2);
+  static SpValue& prim_replace1(SpValue& self, SpValue& s1, SpValue& s2);
+  static SpValue& prim_toInt(SpValue& self);
+  static SpValue& prim_find(SpValue& self, SpValue& s, SpValue& from);
+  static SpValue& prim_format(SpValue& self);
+
+  friend class Writer;
+  friend class SpStringCmp;
+};
+
+class SpStringCmp {
+public:
+  bool operator()(SpString* s1, SpString* s2) const {
+    return s1->str < s2->str;
+  }
+};
+
+class StringReader : public Reader {
+private:
+  SpCharVector::iterator it;
+  SpCharVector::iterator end;
+  SpValue str;
+public:
+  StringReader(SpString* s){
+    str.setNewObject(s);
+    it = s->begin();
+    end = s->end();
+  }
+
+  bool eof(){
+    return !(it < end);
+  }
+  bool is_open(){ return true; }
+  SpChar readCh()
+    {
+      if(eof()){
+        return (SpChar)NULL;
+      }
+      SpChar c = *it;
+      it++;
+      return c;
+    }
+  /*
+    void unreadCh(SpChar c){
+        it--;
+    }
+   */
+};
+
+/*
+ * Soopy Tuple Class
+ */
+
+typedef vector<SpValue> SpValueVector;
+
+class SpTuple : public SpObject {
+private:
+  SpValueVector vec;
+public:
+  SpTuple(SpValueVector& v) : vec(v) {}
+  SpTuple(SpValue& v){ append(v); }
+  ~SpTuple();
+  static void init();
+  bool canEval(){ return true; }
+  SpValue& eval();
+  SpValue& toString();
+  const char* typeString(){ return "tuple"; }
+  bool isTuple(){ return true; }
+  SpType getType(){ return TypeTuple; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  bool match(SpValue& self, SpValue& val, SpNameSpace* ns);
+
+  SpInt length(){ return vec.size(); }
+  SpValueVector::iterator begin(){ return vec.begin(); }
+  SpValueVector::iterator end(){ return vec.end(); }
+  SpValueVector::reverse_iterator rbegin(){ return vec.rbegin(); }
+  SpValueVector::reverse_iterator rend(){ return vec.rend(); }
+  void append(SpValue& val){ vec.push_back(val); }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+  SpValue& operator[](unsigned int index){ return vec[index]; }
+
+  // primitives
+  static SpValue& get_length(SpValue& self);
+  static SpValue& first(SpValue& self);
+  static SpValue& second(SpValue& self);
+  static SpValue& third(SpValue& self);
+  static SpValue& fourth(SpValue& self);
+  static SpValue& fifth(SpValue& self);
+  static SpValue& nth(SpValue& self, SpValue& index);
+
+  friend int yyparse();
+  friend class SpClosureN;
+  friend class SpConstructor;
+};
+
+/*
+ * Soopy List Class
+ */
+
+class SpList : public SpObject {
+protected:
+  virtual SpList* next() = 0;
+  static SpValue& sub_foldr(SpFunc* f, SpValue& v1, SpList* list);
+  SpList* nth(int i);
+
+public:
+  static void init();
+  virtual SpValue& value() = 0;
+  virtual SpValue& nextList();
+  virtual int length(){ throw SpException("can't calc length"); return 0; }
+  bool isList(){ return true; }
+  SpValue& toString();
+  const char* typeString(){ return "list"; }
+  SpType getType(){ return TypeList; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  bool match(SpValue& self, SpValue& val, SpNameSpace* ns);
+  SpValue& eq(SpValue& e1, SpValue& e2);
+
+  // primitives
+  static SpValue& prim_head(SpValue& list);
+  static SpValue& prim_tail(SpValue& list);
+  static SpValue& prim_nth(SpValue& self, SpValue& index);
+  static SpValue& prim_each(SpValue& self, SpValue& func);
+  static SpValue& prim_map(SpValue& self, SpValue& func);
+  static SpValue& prim_foldl(SpValue& self, SpValue& func);
+  static SpValue& prim_foldr(SpValue& self, SpValue& func);
+  static SpValue& prim_member(SpValue& self, SpValue& value);
+  static SpValue& prim_sort(SpValue& self);
+  static SpValue& prim_filter(SpValue& self, SpValue& func);
+  static SpValue& prim_length(SpValue& self);
+
+  friend class SpContainer;
+  friend class Writer;
+  friend class SpAssignList;
+  friend class SpListCompre;
+  friend class SpAppendedList;
+  friend class SpListCompreDiag;
+};
+
+class SpCons : public SpList {
+private:
+  SpValue car;
+  SpValue cdr;
+
+  SpList* next()
+    {
+      if(cdr.isNil()){
+        return NULL;
+      }
+      SpObject* obj = cdr.getObject();
+      if(obj != NULL){
+        return dynamic_cast<SpList*>(obj);
+      }
+      return NULL;
+    }
+public:
+  SpCons(SpValue& head, SpValue& tail = NilObject){
+    car = head;
+    cdr = tail;
+  }
+  ~SpCons();
+
+  SpValue& value(){ return car; }
+  SpValue& nextList(){ return cdr; }
+  void append(SpValue& val);
+  void setNext(SpValue& next){ cdr = next; } // next: SpList
+  int length();
+  bool isCons(){ return true; }
+  SpCons& operator+=(SpValue& val){ append(val); return *this; }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+
+  friend class Reader;
+  //friend class ReadEncoder;
+  friend class SpList;
+  friend class SpDir;
+};
+
+class SpRange : public SpList {
+private:
+  int start, end, step;
+  bool infinity;
+
+  SpList* next();
+public:
+  SpRange(int s, int e, int st = 1, bool p = false){
+    start = s;
+    end = e;
+    step = st;
+    infinity = p;
+  }
+  ~SpRange();
+  SpValue& value();
+  SpValue& toString();
+  int length();
+};
+
+class SpMakeRange : public SpObject {
+private:
+  SpValue vstart;
+  SpValue vend;
+  SpValue vstep;
+  bool infinity;
+  bool hasStep;
+
+  const char* typeString(){ return "*range maker*"; }
+  SpValue& toString();
+
+public:
+  SpMakeRange(SpValue& s, SpValue& e, SpValue& st, bool p = false)
+       : vstart(s), vend(e), vstep(st), infinity(p)
+    {
+      hasStep = true;
+    }
+  SpMakeRange(SpValue& s, SpValue& e, bool p = false)
+       : vstart(s), vend(e), infinity(p)
+    {
+      hasStep = false;
+    }
+
+  bool canEval(){ return true; }
+  SpValue& eval();
+};
+
+// class SpAppendedList
+//   first @ second
+class SpAppendedList : public SpList {
+private:
+  SpValue first;
+  SpValue second;
+  SpValue environ;   // SpNameSpace
+
+  SpList* next();
+
+public:
+  SpAppendedList(SpValue& f, SpValue& s, SpValue& env) : first(f), second(s), environ(env) {}
+
+  SpValue& value();
+};
+
+//
+// list comprehension
+//   ex. [x | x <- [1..10], x % 2 != 0]
+//
+
+class SpListCreator : public SpObject {
+private:
+  SpValue symbol;
+  SpValue expr;
+  SpValue list;
+
+public:
+  SpListCreator(SpValue& sym, SpValue& e){
+    symbol = sym;
+    expr   = e;
+  }
+
+  const char* typeString(){ return "*list creator*"; }
+  SpValue& toString();
+
+  friend class SpListCompreBase;
+  friend class SpListCompre;
+  friend class SpListCompreDiag;
+};
+
+class SpListCompreBase : public SpList {
+protected:
+  SpValue expr;
+  SpValue creators;
+  SpValue filters;
+  SpValue environ;   // SpNameSpace
+  SpValue current_value;
+
+  SpListCompreBase(SpValue& cur_val, SpValue& e, SpValue& c, SpValue& f, SpValue& env){
+    expr     = e;
+    creators = c;
+    filters  = f;
+    environ  = env;
+    // set current_value
+    current_value = cur_val;
+  }
+
+public:
+  SpValue& value(){
+    return current_value;
+  }
+};
+
+class SpListCompre : public SpListCompreBase {
+private:
+  SpValueVector cur_creators;
+
+  SpList* next();
+
+  static void copy_tuple_to_valVec(SpValueVector* dst, SpValue& src);
+  static void copy_valVec_to_valVec(SpValueVector* dst, SpValueVector* src);
+  static bool calc_next_param(SpValue& c, SpValueVector* v);
+  static bool calc_value(SpValue& result, SpValue& e, SpValue& f, SpValueVector* v, SpValue& env);
+  static SpListCompre* calc_next_list(SpValue& e, SpValue& c, SpValue& f, SpValue& env, SpValueVector* v=NULL);
+
+  SpListCompre(SpValue& cur_val, SpValue& e, SpValue& c, SpValue& f, SpValueVector* v, SpValue& env);
+
+public:
+  static SpListCompre* Create(SpValue& e, SpValue& c, SpValue& f);
+
+  //  int length();
+
+  friend class SpListCompreCreator;
+};
+
+// class SpListCompreCreator
+class SpListCompreCreator : public SpObject {
+private:
+  SpValue expr;
+  SpValue creators;
+  SpValue filters;
+
+  SpValue& toString();
+  const char* typeString(){ return "*list comprehension creator*"; }
+
+public:
+  SpListCompreCreator(SpValue& e, SpValue& c, SpValue& f){
+    expr     = e;
+    creators = c;
+    filters  = f;
+  }
+
+  bool canEval(){ return true; }
+  SpValue& eval();
+};
+
+//
+// list comprehension (diagonalising)
+//   ex. [(x, y) // x <- [1..], y <- [1..]]
+//
+typedef std::vector<int> IntVector;
+
+class SpListCompreDiag : public SpListCompreBase {
+private:
+  int  max;
+  int  depth;
+  int* dim;
+  //  int  len;
+  IntVector lengths;
+  IntVector rvalue;   // x1 + x2 + .. + xN = rvalue
+  IntVector base_pos;
+  IntVector move_pos;
+  int  index;
+
+  SpList* next();
+
+  static bool dec_idx(int  max,
+                      int& idx,
+                      IntVector& rval,
+                      IntVector& base,
+                      IntVector& move,
+                      int depth,
+                      int* dimension);
+  static bool calc_value(SpValue& result, SpValue& e, SpValue& c, SpValue& f, SpValue& env, int* dimension);
+  static bool calc_next_param(IntVector& lengths, int max, int& idx, IntVector& rval, IntVector& base, IntVector& move, int depth, int* dimension);
+  static bool next_rval(int  max, int& idx, IntVector& rval, IntVector& base, IntVector& move, int depth, int* dimension);
+  static SpListCompreDiag* calc_next_list(IntVector& lengths, SpValue& e, SpValue& c, SpValue& f, SpValue& env, int max, int& idx, IntVector& rval, IntVector& base, IntVector& move, int depth, int* dimension=NULL);
+
+  static void clearIntVector(IntVector& dst, int len);
+  void copyIntVector(IntVector& dst, IntVector& src);
+  void calcLength();
+
+  SpListCompreDiag(SpValue& cur_val, SpValue& e, SpValue& c, SpValue& f, SpValue& env, int mx, int idx, IntVector& rval, IntVector& base, IntVector& move, int size, int* p)
+       : SpListCompreBase(cur_val, e, c, f,env)
+    {
+      max      = mx;
+      copyIntVector(rvalue, rval);
+      copyIntVector(base_pos, base);
+      copyIntVector(move_pos, move);
+      index = idx;
+      depth    = size;
+      dim      = p;
+      calcLength();
+    }
+
+  ~SpListCompreDiag(){
+    if(dim != NULL){
+      delete[] dim;
+    }
+  }
+
+public:
+  static SpListCompreDiag* Create(SpValue& e, SpValue& c, SpValue& f);
+
+  //  int length(){ return len; }
+
+  friend class SpListCompreDiagCreator;
+};
+
+// class SpListCompreDiagCreator
+class SpListCompreDiagCreator : public SpObject {
+private:
+  SpValue expr;
+  SpValue creators;
+  SpValue filters;
+
+  SpValue& toString();
+  const char* typeString(){ return "*list comprehension creator*"; }
+
+public:
+  SpListCompreDiagCreator(SpValue& e, SpValue& c, SpValue& f){
+    expr     = e;
+    creators = c;
+    filters  = f;
+  }
+
+  bool canEval(){ return true; }
+  SpValue& eval();
+};
+
+/*
+ * Soopy Symbol Object
+ */
+
+class SpSymbol : public SpString {
+public:
+  //SpSymbol(const char* s) : SpString(s) {}
+  SpSymbol(const char* s){
+    //        appendWithEncoder(s);
+    append(s);
+  }
+  SpSymbol(SpCharVector& vec) : SpString(vec) {}
+  SpSymbol(SpString& s) : SpString(s) {}
+  ~SpSymbol(){
+#ifdef TEST
+    cout << ":destroy SpSymbol" << endl;
+#endif
+  }
+  static void init();
+  bool canEval(){ return true; }
+  SpValue& eval();
+  const char* typeString(){ return "symbol"; }
+  SpType getType(){ return TypeSymbol; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  SpValue& toString();
+  bool match(SpValue& self, SpValue& val, SpNameSpace* ns);
+  SpValue& eq(SpValue& e1, SpValue& e2);
+
+  bool isString(){ return false; }
+  bool isSymbol(){ return true; }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+};
+
+/*
+ * Soopy NameSpace Class
+ *  & KeyClass NSKey : abstract class
+                   NSVar
+                   NSConst
+                   NSProperty
+                   NSFunc
+                   NSDataType
+ *  & ValueClass SpValue
+ */
+
+class NSKey : public SpObject {
+public:
+  SpValue val;
+  bool isPublic;
+  virtual bool isNSConst(){ return true; }
+  virtual bool isNSProperty(){ return false; }
+  virtual bool isNSPrimProperty(){ return false; }
+  virtual bool isNSFunc(){ return false; }
+  virtual bool isNSDataType(){ return false; }
+  bool isNSKey(){ return true; }
+
+  NSKey(SpValue& v, bool p=true): val(v), isPublic(p) {}
+  virtual SpValue& toString(){ return val.toString(); }
+  const char* typeString(){ return "ns-key"; }
+
+  bool operator<(SpObject& k){
+    NSKey& key = dynamic_cast<NSKey&>(k);
+    return val < key.val;
+  }
+  bool operator!=(NSKey& key) { return val != key.val; }
+};
+
+class NSVar : public NSKey {
+public:
+  NSVar(SpValue& v, bool p=true) : NSKey(v,p) {}
+  ~NSVar() {}
+  SpValue& toString();
+  bool isNSConst(){ return false; }
+};
+
+class NSConst : public NSKey {
+private:
+  SpType typ;
+public:
+  NSConst(SpValue& v, bool p=true, SpType t=TypeNil)
+       : NSKey(v,p), typ(t) {}
+  ~NSConst() {}
+  SpValue& toString();
+};
+
+class NSProperty : public NSKey {
+private:
+  SpValue getter, setter;
+public:
+  NSProperty(SpValue& key, SpValue& r, SpValue& w, bool p=true)
+       : NSKey(key,p), getter(r), setter(w) {}
+  ~NSProperty() {}
+  SpValue& toString();
+  bool isNSProperty(){ return true; }
+
+  friend class SpNameSpace;
+};
+
+class NSPrimProperty : public NSKey {
+private:
+  SpValue getter, setter; // SpPrim
+public:
+  NSPrimProperty(SpValue& key, SpValue& r, SpValue& w, bool p=true)
+       : NSKey(key,p), getter(r), setter(w) {}
+  ~NSPrimProperty() {}
+  SpValue& toString();
+  bool isNSPrimProperty(){ return true; }
+
+  friend class SpNameSpace;
+};
+
+class NSFunc : public NSKey {
+public:
+  NSFunc(SpValue& v, bool p=true) : NSKey(v,p) {}
+  ~NSFunc() {}
+  SpValue& toString() { return val.toString();}
+  bool isNSFunc(){ return true; }
+};
+
+class NSDataType : public NSKey {
+public:
+  NSDataType(SpValue& symbol, bool p=true) : NSKey(symbol, p) {}
+  SpValue& toString() { return val.toString();}
+  bool isNSDataType(){ return true; }
+};
+
+class VVCmp {
+public:
+  //    bool operator()(SpValue key1, SpValue key2) const;
+  bool operator()(const SpValue& key1, const SpValue& key2) const;
+};
+/*
+class NSKeyCmp {
+public:
+    bool operator()(SpValue key1, SpValue key2);
+};
+ */
+//typedef map<NSKey*, SpValue, NSKeyCmp> NSMap;
+//typedef pair<NSKey*, SpValue> NSPair;
+
+typedef map<SpValue, SpValue, VVCmp> NSMap;
+//typedef map<SpValue, SpValue, NSKeyCmp> NSMap;
+typedef pair<SpValue, SpValue> NSPair;
+
+// for make SpNameSpace in yyparse
+class NSPairAdaptor : public SpObject {
+public:
+  NSPair* pair;
+
+  NSPairAdaptor(NSPair* p){ pair = p; }
+  ~NSPairAdaptor(){ delete pair; }
+  SpValue& toString(){ return NilObject; }
+  const char* typeString(){ return "pair-adaptor"; }
+};
+
+// for make SpNameSpace in yyparse
+class NSMapAdaptor : public SpObject {
+public:
+  NSMap* map;
+
+  NSMapAdaptor(NSMap* m){ map = m; }
+  ~NSMapAdaptor(){ delete map; }
+  SpValue& toString(){ return NilObject; }
+  const char* typeString(){ return "map-adaptor"; }
+};
+
+// for SpNameSpace
+class SpPatternWColon : public SpObject {
+private:
+  SpValue head, tail;
+public:
+  SpPatternWColon(SpValue& v1, SpValue& v2)
+       : head(v1), tail(v2) {}
+  SpValue& toString();
+  const char* typeString(){ return "pattern::"; }
+  bool match(SpValue& self, SpValue& val, SpNameSpace* ns);
+};
+
+// for SpNameSpace
+class SpPatternAt : public SpObject {
+private:
+  SpValue list1, list2;
+public:
+  SpPatternAt(SpValue& v1, SpValue& v2)
+       : list1(v1), list2(v2) {}
+  SpValue& toString();
+  const char* typeString(){ return "pattern@"; }
+  bool match(SpValue& self, SpValue& val, SpNameSpace* ns);
+};
+
+// for SpNameSpace
+class SpPatternCon : public SpObject {
+private:
+  SpValue symbol; // symbol
+  SpValue tuple;  // tuple
+public:
+  SpPatternCon(SpValue& sym, SpValue& t)
+       : symbol(sym), tuple(t) {}
+  SpValue& toString();
+  const char* typeString(){ return "constructor pattern"; }
+  bool match(SpValue& self, SpValue& val, SpNameSpace* ns);
+};
+
+///////////////////////////////////////
+////////////// NameSpace //////////////
+///////////////////////////////////////
+
+class SpNameSpace : public SpObject {
+private:
+  NSMap aMap;
+  SpValue parentNS;
+  bool reachable(SpNameSpace* ns);
+  void intern(SpValue& key, SpValue& val);
+  void setParent(SpValue& p){
+    parentNS = p;
+  }
+  SpValue& getValue(NSKey* key,
+                    SpNameSpace* searcher,
+                    SpNameSpace* cur_ns=NULL,
+                    bool search_parent=true);
+public:
+  SpNameSpace(NSMap& m, SpValue& p=NilObject);
+  SpNameSpace(SpNameSpace* ns1, SpNameSpace* ns2, SpValue& p=NilObject);
+  SpNameSpace(SpValue& p=NilObject);
+  ~SpNameSpace();
+
+  NSMap& getMap(){ return aMap; }
+  static void init();
+  SpValue& toString();
+  const char* typeString(){ return "namespace"; }
+  bool isNameSpace(){ return true; }
+  SpType getType(){ return TypeNameSpace; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  SpValue& plus(SpValue& e1, SpValue& e2);
+
+  void clear(){ aMap.clear(); }
+  SpInt size(){ return aMap.size(); }
+  NSMap::iterator begin(){ return aMap.begin(); }
+  NSMap::iterator end(){ return aMap.end(); }
+
+  SpValue& lookup(SpValue& v, SpNameSpace* searcher=NULL);
+  SpValue& lookup1(SpValue& v, SpNameSpace* searcher=NULL);
+  void setValue(SpValue& key, SpValue& val, SpNameSpace* searcher, SpNameSpace* cur_ns=NULL);
+  void internVar(SpValue& v1, SpValue& v2, bool p=true){
+    NSVar* var = new NSVar(v1,p);
+    SpValue key(var);
+    intern(key, v2);
+  }
+  void internConst(SpValue& v1, SpValue& v2, bool p=true, SpType t=TypeNil){
+    NSConst* con = new NSConst(v1, p, t);
+    SpValue key(con);
+    intern(key, v2);
+  }
+  void internProperty(SpValue& v1, SpValue& v2, SpValue& r, SpValue& w, bool p=true){
+    NSProperty* pro = new NSProperty(v1, r, w, p);
+    SpValue key(pro);
+    intern(key, v2);
+  }
+  void internPrimProperty(SpValue& v1, SpValue& v2, SpValue& r, SpValue& w, bool p=true){
+    NSPrimProperty* pro = new NSPrimProperty(v1, r, w, p);
+    SpValue key(pro);
+    intern(key, v2);
+  }
+  void internFunc(SpValue& v1, SpValue& v2, bool p=true){
+    NSFunc* func = new NSFunc(v1);
+    SpValue key(func);
+    intern(key, v2);
+  }
+  void internDataType(SpValue& v1, SpValue& v2, bool p=true){
+    NSDataType* dt = new NSDataType(v1);
+    SpValue key(dt);
+    intern(key, v2);
+  }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+
+  SpNameSpace& operator+=(SpNameSpace& ns);
+  SpNameSpace& operator+=(NSPair& p)
+    {
+      // insert data
+      setValue(p.first, p.second, this);
+      return *this;
+    }
+
+
+  // primitives
+  static SpValue& rename(SpValue& self, SpValue& renames);
+  static SpValue& make_func(SpValue& self);
+  static SpValue& prim_append(SpValue& self, SpValue& key, SpValue& value);
+  static SpValue& prim_keys(SpValue& self);
+  static SpValue& prim_delete(SpValue& self, SpValue& key);
+  static SpValue& prim_lookup(SpValue& self, SpValue& key);
+
+#ifdef USE_CLX
+  friend class SpContainer;
+#endif
+#ifdef AQUA
+  friend class SpContainer;
+#endif
+  friend class MakeNameSpace;
+  friend class SpPatternCon;
+  friend class SpThread;
+  friend int yyparse();
+};
+
+class MakeNameSpace : public SpObject {
+private:
+  SpValue ns; // SpNameSpace
+public:
+  MakeNameSpace(SpValue& names) : ns(names) {}
+  bool canEval(){ return true; }
+  SpValue& eval();
+  SpValue& toString();
+  const char* typeString(){ return "make namespace"; }
+};
+
+#ifdef USE_PTHREAD
+
+inline SpValue& getCurrentNS()
+{
+  ThreadContext* context;
+  context = (ThreadContext*)pthread_getspecific(pthread_key);
+  return context->Frame.back();
+}
+inline SpValue& getPrevNS()
+{
+  ThreadContext* context;
+  context = (ThreadContext*)pthread_getspecific(pthread_key);
+  int size = context->Frame.size();
+  if(size >= 2){
+    return context->Frame[size-2];
+  }
+  return NilObject;
+}
+inline void pushCurrentNS(SpValue& ns)
+{
+  ThreadContext* context;
+  context = (ThreadContext*)pthread_getspecific(pthread_key);
+  context->Frame.push_back(ns);
+}
+inline void popCurrentNS()
+{
+  ThreadContext* context;
+  context = (ThreadContext*)pthread_getspecific(pthread_key);
+  context->Frame.pop_back();
+}
+
+#endif /* USE_PTHREAD */
+
+#ifdef USE_W32THREAD
+
+#ifndef THREAD
+#define THREAD
+#endif
+
+inline SpValue& getCurrentNS()
+{
+  ThreadContext* context;
+  context = (ThreadContext*)TlsGetValue(tls_key);
+  if(context == 0){
+    throw SpException("can't get tls value");
+  }
+  return context->Frame.back();
+}
+inline SpValue& getPrevNS()
+{
+  ThreadContext* context;
+  context = (ThreadContext*)TlsGetValue(tls_key);
+  if(context == 0){
+    throw SpException("can't get tls value");
+  }
+  int size = context->Frame.size();
+  if(size >= 2){
+    return context->Frame[size-2];
+  }
+  return NilObject;
+}
+inline void pushCurrentNS(SpValue& ns)
+{
+  ThreadContext* context;
+  context = (ThreadContext*)TlsGetValue(tls_key);
+  if(context == 0){
+    throw SpException("can't get tls value");
+  }
+  context->Frame.push_back(ns);
+}
+inline void popCurrentNS()
+{
+  ThreadContext* context;
+  context = (ThreadContext*)TlsGetValue(tls_key);
+  if(context == 0){
+    throw SpException("can't get tls value");
+  }
+  context->Frame.pop_back();
+}
+
+#endif /* USE_W32THREAD */
+
+
+#ifndef THREAD
+
+extern vector<SpValue> Frame;
+inline SpValue& getCurrentNS()
+{
+  return Frame.back();
+}
+inline SpValue& getPrevNS()
+{
+  int size = Frame.size();
+  if(size >= 2){
+    return Frame[size-2];
+  }
+  return NilObject;
+}
+inline void pushCurrentNS(SpValue& ns)
+{
+  Frame.push_back(ns);
+}
+inline void popCurrentNS()
+{
+  Frame.pop_back();
+}
+
+#endif /* not THREAD */
+
+/*
+ * Soopy Assign Class
+ */
+
+class SpAssign : public SpObject {
+private:
+  SpValue place;
+  SpValue val;
+public:
+  SpAssign(SpValue& p, SpValue& v)
+       : place(p), val(v) {}
+  ~SpAssign();
+
+  bool isAssign(){ return true; }
+  bool canEval(){ return true; }
+  SpValue& eval();
+  SpValue& toString();
+  const char* typeString(){ return "="; }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+
+  friend class SpContainer;
+};
+
+class SpAssignS : public SpObject {
+private:
+  SpValueVector places;
+  SpValue val;
+public:
+  SpAssignS(SpValueVector& p, SpValue& v)
+       : places(p), val(v) {}
+  ~SpAssignS();
+
+  bool canEval(){ return true; }
+  SpValue& eval();
+  SpValue& toString();
+  const char* typeString(){ return "let = "; }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+};
+
+class SpAssignSM : public SpObject {
+private:
+  SpValue place;
+  SpValue val;
+public:
+  SpAssignSM(SpValue& p, SpValue& v)
+       : place(p), val(v) {}
+  ~SpAssignSM();
+
+  bool canEval(){ return true; }
+  SpValue& eval();
+  SpValue& toString();
+  const char* typeString(){ return "obj msg = "; }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+};
+
+class SpAssignList : public SpObject {
+private:
+  SpValueVector places;
+  SpValue val;
+public:
+  SpAssignList(SpValueVector& p, SpValue& v)
+       : places(p), val(v) {}
+  ~SpAssignList();
+
+  bool canEval(){ return true; }
+  SpValue& eval();
+  SpValue& toString();
+  const char* typeString(){ return "let [...] = "; }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+};
+
+class SpAssignHT : public SpObject {
+private:
+  SpValue head;
+  SpValue tail;
+  SpValue val;
+public:
+  SpAssignHT(SpValue& h, SpValue& t, SpValue& v)
+       : head(h), tail(t), val(v) {}
+  ~SpAssignHT();
+
+  bool canEval(){ return true; }
+  SpValue& eval();
+  SpValue& toString();
+  const char* typeString(){ return "let head::tail = "; }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+};
+
+
+/*
+ * SpSendMsg Class
+ */
+
+class SpSendMsg : public SpObject {
+private:
+  SpValue receiver, message;
+public:
+  SpSendMsg(SpValue& r, SpValue& m)
+       : receiver(r), message(m) {}
+  ~SpSendMsg();
+
+  bool canEval(){ return true; }
+  SpValue& eval();
+  SpValue& toString();
+  const char* typeString(){ return "obj msg"; }
+  bool isSendMsg(){ return true; }
+
+  bool operator==(SpObject& obj);
+  bool operator<(SpObject& obj);
+
+  friend class SpAssignSM;
+};
+
+
+/*
+ *
+ * Function class
+ *
+ */
+
+typedef SpValue& (*PRIM0)();
+typedef SpValue& (*PRIM1)(SpValue&);
+typedef SpValue& (*PRIM2)(SpValue&, SpValue&);
+typedef SpValue& (*PRIM3)(SpValue&, SpValue&, SpValue&);
+
+class SpFunc : public SpObject {
+protected:
+  unsigned int argLen;
+public:
+  bool isFunc(){ return true; }
+  virtual SpValue& operator()(SpValue& arg) = 0;
+  SpValue& onMessage(SpValue& rec, SpValue& msg)
+    {
+      return (*this)(msg);
+    }
+  const char* typeString(){ return "function"; }
+
+  friend class SpClosure;
+  friend class SpClosureN;
+};
+
+//
+// Primitive class
+//
+
+class SpPrim0 : public SpFunc {
+  PRIM0 func;
+public:
+  SpPrim0(PRIM0 f) : func(f) { argLen = 0; }
+
+  SpValue& operator()(SpValue& arg);
+  SpValue& toString();
+  const char* typeString(){ return "primitive0"; }
+};
+
+class SpPrim1 : public SpFunc {
+  PRIM1 func;
+public:
+  SpPrim1(PRIM1 f) : func(f) { argLen = 1; }
+
+  SpValue& operator()(SpValue& arg);
+  SpValue& toString();
+  const char* typeString(){ return "primitive1"; }
+};
+
+class SpPrim2 : public SpFunc {
+  PRIM2 func;
+public:
+  SpPrim2(PRIM2 f) : func(f) { argLen = 2; }
+
+  SpValue& operator()(SpValue& arg);
+  SpValue& operator()(SpValue& arg1, SpValue& arg2);
+  SpValue& toString();
+  const char* typeString(){ return "primitive2"; }
+};
+
+class SpPrim3 : public SpFunc {
+  PRIM3 func;
+public:
+  SpPrim3(PRIM3 f) : func(f) { argLen = 3; }
+
+  SpValue& operator()(SpValue& arg);
+  SpValue& operator()(SpValue& arg1, SpValue& arg2);
+  SpValue& operator()(SpValue& arg1, SpValue& arg2, SpValue& arg3);
+  SpValue& toString();
+  const char* typeString(){ return "primitive3"; }
+};
+
+//
+// class SpUsrFunc && class SpArg
+//
+
+class SpArg : public SpObject {
+private:
+  SpValue name; // SpSymbol
+  SpValue typ;  // SpSymbol or NilObject
+public:
+  SpArg(SpValue& n, SpValue& t)
+       : name(n), typ(t) {}
+  SpValue& toString();
+  const char* typeString(){ return "arg"; }
+  SpValue& getVarName(){ return name; }
+  SpValue& getVarType(){ return typ; }
+  bool isArg(){ return true; }
+
+  friend class SpUsrFunc;
+  friend class SpConstructor;
+};
+
+class SpUsrFunc : public SpFunc {
+private:
+  SpValue name;    // SpSymbol
+  SpValue args;    // SpTuple or NilObject
+  SpValue vars;    // SpList or NilObject
+  SpValue requir;  // SpList or NilObject
+  SpValue body;    // SpNameSpace
+  SpValue ensure;  // SpList or NilObject
+  SpValue rescue;  // SpList or NilObject
+
+  void checkRequire();
+  void checkEnsure();
+  bool doRescue();
+public:
+  SpUsrFunc(SpValue& n,
+            SpValue& a,
+            SpValue& v,
+            SpValue& r,
+            SpValue& b,
+            SpValue& e,
+            SpValue& res)
+       : name(n), args(a), vars(v), requir(r), body(b), ensure(e), rescue(res)
+    {
+      if(a.isNil()){
+        argLen = 0;
+      }else{
+        SpTuple* ptr = dynamic_cast<SpTuple*>(a.getObject());
+        argLen = ptr->length();
+      }
+    }
+  static SpUsrFunc* fromNameSpace(SpNameSpace* ns);
+
+  SpValue& doBody();
+
+  SpValue& operator()(SpValue& arg);
+  SpValue& toString();
+  SpValue& getName(){ return name; }
+};
+
+class SpRetry : public SpObject {
+public:
+  SpRetry(){}
+
+  bool canEval(){ return true; }
+  SpValue& eval(){ throw SpRetryException("uncaught retry"); return NilObject; }
+  SpValue& toString();
+  const char* typeString(){ return "retry"; }
+};
+
+//
+// class SpClosure
+//
+
+class SpClosure : public SpFunc {
+private:
+  SpValue func; // SpFunc
+  SpValue ns;   // SpNameSpace
+public:
+  SpClosure(SpValue& f, SpValue& aNS);
+
+  SpValue& operator()(SpValue& a);
+  SpValue& toString();
+  const char* typeString(){ return "closure"; }
+};
+
+class SpClosureP2 : public SpFunc { // for Prim2 only
+private:
+  SpValue func; // Prim2
+  SpValue arg;
+  SpValue ns; // NameSpace
+public:
+  SpClosureP2(SpValue& f, SpValue& a, SpValue& aNS)
+       : func(f), arg(a), ns(aNS) { argLen = 1; }
+
+  SpValue& operator()(SpValue& a);
+  SpValue& toString();
+};
+
+class SpClosureP3_1 : public SpFunc { // for Prim3 only
+private:
+  SpValue func; // Prim3
+  SpValue arg;
+  SpValue ns; // NameSpace
+public:
+  SpClosureP3_1(SpValue& f, SpValue& a, SpValue& aNS)
+       : func(f), arg(a), ns(aNS) { argLen = 1; }
+
+  SpValue& operator()(SpValue& a);
+  SpValue& toString();
+};
+
+class SpClosureP3_2 : public SpFunc { // for Prim3 only
+private:
+  SpValue func; // Prim3
+  SpValue arg1;
+  SpValue arg2;
+  SpValue ns; // NameSpace
+public:
+  SpClosureP3_2(SpValue& f, SpValue& a1, SpValue& a2, SpValue& aNS)
+       : func(f), arg1(a1), arg2(a2), ns(aNS) { argLen = 1; }
+
+  SpValue& operator()(SpValue& a);
+  SpValue& toString();
+};
+
+class SpClosureN : public SpFunc {
+private:
+  SpValue func; // SpFunc
+  SpValue args; // SpTuple
+  SpValue ns;   // NameSpace
+public:
+  SpClosureN(SpValue& f, SpValue& a, SpValue& aNS);
+
+  SpValue& operator()(SpValue& a);
+  SpValue& toString();
+};
+
+typedef map<SpValue, SpValue, VVCmp> VVMap;
+
+class MsgHandler {
+  VVMap aMap;
+  MsgHandler* parent;
+public:
+  MsgHandler(MsgHandler* p=NULL) : parent(p) {}
+  ~MsgHandler();
+  void append(SpValue& message, SpValue& handler);
+  SpValue& operator()(SpValue& rec, SpValue& msg);
+  bool hasMessage(SpValue& message);
+};
+
+/*
+ * Exprs
+ */
+
+class SpExpr : public SpObject {
+public:
+  bool canEval(){ return true; }
+  const char* typeString(){ return "expr"; }
+};
+
+class ExprUMinus : public SpExpr {
+private:
+  SpValue expr;
+public:
+  ExprUMinus(SpValue& e) : expr(e) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+/*
+ * SpQuote class
+ */
+
+class SpQuote : public SpExpr {
+private:
+  SpValue expr;
+public:
+  SpQuote(SpValue& v): expr(v) {}
+  SpValue& eval(){ return expr; }
+  SpValue& toString();
+};
+
+class ExprPlus : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprPlus(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprMinus : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprMinus(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprTimes : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprTimes(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprDiv : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprDiv(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprMod : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprMod(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprNOT : public SpExpr {
+private:
+  SpValue expr;
+public:
+  ExprNOT(SpValue& e1)
+       : expr(e1) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprAND : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprAND(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprOR : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprOR(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprEQ : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprEQ(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprNE : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprNE(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprGT : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprGT(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprGE : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprGE(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprLT : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprLT(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprLE : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprLE(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprWColon : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprWColon(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class ExprAT : public SpExpr {
+private:
+  SpValue expr1, expr2;
+public:
+  ExprAT(SpValue& e1, SpValue& e2)
+       : expr1(e1), expr2(e2) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+/*
+ * If statement
+ */
+
+class SpIf : public SpExpr {
+private:
+  SpValue cond;  // condition
+  SpValue assoc; // NSPairAdaptor Vector(SpTuple)
+public:
+  SpIf(SpValue& c, SpValue& a)
+       : cond(c), assoc(a) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+/*
+ * Loop statement
+ */
+
+class SpLoop: public SpExpr {
+private:
+  SpValue symbol;
+  SpValue from;       // from
+  SpValue step;       // step
+  SpValue body;       // do
+  SpValue while_cond; // while
+  SpValue until_cond; // until
+  SpValue variant;    // variant
+  SpValue invariant;  // invariant
+public:
+  SpLoop(SpValue& sym=NilObject,
+         SpValue& fr=NilObject,
+         SpValue& st=NilObject,
+         SpValue& bd=NilObject,
+         SpValue& wcond=NilObject,
+         SpValue& ucond=NilObject,
+         SpValue& vari=NilObject,
+         SpValue& invari=NilObject)
+       : symbol(sym),
+         from(fr),
+         step(st),
+         body(bd),
+         while_cond(wcond),
+         until_cond(ucond),
+         variant(vari),
+         invariant(invari) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class SpExit : public SpExpr {
+private:
+  SpValue symbol, expr;
+public:
+  SpExit(SpValue& sym = NilObject, SpValue& ex  = NilObject)
+       : symbol(sym), expr(ex) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+class SpNext : public SpExpr {
+private:
+  SpValue symbol, expr;
+public:
+  SpNext(SpValue& sym = NilObject, SpValue& ex  = NilObject)
+       : symbol(sym), expr(ex) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+/*
+ * Array
+ */
+
+typedef vector<unsigned int> uintvec;
+
+class SpBaseArray : public SpObject {
+protected:
+  unsigned int depth;
+  uintvec dimension;
+
+public:
+  SpBaseArray(){} // for TableOfTableView(soopyg)
+  SpBaseArray(uintvec& v);
+
+  const char* typeString(){ return "array"; }
+  bool isArray(){ return true; }
+  SpType getType(){ return TypeArray; }
+  virtual SpValue& getFeatureType() = 0;
+
+  static void init();
+  // primitives
+  static SpValue& getDepth(SpValue& self);
+  static SpValue& getDimension(SpValue& self);
+};
+
+class SpArray : public SpBaseArray {
+public:
+  SpArray(){} // for TableOfTableView(soopyg)
+  SpArray(uintvec& v) : SpBaseArray(v){}
+  virtual SpValue& operator[](SpValue& tuple) = 0;
+  virtual void set(SpValue& tuple, SpValue& value) = 0;
+};
+
+class SpObjectArray : public SpArray {
+private:
+  SpValue typ;       // SpSymbol or NilObject
+  SpValueVector* pvec;
+public:
+  SpObjectArray(SpValue& t, uintvec& v);
+  ~SpObjectArray(){
+    if(pvec != NULL){
+      delete pvec;
+    }
+  }
+  SpValue& toString();
+  SpValue& operator[](SpValue& tuple);
+  void set(SpValue& tuple, SpValue& value);
+  SpValue& getFeatureType(){ return typ; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+};
+
+class SpByteArray : public SpBaseArray {
+private:
+  unsigned char* buf;
+
+public:
+  SpByteArray(uintvec& v);
+  ~SpByteArray(){
+    if(buf != NULL){
+      //            delete buf;
+      free(buf);
+    }
+    buf = NULL;
+  }
+
+  unsigned char* getBuffer(){
+    if(buf == NULL){
+      throw SpException("null buffer (bytearray)");
+    }
+    return buf;
+  }
+  bool isByteArray(){ return true; }
+  SpInt length(){ return (SpInt)dimension[0]; }
+  SpValue& toString();
+  unsigned char& operator[](SpValue& tuple);
+  SpValue& getFeatureType();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+};
+
+class MakeArray : public SpExpr {
+private:
+  SpValue typ;    // SpSymbol or NilObject
+  SpValue vec;    // SpTuple
+public:
+  MakeArray(SpValue& t, SpValue& v): typ(t), vec(v) {}
+  SpValue& eval();
+  SpValue& toString();
+};
+
+
+/*
+ * DataType
+ */
+
+class SpDataType : public SpObject {
+private:
+  SpValue symbol;    // SpSymbol
+  SpValueVector vec; // SpConstructor vector
+public:
+  SpDataType(SpValue& sym, SpValueVector& v)
+       : symbol(sym), vec(v) {}
+  SpValue& toString();
+  const char* typeString(){ return "datatype"; }
+  bool isDataType(){ return true; }
+  void mapping2ns(SpValue& self, SpNameSpace* ns);
+
+  friend int yyparse();
+  friend void CheckType(SpValue& featureType, SpValue& value);
+};
+
+class SpConstructor : public SpFunc {
+private:
+  SpDataType* datatype;
+  SpValue symbol; // SpSymbol
+  SpValue args;   // Nil or SpTuple
+  SpValue ns;     // SpNameSpace
+  void setDataType(SpDataType* dt){ datatype = dt; }
+public:
+  SpConstructor(SpValue& sym, SpValue& a, SpValue& n)
+       : symbol(sym), args(a), ns(n)
+    {
+      if(args.isNil()){
+        argLen = 0;
+      }else{
+        SpTuple* t = args.asTuple();
+        argLen = t->length();
+      }
+    }
+
+  bool isConstructor(){ return true; }
+  SpValue& operator()(SpValue& a);
+  SpValue& toString();
+  const char* typeString(){ return "constructor"; }
+  bool canEval(){ return true; }
+  SpValue& eval();
+
+  friend class SpDataType;
+  friend class SpDType;
+  friend class SpPatternCon;
+  friend int yyparse();
+  friend void CheckType(SpValue& featureType, SpValue& value);
+};
+
+class SpDType : public SpObject {
+private:
+  SpConstructor* con;
+  SpValue& symbol;
+  SpValue ns;
+public:
+  SpDType(SpConstructor* c, SpValue& sym, SpValue& n)
+       : con(c), symbol(sym), ns(n) {}
+  SpValue& toString();
+  const char* typeString(){ return symbol.toCString(); }
+  SpType getType(){ return TypeDType; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  SpValue& eq(SpValue& e1, SpValue& e2);
+  //bool match(SpValue& self, SpValue& val, SpNameSpace* ns);
+  bool isDType(){ return true; }
+
+  friend class SpPatternCon;
+  friend void CheckType(SpValue& featureType, SpValue& value);
+};
+
+
+class SpDir : public SpObject {
+public:
+  SpDir(){};
+  bool isDir(){ return true; }
+  SpValue& toString();
+  const char* typeString(){ return "dir"; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  static void init();
+  // primitives
+  static SpValue& Chdir(SpValue& dir, SpValue& path);
+  static SpValue& Mkdir(SpValue& dir, SpValue& path);
+  static SpValue& Rmdir(SpValue& dir, SpValue& path);
+  static SpValue& List(SpValue& dir, SpValue& path);
+  static SpValue& Pwd(SpValue& dir);
+  static SpValue& prim_glob(SpValue&, SpValue& path);
+};
+
+class SpFile : public SpObject {
+public:
+  SpFile(){};
+  bool isFile(){ return true; }
+  SpValue& toString();
+  const char* typeString(){ return "fileutil"; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  static void init();
+  // primitives
+  static SpValue& prim_exists(SpValue& dir, SpValue& path);
+  static SpValue& prim_delete(SpValue&, SpValue& path);
+  static SpValue& prim_size(SpValue&, SpValue& path);
+  static SpValue& prim_rename(SpValue&, SpValue& from, SpValue& to);
+  static SpValue& prim_atime(SpValue&, SpValue& path);
+  static SpValue& prim_ctime(SpValue&, SpValue& path);
+  static SpValue& prim_mtime(SpValue&, SpValue& path);
+};
+
+#ifdef USE_SOCKET
+
+const int BUFFSIZE = 1024;
+
+#ifndef SOCKET
+#define SOCKET int
+#endif
+
+//class BaseSocket : public Reader, public Writer {
+class BaseSocket : public IO {
+protected:
+  SOCKET sock;
+  int port;
+  bool isOpen;
+public:
+  BaseSocket(int p) : port(p){
+    isOpen = false;
+  }
+  BaseSocket(){
+    isOpen = false;
+  }
+  ~BaseSocket(){
+    if(isOpen){
+      close();
+    }
+  }
+
+  bool is_open(){
+    return isOpen;
+  }
+  void close();  // close socket
+};
+
+class Socket : public BaseSocket {
+private:
+  char* hostname;
+  // for read
+  char buff[2][BUFFSIZE]; // read buffers
+  bool already_read[2]; // buff was already read flag
+  int which_buf;
+  int read_bytes;  // read buff bytes
+  int read_point;
+  bool receive_end;
+  // for write
+  char wbuff[BUFFSIZE]; // write buffer
+  int write_point;
+
+  void next_buf(){
+    already_read[which_buf] = false;
+    which_buf = (which_buf + 1) & 1;
+  }
+  void read_buffer();
+public:
+  Socket(int p, char* hname) : BaseSocket(p), hostname(hname) {
+    which_buf = 0;
+    read_bytes = 0;
+    read_point = 0;
+    receive_end = false;
+    already_read[0] = false;
+    already_read[1] = false;
+    write_point = 0;
+  }
+  Socket(SOCKET s){
+    sock = s;
+    which_buf = 0;
+    read_bytes = 0;
+    read_point = 0;
+    receive_end = false;
+    already_read[0] = false;
+    already_read[1] = false;
+    write_point = 0;
+  }
+  bool isSocket(){ return true; }
+
+  SpChar readCh();
+  /*
+    void unreadCh(SpChar){
+        throw SpException("can't unread socket");
+    }
+   */
+  void writeCh(unsigned char ch);
+  //void WriteChar(SpChar ch);
+  void open();   // open client socket
+  bool eof();
+  void flush();
+
+  void write(char* str);
+  SpValue& receive(SpInt n, unsigned char* buffer);
+  SpValue& send_buffer(SpInt n, unsigned char* buffer);
+
+  SpValue& toString();
+  const char* typeString(){ return "socket"; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+
+  static void init();
+  // primitives
+  static SpValue& prim_getname(SpValue& adr);
+  static SpValue& prim_open(SpValue& adr, SpValue& port);
+  static SpValue& prim_close(SpValue& self);  // close socket
+  static SpValue& prim_eof(SpValue& self);
+  static SpValue& prim_write(SpValue& self, SpValue& str);
+  static SpValue& prim_writeline(SpValue& self, SpValue& str);
+  //    static SpValue& prim_readline(SpValue& self);
+  static SpValue& prim_receive(SpValue& self, SpValue& n, SpValue& byte_vector);
+  static SpValue& prim_send(SpValue& self, SpValue& n, SpValue& byte_vector);
+};
+
+class ServerSocket : public BaseSocket {
+private:
+  struct sockaddr_in sockadd;
+
+public:
+  ServerSocket(int p) : BaseSocket(p) {}
+  bool isServerSocket(){ return true; }
+  SpValue& toString();
+  const char* typeString(){ return "server_socket"; }
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+
+  void open();
+  SpValue& accept();
+
+  SpChar readCh(){
+    throw SpException("illegal call of ServerSocket::readCh()");
+    return 0;
+  }
+  /*
+    void unreadCh(SpChar){
+        throw SpException("can't unread server socket");
+    }
+   */
+  void writeCh(unsigned char ch){
+    throw SpException("illegal call of ServerSocket::writeCh()");
+  }
+  void WriteChar(SpChar ch){
+    throw SpException("illegal call of ServerSocket::WriteChar()");
+  }
+  bool eof(){
+    throw SpException("illegal call of ServerSocket::eof()");
+    return true;
+  }
+
+  static void init();
+  // primitives
+  static SpValue& prim_open(SpValue& port);
+  static SpValue& prim_accept(SpValue& self);
+  static SpValue& prim_close(SpValue& self);
+};
+
+
+#endif /* USE_SOCKET */
+
+class SpDate : public SpObject {
+private:
+  SpInt year;
+  SpInt month;
+  SpInt day;
+
+  void regular();
+public:
+  SpDate(int y, int m, int d) : year(y), month(m), day(d) {}
+
+  bool isDate(){ return true; }
+  const char* typeString(){ return "date"; }
+  SpValue& toString();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  void assign(SpValue& feature, SpValue& value);
+  SpValue& plus(SpValue& e1, SpValue& e2);
+  SpValue& minus(SpValue& e1, SpValue& e2);
+  SpValue& eq(SpValue& e1, SpValue& e2);
+  SpValue& ne(SpValue& e1, SpValue& e2);
+  SpValue& gt(SpValue& e1, SpValue& e2);
+  SpValue& ge(SpValue& e1, SpValue& e2);
+  SpValue& lt(SpValue& e1, SpValue& e2);
+  SpValue& le(SpValue& e1, SpValue& e2);
+
+  static void init();
+  // primitives
+  static SpValue& prim_today();
+  static SpValue& prim_new(SpValue& v1, SpValue& v2, SpValue& v3);
+  static SpValue& prim_succ(SpValue& self);
+  static SpValue& prim_pred(SpValue& self);
+  static SpValue& prim_getYear(SpValue& self);
+  static SpValue& prim_getMonth(SpValue& self);
+  static SpValue& prim_getDay(SpValue& self);
+  static SpValue& prim_fromString(SpValue& date_str);
+  static SpValue& prim_toString(SpValue& self);
+
+  friend class SpDateTime;
+};
+
+class SpTime : public SpObject {
+private:
+  SpInt hour, minute, second;
+
+  void regular();
+public:
+  SpTime(int h, int m, int s) : hour(h), minute(m), second(s) {}
+
+  bool isTime(){ return true; }
+  const char* typeString(){ return "time"; }
+  SpValue& toString();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  void assign(SpValue& feature, SpValue& value);
+  SpValue& plus(SpValue& e1, SpValue& e2);
+  SpValue& minus(SpValue& e1, SpValue& e2);
+  SpValue& eq(SpValue& e1, SpValue& e2);
+  SpValue& ne(SpValue& e1, SpValue& e2);
+  SpValue& gt(SpValue& e1, SpValue& e2);
+  SpValue& ge(SpValue& e1, SpValue& e2);
+  SpValue& lt(SpValue& e1, SpValue& e2);
+  SpValue& le(SpValue& e1, SpValue& e2);
+
+  static void init();
+  // primitives
+  static SpValue& prim_now();
+  static SpValue& prim_new(SpValue& v1, SpValue& v2, SpValue& v3);
+  //static SpValue& prim_succ(SpValue& self);
+  //static SpValue& prim_pred(SpValue& self);
+  static SpValue& prim_getHour(SpValue& self);
+  static SpValue& prim_getMinute(SpValue& self);
+  static SpValue& prim_getSecond(SpValue& self);
+  static SpValue& prim_fromString(SpValue& time_str);
+  static SpValue& prim_toString(SpValue& self);
+
+  friend class SpDateTime;
+};
+
+class SpDateTime : public SpObject {
+private:
+  SpValue date; // SpDate
+  SpValue time; // SpTime
+
+  void regular();
+public:
+  SpDateTime(int year, int mon, int day,
+             int hour, int min, int sec)
+    {
+      date.setNewObject((SpObject*)new SpDate(year, mon, day));
+      time.setNewObject((SpObject*)new SpTime(hour, min, sec));
+    }
+
+  bool isDateTime(){ return true; }
+  const char* typeString(){ return "datetime"; }
+  SpValue& toString();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+  void assign(SpValue& feature, SpValue& value);
+  SpValue& plus(SpValue& e1, SpValue& e2);
+  SpValue& minus(SpValue& e1, SpValue& e2);
+  SpValue& eq(SpValue& e1, SpValue& e2);
+  SpValue& ne(SpValue& e1, SpValue& e2);
+  SpValue& gt(SpValue& e1, SpValue& e2);
+  SpValue& ge(SpValue& e1, SpValue& e2);
+  SpValue& lt(SpValue& e1, SpValue& e2);
+  SpValue& le(SpValue& e1, SpValue& e2);
+
+  static void init();
+  // primitives
+  static SpValue& prim_now();
+  static SpValue& prim_new(SpValue& date, SpValue& time);
+  static SpValue& prim_getYear(SpValue& self);
+  static SpValue& prim_getMonth(SpValue& self);
+  static SpValue& prim_getDay(SpValue& self);
+  static SpValue& prim_getHour(SpValue& self);
+  static SpValue& prim_getMinute(SpValue& self);
+  static SpValue& prim_getSecond(SpValue& self);
+  static SpValue& prim_getDate(SpValue& self);
+  static SpValue& prim_getTime(SpValue& self);
+};
+
+#ifdef USE_DATABASE
+///////////////////////////
+// Database
+///////////////////////////
+
+struct DBRoot {
+  DBRoot* next;
+  SpValue value;
+  int pos;  // file position
+};
+
+class DB {
+private:
+  FILE* file;
+  char filename[MAXPATH];
+  bool closed;
+  //bool locked;
+
+  DBRoot* findRoot(SpValue& name);
+  DBRoot* createRoot(SpValue& name);
+  void setObject(DBRoot* root, SpValue& obj)
+
+  public:
+  DB(char* name){
+    strncpy(filename, name, MAXPATH);
+    filename[MAXPATH-1] = '\0';
+    closed = true;
+  }
+
+  void open();
+  void close();
+  /*
+    void lock();
+    void unlock();
+    bool isLocked(){
+        return locked;
+    }
+   */
+  void setRoot(SpValue& name, SpValue& obj);
+  SpValue& getRoot(SpValue& name);
+};
+
+class SpDatabase : public SpObject {
+private:
+  DB* database;
+
+  void open();
+  void close();
+public:
+  SpDatabase(char* filename);
+  ~SpDatabase();
+
+  bool isDatabase(){ return true; }
+  const char* typeString(){ return "database"; }
+  SpValue& toString();
+  SpValue& onMessage(SpValue& rec, SpValue& msg);
+
+  void setRoot(SpValue& name, SpValue& obj);
+  SpValue& getRoot(SpValue& name);
+
+  static void init();
+
+  // primitives
+  static SpValue& prim_open(SpValue& filename);
+  static SpValue& prim_close(SpValue& db);
+  // NameSpace¡¡¤È¶¦Ä̤Υץê¥ß¥Æ¥£¥Ö
+  /*
+    static SpValue& rename(SpValue& self, SpValue& renames);
+    static SpValue& make_func(SpValue& self);
+    static SpValue& prim_append(SpValue& self, SpValue& key, SpValue& value);
+    static SpValue& prim_keys(SpValue& self);
+    static SpValue& prim_delete(SpValue& self, SpValue& key);
+    static SpValue& prim_lookup(SpValue& self, SpValue& key);
+   */
+};
+
+
+class DBNamespace : public SpObject {
+};
+
+
+class DBArray : public SpObject {
+};
+
+#endif
+
+/*
+ * Lexer
+ */
+
+const int MaxBuf = 1000;
+
+typedef map<SpString*, int, SpStringCmp> KeywordMap;
+
+class Lexer {
+private:
+  ReadEncoder* reader;
+  KeywordMap reserved;
+  static Lexer* lexer;
+  char buf[MaxBuf+1]; // for lex number
+  int index;  // index of buf
+  int integer; // for lex number
+
+  SpChar skipWhiteSpace();
+  int lexZeroNumber();
+  int lexNumber();
+  int lexBIN();
+  int lexOCT();
+  int lexHEX();
+  int lexReal();
+  int lexString();
+  int lexChar();
+  SpChar lexBackslashChar();
+  void skipOneLine();
+  void skipComment();
+  int isReserved(SpCharVector& vec);
+  bool isReservedKigou(SpChar c);
+  bool wdot_read;
+
+  Lexer(ReadEncoder& r=*spin);
+  ~Lexer();
+public:
+  static Lexer* getLexer(ReadEncoder& r=*spin){
+    if(lexer == NULL){
+      lexer = new Lexer(r);
+    }
+    return lexer;
+  }
+
+  int lex();
+  static void setReadEncoder(ReadEncoder* r){ getLexer()->reader = r; }
+  static ReadEncoder* getReadEncoder(){ return getLexer()->reader; }
+};
+
+
+/*
+ * globals, etc
+ */
+
+// globals
+extern MsgHandler NilMsgHandler;
+extern MsgHandler BoolMsgHandler;
+extern MsgHandler CharMsgHandler;
+extern MsgHandler IntMsgHandler;
+extern MsgHandler RealMsgHandler;
+extern MsgHandler ObjectMsgHandler;
+extern MsgHandler ListMsgHandler;
+extern MsgHandler StringMsgHandler;
+extern MsgHandler SymbolMsgHandler;
+extern MsgHandler TupleMsgHandler;
+extern MsgHandler NameSpaceMsgHandler;
+extern MsgHandler ArrayMsgHandler;
+extern MsgHandler FileInMsgHandler;
+extern MsgHandler FileOutMsgHandler;
+extern MsgHandler DirMsgHandler;
+extern MsgHandler FileMsgHandler; /* file util */
+#ifdef USE_SOCKET
+extern MsgHandler SocketMsgHandler;
+extern MsgHandler ServerSocketMsgHandler;
+#endif
+extern MsgHandler DateMsgHandler;
+extern MsgHandler TimeMsgHandler;
+extern MsgHandler DateTimeMsgHandler;
+#ifdef USE_DATABASE
+extern MsgHandler DatabaseMsgHandler;
+#endif
+#ifdef THREAD
+extern MsgHandler ThreadMsgHandler;
+#endif
+
+extern SpValue SymIsInt;
+extern SpValue SymIsChar;
+extern SpValue SymIsBool;
+extern SpValue SymIsReal;
+extern SpValue SymIsList;
+extern SpValue SymIsNil;
+extern SpValue SymIsTuple;
+extern SpValue SymIsString;
+extern SpValue SymIsSymbol;
+extern SpValue SymHead;
+extern SpValue SymTail;
+extern SpValue SymLength;
+extern SpValue SymVar;
+extern SpValue SymRequire;
+extern SpValue SymDo;
+extern SpValue SymEnsure;
+extern SpValue SymRescue;
+extern SpValue SymFrom;
+extern SpValue SymStep;
+extern SpValue SymWhile;
+extern SpValue SymUntil;
+extern SpValue SymVariant;
+extern SpValue SymInvariant;
+extern SpValue SymSoopy;
+extern SpValue SymEnv;
+extern SpValue SymClose;
+extern SpValue SymRename;
+extern SpValue SymArg;
+extern SpValue SymName;
+extern SpValue SymToInt;
+extern SpValue SymToString;
+extern SpValue SymNth;
+extern SpValue SymEach;
+extern SpValue SymFirst;
+extern SpValue SymSecond;
+extern SpValue SymThird;
+extern SpValue SymFourth;
+extern SpValue SymFifth;
+extern SpValue SymEucjpOut;
+extern SpValue SymEucjpIn;
+extern SpValue SymSjisOut;
+extern SpValue SymSjisIn;
+/*
+nil, bool, int, char, real, string, function, expr,
+        tuple, list, array, namespace, datatype_name,
+        stream, file, socket
+ */
+extern SpValue SymBool;
+extern SpValue SymInt;
+extern SpValue SymByte;
+extern SpValue SymWord;
+extern SpValue SymChar;
+extern SpValue SymReal;
+extern SpValue SymString;
+extern SpValue SymSymbol;
+extern SpValue SymFunction;
+extern SpValue SymTuple;
+extern SpValue SymList;
+extern SpValue SymArray;
+extern SpValue SymNameSpace;
+extern SpValue SymReader;
+extern SpValue SymWriter;
+extern SpValue SymEncoderIn;
+extern SpValue SymEncoderOut;
+extern SpValue SymDecoderIn;
+extern SpValue SymDecoderOut;
+extern SpValue SymDir;
+extern SpValue SymMember;
+extern SpValue SymOpen;
+extern SpValue SymOpenIn;
+extern SpValue SymOpenOut;
+extern SpValue SymOpenAppend;
+extern SpValue SymSelf;
+extern SpValue SymWriteChar;
+extern SpValue SymWrite;
+extern SpValue SymWriteLine;
+extern SpValue SymReadLine;
+extern SpValue SymFlush;
+extern SpValue SymClosed;
+extern SpValue SymIsEOF;
+extern SpValue SymUpper;
+extern SpValue SymLower;
+extern SpValue SymAppend;
+extern SpValue SymKeys;
+extern SpValue SymDelete;
+extern SpValue SymSplit;
+extern SpValue SymSplit1;
+extern SpValue SymSort;
+extern SpValue SymMap;
+extern SpValue SymFoldl;
+extern SpValue SymFoldr;
+extern SpValue SymFilter;
+extern SpValue SymReplace;
+extern SpValue SymReplace1;
+extern SpValue SymFind;
+extern SpValue SymYear;
+extern SpValue SymMonth;
+extern SpValue SymDay;
+extern SpValue SymSucc;
+extern SpValue SymPred;
+extern SpValue SymHour;
+extern SpValue SymMinute;
+extern SpValue SymDate;
+extern SpValue SymTime;
+extern SpValue SymAtime;
+extern SpValue SymCtime;
+extern SpValue SymMtime;
+#ifdef USE_DATABASE
+extern SpValue SymDatabase;
+#endif
+extern SpValue SymGet;
+extern SpValue SymSet;
+extern SpValue SymCurrentThread;
+
+extern SpValue PrimNil;
+extern SpValue PrimNil2;
+extern SpValue PrimNil3;
+extern SpValue PrimTrue;
+extern SpValue PrimFalse;
+extern SpValue PrimZero;
+
+extern SpNameSpace* PMainNameSpace;
+extern SpValue MainNS; // main(global) NameSpace
+extern SpNameSpace* PSoopyNameSpace;
+extern SpValue SoopyNS;
+extern SpNameSpace* PEnvNameSpace;
+extern SpValue EnvNS;
+
+extern SjisWriteEncoder* sjisout;
+extern SjisReadDecoder* sjisin;
+extern EucJPWriteEncoder* eucjpout;
+extern EucJPReadDecoder* eucjpin;
+
+void SpInit(int argc, char* argv[], char* env[]);
+void SpFinalize();
+void CheckType(SpValue& featureType, SpValue& value);
+
+#define YYSTYPE SpValue
+int yyerror(char* str);
+
+
+#endif /* __SOOPY_H */
diff --git a/src/test.txt b/src/test.txt
new file mode 100644 (file)
index 0000000..a3fdb7a
--- /dev/null
@@ -0,0 +1,3 @@
+This is a test.
+\82±\82ê\82Í\8a¿\8e\9a\82Ì\83e\83X\83g\82Å\82·\81B
+Hello!
diff --git a/src/test/array.sp b/src/test/array.sp
new file mode 100644 (file)
index 0000000..50c4aa5
--- /dev/null
@@ -0,0 +1,37 @@
+
+n = 5;
+m = 4;
+
+ary = array(n,m);
+
+loop {
+  from: i=0;
+  step: i=i+1;
+  while: i < n;
+  do: [
+    loop {
+      from: j=0;
+      step: j=j+1;
+      while: j < m;
+      do: ary(i,j) = i * j;
+    };
+  ];
+};
+
+loop {
+  from: i=0;
+  step: i=i+1;
+  while: i < n;
+  do: [
+    loop {
+      from: j=0;
+      step: j=j+1;
+      while: j < m;
+      do: [
+        print "(" i "," j ") = ";
+        println (ary (i,j));
+      ];
+    };
+  ];
+};
+
diff --git a/src/test/array2.sp b/src/test/array2.sp
new file mode 100644 (file)
index 0000000..201c27b
--- /dev/null
@@ -0,0 +1,37 @@
+
+n = 5;
+m = 4;
+
+ary = array:byte(n,m);
+
+loop {
+  from: i=0;
+  step: i=i+1;
+  while: i < n;
+  do: [
+    loop {
+      from: j=0;
+      step: j=j+1;
+      while: j < m;
+      do: ary(i,j) = i * j;
+    };
+  ];
+};
+
+loop {
+  from: i=0;
+  step: i=i+1;
+  while: i < n;
+  do: [
+    loop {
+      from: j=0;
+      step: j=j+1;
+      while: j < m;
+      do: [
+        print "(" i "," j ") = ";
+        println (ary (i,j));
+      ];
+    };
+  ];
+};
+
diff --git a/src/test/bank.sp b/src/test/bank.sp
new file mode 100644 (file)
index 0000000..dcfb781
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Bank Account
+ */
+
+BankAccount = {
+  balance: 200;
+
+  fun deposit(x:int){
+    do: balance = balance + x;
+  };
+
+  fun withdraw(x:int){
+    do: [
+      balance = balance - x;
+      match(balance < 0){
+        true: balance = 0;
+      };
+    ];
+  };
+};
+
+println "<<BankAccout demo>>";
+print "BankAccount balance: "; println(BankAccount balance);  # => 200
+
+BankAccount deposit(50);
+println "deposit(50)";
+print "BankAccount balance: "; println(BankAccount balance);  # => 250
+
+BankAccount withdraw(100);
+println "withdraw(100)";
+print "BankAccount balance: "; println(BankAccount balance);  # => 150
+
+BankAccount withdraw(200);
+println "withdraw(200)";
+print "BankAccount balance: ";  println(BankAccount balance);  # => 0
+
+/*
+ * myAccount
+ */
+
+myAccount = BankAccount + {};
+println "" "<<MyAccount demo>>";
+myAccount balance = 100;
+print "myAccount balance: ";  println(myAccount balance);  # => 100
+myAccount deposit(50);
+println "deposit(50)";
+print "myAccount balance: ";  println(myAccount balance);  # => 150
+print "BankAccount balance: ";  println(BankAccount balance);  # => 0
+
+/*
+ * StockAccount
+ */
+
+StockAccount = BankAccount +
+  {
+    private
+      fun setBalance(x:int){
+        do: numShares = x / pricePerShare;
+      };
+
+      fun getBalance(){
+        do: numShares * pricePerShare;
+      };
+
+    public
+      numShares:     10;
+      pricePerShare: 30;
+      property balance {set: setBalance; get: getBalance;};
+  };
+
+println "" "<<StockAccount demo>>";
+print "StockAccount numShares: "; println(StockAccount numShares);          # => 10
+print "StockAccount pricePerShare: "; println(StockAccount pricePerShare);  # => 30
+print "StockAccount balance: ";  println(StockAccount balance);    # => 300
+StockAccount balance = 600;
+print "StockAccount balance: ";  println(StockAccount balance);    # => 600
+print "StockAccount numShares: "; println(StockAccount numShares); # => 20
+StockAccount deposit(60);
+println "deposit(60)";
+print "StockAccount balance: ";  println(StockAccount balance);    # => 660
+print "StockAccount numShares: "; println(StockAccount numShares); # => 22
+StockAccount withdraw(90);
+println "withdraw(90)";
+print "StockAccount balance: ";  println(StockAccount balance);    # => 570
+print "StockAccount numShares: "; println(StockAccount numShares); # => 19
+
+
diff --git a/src/test/byte.sp b/src/test/byte.sp
new file mode 100644 (file)
index 0000000..15ac4c2
--- /dev/null
@@ -0,0 +1,66 @@
+#########################
+# byte read & write test
+#########################
+
+####################
+# read test
+####################
+
+const bytes = 16;
+
+buffer = array:byte(bytes);
+filename = "euc.txt";
+fin = openIn filename;
+
+loop {
+  until: fin eof?;
+  do: [
+    n = fin readbyte bytes buffer;
+    print "read bytes: "; println n;
+    match(n == 0){
+      false: [
+        loop {
+          from: i=0;
+          step: i=i+1;
+          while: i < bytes;
+          do: [
+            print(buffer(i)) ", ";
+          ];
+        };
+        println "";
+      ];
+    }
+  ];
+};
+
+
+####################
+# write test
+####################
+
+const wbytes = 256;
+buf = array:byte(wbytes);
+outfile = "byte.out";
+fout = openOut outfile;
+
+loop {
+  from: i=0;
+  step: i = i + 1;
+  while: i < wbytes;
+  do: [
+    buf i = i;
+  ];
+};
+
+loop {
+  from: i=0;
+  step: i=i+1;
+  while: i < 4;
+  do: [
+    n = fout writebyte wbytes buf;
+    print "write bytes: "; println n;
+  ];
+};
+
+fout close;
+
diff --git a/src/test/cat.sp b/src/test/cat.sp
new file mode 100644 (file)
index 0000000..f37181c
--- /dev/null
@@ -0,0 +1,45 @@
+fun printlines(lines){
+  do: match(lines){
+        []: true;
+        x::xs: [
+            println x;
+            printlines xs;
+          ];
+      };
+};
+
+fun cat(file){
+  var: [fin, lines];
+  do: [
+    fin = openIn file;
+    lines = fin readlineS;
+    printlines lines;
+    fin close;
+  ];
+};
+
+
+fun cats(files){
+  do: match(files){
+        []:    [];
+        x::xs: [ cat x; cats xs; ];
+      };
+};
+
+fun usage(){
+  do: [
+    println "usage: soopy cat.sp file1 [file2 ... fileN]";
+  ];
+};
+
+/*
+ * Main routine
+ */
+
+files = Soopy commandLine;
+match(files){
+  []: usage();
+  _:  cats(files);
+};
+
+
diff --git a/src/test/cat2.sp b/src/test/cat2.sp
new file mode 100644 (file)
index 0000000..f1bf4b6
--- /dev/null
@@ -0,0 +1,79 @@
+
+program = {
+  comment:  "cat program in soopy2";
+  author:   "$Author: randy $";
+  date:     "$Date: 2004/03/27 05:59:44 $";
+  revision: "$Revision: 1.4 $";
+
+  fun usage(){
+    do: [
+      println "usage: soopy cat.sp file1 [file2 ... fileN]";
+    ];
+  };
+
+  fun printlines(lines){
+    comment: "print each lines with newline";
+    do: match(lines){
+          []: true;
+          x::xs: [
+              println x;
+              printlines xs;
+            ];
+        };
+  };
+
+  fun with_openIn_file(filename, body){
+    comment: "open file & eval body & close file";
+    var: [fin];
+    do: [
+      fin = openIn filename;
+      body eval(fin);
+      fin close;
+    ];
+    rescue: fin close;
+  };
+
+
+  fun cat(file){
+    comment: "cat a file";
+    do: [
+      with_openIn_file file {
+        arg: [fin];
+        var: [lines];
+        do: [
+          lines = fin readlines;
+          printlines lines;
+        ];
+      };
+    ];
+  };
+
+  fun cats(files){
+    comment: "cat files";
+    do: match(files){
+          []:    [];
+          x::xs: [ cat x; cats xs; ];
+        };
+  };
+
+  /*
+   * Main routine
+   */
+  fun main(){
+    comment: "main routine";
+    var: [files];
+    do: [
+      files = Soopy commandLine;
+      match(files){
+        []: usage();
+        _:  cats(files);
+      };
+    ];
+  };
+};
+
+/*
+ * run program
+ */
+program main();
+
diff --git a/src/test/cat3.sp b/src/test/cat3.sp
new file mode 100644 (file)
index 0000000..813f633
--- /dev/null
@@ -0,0 +1,80 @@
+
+program = {
+  comment:  "cat program in soopy2";
+  author:   "$Author: randy $";
+  date:     "$Date: 2004/03/27 05:59:44 $";
+  revision: "$Revision: 1.3 $";
+
+  fun usage(){
+    do: [
+      println "usage: soopy cat.sp file1 [file2 ... fileN]";
+    ];
+  };
+
+  fun printlines(lines){
+    comment: "print each lines with newline";
+    do: match(lines){
+          []: true;
+          x::xs: [
+              println x;
+              printlines xs;
+            ];
+        };
+  };
+
+  fun with_openEncodeIn_file(encoder, filename, body){
+    comment: "open file & eval body & close file";
+    var: [fin, f];
+    do: [
+      f = openIn filename;
+      fin = encoder decoderIn(f);
+      body eval(fin);
+      fin close;
+    ];
+    rescue: fin close;
+  };
+
+
+  fun cat(file){
+    comment: "cat a file";
+    do: [
+      with_openEncodeIn_file SJIS file {
+        arg: [fin];
+        var: [lines];
+        do: [
+          lines = fin readlines;
+          printlines lines;
+        ];
+      };
+    ];
+  };
+
+  fun cats(files){
+    comment: "cat files";
+    do: match(files){
+          []:    [];
+          x::xs: [ cat x; cats xs; ];
+        };
+  };
+
+  /*
+   * Main routine
+   */
+  fun main(){
+    comment: "main routine";
+    var: [files];
+    do: [
+      files = Soopy commandLine;
+      match(files){
+        []: usage();
+        _:  cats(files);
+      };
+    ];
+  };
+};
+
+/*
+ * run program
+ */
+program main();
+
diff --git a/src/test/clike.sp b/src/test/clike.sp
new file mode 100644 (file)
index 0000000..3908db6
--- /dev/null
@@ -0,0 +1,214 @@
+#
+# for
+#
+
+fun for(init, cond, step, body){
+  do: [
+    loop {
+      from:  init each {arg:[dammy]; do: [];};
+      while: cond head;
+      step:  step each {arg:[dammy]; do: [];};
+      do:    body each {arg:[dammy]; do: [];};
+    };
+  ];
+};
+
+
+#
+# local
+#
+
+fun local(vars, body){
+  do: (vars + {do: body;}) eval();
+};
+
+
+#
+# lambda
+#
+
+fun lambda(args, body){
+  do: {arg: args; do: body;} eval;
+};
+
+#
+# if -- like C
+#
+
+fun c_if(cond, then, else){
+  do: [
+    match(cond){
+      true:  then each {arg:[dammy]; do: [];};
+      false: else each {arg:[dammy]; do: [];};
+    };
+  ];
+};
+
+#
+# when
+#
+
+fun when(cond, body){
+  do: [
+    match(cond){
+      true: body each {arg:[dammy]; do: [];};
+    };
+  ];
+};
+
+
+#
+# unless
+#
+
+fun unless(cond, body){
+  do: [
+    match(cond){
+      false: body each {arg:[dammy]; do: [];};
+    };
+  ];
+};
+
+
+#
+# while
+#
+
+fun while(cond, body){
+  do: [
+    loop {
+      while: cond head;
+      do: body each {arg:[dammy]; do: [];};
+    };
+  ];
+};
+
+
+#
+# until
+#
+
+fun until(cond, body){
+  do: [
+    loop {
+      until: cond head;
+      do: body each {arg:[dammy]; do: [];};
+    };
+  ];
+};
+
+
+#
+# do
+#
+
+fun do(body){
+  do: [
+    body each {arg:[dammy]; do: [];};
+    {
+      while: {
+          arg:[cond];
+          do: [
+            loop {
+              while: cond head;
+              do: body each {arg:[dammy]; do: [];};
+            };
+          ];
+        } eval;
+      until: {
+          arg:[cond];
+          do: [
+            loop {
+              until: cond head;
+              do: body each {arg:[dammy]; do: [];};
+            };
+          ];
+        } eval;
+    };
+  ];
+};
+
+
+# test  -- for & local
+
+println "<<for & local>>";
+i = 5;
+local{i: 0;}[
+  for[i=0][i < 10][i = i + 1][
+    print "i = "; println i;
+  ];
+];
+print "global i = "; println i; # => 5
+
+# test  -- labmda
+
+println "<<lambda>>";
+sq = lambda[x][x * x];
+print "sq 9 = "; println(sq 9);
+
+# test c_if
+
+println "<<c_if>>";
+c_if(1 == 1)[
+  print "1 == 1."; println "SUCCESS.";
+][
+  print "1 != 1."; println "Error.";
+];
+
+c_if(1 == 2)[
+  print "1 == 2."; println "Error";
+][
+  print "1 != 2."; println "SUCCESS";
+];
+
+# test -- when
+
+println "<<when>>";
+when(true)[println "when true"];
+when(false)[println "when false"];
+
+# test -- unless
+
+println "<<unless>>";
+unless(true)[println "unless true"];
+unless(false)[println "unless false"];
+
+# test -- while
+
+println "<<while>>";
+i = 0;
+while[i < 10][
+  println i;
+  i = i + 1;
+];
+
+# test -- until
+
+println "<<until>>";
+i = 0;
+until[i == 10][
+  println i;
+  i = i + 1;
+];
+
+
+# test -- do
+
+println "<<do while>>";
+i = 0;
+do [
+  println i;
+  i = i + 1;
+] while [i < 5];
+
+
+println "<<do until>>";
+i = 0;
+do [
+  println i;
+  i = i + 1;
+] until [i == 5];
+
+
+
+
diff --git a/src/test/cp.sp b/src/test/cp.sp
new file mode 100644 (file)
index 0000000..179e400
--- /dev/null
@@ -0,0 +1,73 @@
+
+program = {
+  comment:  "file copy in soopy2";
+  author:   "$Author: randy $";
+  date:     "$Date: 2004/03/27 05:59:44 $";
+  revision: "$Revision: 1.6 $";
+
+  fun usage(){
+    do: println "usage: soopy cp.sp src_file dist_file";
+  };
+
+  fun with_openIn_file(filename, body){
+    comment: "open input-file & eval body & close file";
+    var: [fin];
+    do: [
+      fin = openIn filename;
+      body eval(fin);
+      fin close;
+    ];
+    rescue: fin close;
+  };
+
+  fun with_openOut_file(filename, body){
+    comment: "open output-file & eval body & close file";
+    var: [fout];
+    do: [
+      fout = openOut filename;
+      body eval(fout);
+      fout close;
+    ];
+    rescue: fout close;
+  };
+
+  fun copy(src, dist){
+    comment: "copy file from src to dist";
+    do: with_openIn_file src {
+          arg: [fin];
+          var: [ch];
+          do: [
+                with_openOut_file dist {
+                  arg: [fout];
+                  do: [
+                    loop {
+                      until: fin eof?;
+                      do: [
+                        ch = fin readChar;
+                        fout writeChar ch;
+                      ];
+                    };
+                  ];
+                };
+              ];
+        };
+  };
+
+  /*
+   * Main routine
+   */
+  fun main(){
+    comment: "main routine";
+    var: [files];
+    do: [
+      files = Soopy commandLine;
+      match(files){
+        [x,y]: copy(x,y);
+        _:     usage();
+      };
+    ];
+  };
+};
+
+program main();
+
diff --git a/src/test/cp2.sp b/src/test/cp2.sp
new file mode 100644 (file)
index 0000000..b316a75
--- /dev/null
@@ -0,0 +1,73 @@
+
+program = {
+  comment:  "file copy in soopy2";
+  author:   "$Author: randy $";
+  date:     "$Date: 2004/03/27 05:59:44 $";
+  revision: "$Revision: 1.4 $";
+
+  fun usage(){
+    do: println "usage: soopy cp.sp src_file dist_file";
+  };
+
+  fun with_openIn_file(filename, body){
+    comment: "open input-file & eval body & close file";
+    var: [fin];
+    do: [
+      fin = openIn filename;
+      body eval(fin);
+      fin close;
+    ];
+    rescue: fin close;
+  };
+
+  fun with_openOut_file(filename, body){
+    comment: "open output-file & eval body & close file";
+    var: [fout];
+    do: [
+      fout = openOut filename;
+      body eval(fout);
+      fout close;
+    ];
+    rescue: fout close;
+  };
+
+  fun copy(src, dist){
+    comment: "copy file from src to dist";
+    do: with_openIn_file src {
+          arg: [fin];
+          var: [line];
+          do: [
+                with_openOut_file dist {
+                  arg: [fout];
+                  do: [
+                    loop {
+                      until: fin eof?;
+                      do: [
+                        line = fin readLine;
+                        fout writeLine line;
+                      ];
+                    };
+                  ];
+                };
+              ];
+        };
+  };
+
+  /*
+   * Main routine
+   */
+  fun main(){
+    comment: "main routine";
+    var: [files];
+    do: [
+      files = Soopy commandLine;
+      match(files){
+        [x,y]: copy(x,y);
+        _:     usage();
+      };
+    ];
+  };
+};
+
+program main();
+
diff --git a/src/test/cp3.sp b/src/test/cp3.sp
new file mode 100644 (file)
index 0000000..404de6e
--- /dev/null
@@ -0,0 +1,78 @@
+
+program = {
+  comment:  "file copy in soopy2";
+  author:   "$Author: randy $";
+  date:     "$Date: 2004/03/27 05:59:44 $";
+  revision: "$Revision: 1.5 $";
+
+  fun usage(){
+    do: [
+      println "usage: soopy cp3.sp input_encode_type src_file output_encode_type dist_file";
+      println "  ex. soopy cp3.sp sjis sjis.txt eucjp output.txt";
+    ];
+  };
+
+  fun with_openEncodeIn_file(encoder, filename, body){
+    comment: "open file & eval body & close file";
+    var: [fin, f];
+    do: [
+      f = Raw openIn filename;
+      fin = encoder encoderIn(f);
+      body eval(fin);
+      fin close;
+    ];
+    rescue: fin close;
+  };
+
+  fun with_openEncodeOut_file(encoder, filename, body){
+    comment: "open output-file & eval body & close file";
+    var: [fout, f];
+    do: [
+      f = Raw openOut filename;
+      fout = encoder encoderOut(f);
+      body eval(fout);
+      fout close;
+    ];
+    rescue: fout close;
+  };
+
+  fun copy(src_encode, src, dist_encode, dist){
+    comment: "copy file from src to dist";
+    do: with_openEncodeIn_file src_encode src {
+          arg: [fin];
+          var: [line];
+          do: [
+                with_openEncodeOut_file dist_encode dist {
+                  arg: [fout];
+                  do: [
+                    loop {
+                      until: fin eof?;
+                      do: [
+                        line = fin readLine;
+                        fout writeLine line;
+                      ];
+                    };
+                  ];
+                };
+              ];
+        };
+  };
+
+  /*
+   * Main routine
+   */
+  fun main(){
+    comment: "main routine";
+    var: [files];
+    do: [
+      files = Soopy commandLine;
+      match(files){
+        [enc1,x,enc2,y]: copy((enc1 symbol), x, (enc2 symbol), y);
+        _:               usage();
+      };
+    ];
+  };
+};
+
+program main();
+
diff --git a/src/test/crlf.sp b/src/test/crlf.sp
new file mode 100644 (file)
index 0000000..e62f248
--- /dev/null
@@ -0,0 +1,119 @@
+
+program = {
+  comment:  "file copy with CRLF -> LF in soopy2";
+  author:   "$Author: randy $";
+  date:     "$Date: 2004/03/27 05:59:44 $";
+  revision: "$Revision: 1.2 $";
+
+  fun usage(){
+    do: println "usage: soopy crlf.sp src_file dist_file dist2";
+  };
+
+  fun with_openIn_file(filename, body){
+    comment: "open input-file & eval body & close file";
+    var: [fin];
+    do: [
+      fin = openIn filename;
+      body eval(fin);
+      fin close;
+    ];
+    rescue: fin close;
+  };
+
+  fun with_openOut_file(filename, body){
+    comment: "open output-file & eval body & close file";
+    var: [fout];
+    do: [
+      fout = openOut filename;
+      body eval(fout);
+      fout close;
+    ];
+    rescue: fout close;
+  };
+
+  fun with_openEncodeIn_file(encoder, filename, body){
+    comment: "open file & eval body & close file";
+    var: [fin, f];
+    do: [
+      #f = Raw openIn filename;
+      f = openIn filename;
+      fin = encoder encoderIn(f);
+      body eval(fin);
+      fin close;
+    ];
+    rescue: fin close;
+  };
+
+  fun with_openEncodeOut_file(encoder, filename, body){
+    comment: "open output-file & eval body & close file";
+    var: [fout, f];
+    do: [
+      #f = Raw openOut filename;
+      f = openOut filename;
+      fout = encoder encoderOut(f);
+      body eval(fout);
+      fout close;
+    ];
+    rescue: fout close;
+  };
+
+  fun copy(src, dist){
+    comment: "copy file from src to dist";
+    do: with_openIn_file src {
+          arg: [fin];
+          var: [ch];
+          do: [
+                with_openEncodeOut_file LF2CR dist {
+                  arg: [fout];
+                  do: [
+                    loop {
+                      from: ch = fin readChar;
+                      step: ch = fin readChar;
+                      until: fin eof?;
+                      do: fout writeChar ch;
+                    };
+                  ];
+                };
+              ];
+        };
+  };
+
+  fun copy2(src, dist){
+    comment: "copy file from src to dist";
+    do: with_openEncodeIn_file LF2CR src {
+          arg: [fin];
+          var: [ch];
+          do: [
+                with_openOut_file dist {
+                  arg: [fout];
+                  do: [
+                    loop {
+                      from: ch = fin readChar;
+                      step: ch = fin readChar;
+                      until: fin eof?;
+                      do: fout writeChar ch;
+                    };
+                  ];
+                };
+              ];
+        };
+  };
+
+  /*
+   * Main routine
+   */
+  fun main(){
+    comment: "main routine";
+    var: [files];
+    do: [
+      files = Soopy commandLine;
+      match(files){
+        [x,y,z]: [copy(x,y); copy2(x,z);];
+        _:     usage();
+      };
+    ];
+  };
+};
+
+program main();
+
diff --git a/src/test/csock.sp b/src/test/csock.sp
new file mode 100644 (file)
index 0000000..bbf9f4c
--- /dev/null
@@ -0,0 +1,16 @@
+/* see also 'ssock.sp' */
+
+/* client socket */
+
+sock = Socket open "localhost" 2000;
+match(sock isNil?){
+  false: [
+    reader = Sjis encoderIn sock;
+    println "connected.";
+    line = reader readline;
+    println line;
+  ];
+};
+sock close;
+
+
diff --git a/src/test/csock2.sp b/src/test/csock2.sp
new file mode 100644 (file)
index 0000000..d077b78
--- /dev/null
@@ -0,0 +1,34 @@
+/* see also 'ssock2.sp' */
+
+/* client socket */
+
+const bufsize = 5;
+
+sock = Socket open "localhost" 2000;
+match(sock isNil?){
+  false: [
+    println "connected.";
+    buf = array:byte(bufsize);
+    recv = sock receive bufsize;
+    loop {
+      from: j=0;
+      step: j=j+1;
+      while: j < 3;
+      do: [
+        size = recv buf;
+        loop {
+          from: i=0;
+          step: i=i+1;
+          while: i < size;
+          do: [
+            print i ":";
+            println (buf i);
+          ];
+        };
+      ];
+    };
+  ];
+};
+sock close;
+
+
diff --git a/src/test/datatype.sp b/src/test/datatype.sp
new file mode 100644 (file)
index 0000000..6c70cc7
--- /dev/null
@@ -0,0 +1,83 @@
+
+datatype day {
+    property holiday? {get: isHoliday;};
+    fun isHoliday(){
+      do: [!workday?];
+    };
+  }
+= Mon {
+    const workday? = true;
+  }
+| Tue {
+    const workday? = true;
+  }
+| Wed {
+    const workday? = true;
+  }
+| Thi {
+    const workday? = true;
+  }
+| Fri {
+    const workday? = true;
+  }
+| Sat {
+    const workday? = false;
+  }
+| Sun {
+    const workday? = false;
+  }
+;
+
+
+datatype fig =
+  Rect(x:int, y:int){
+    fun area(){
+      do: x * y;
+    };
+  }
+| Circle(r:int){
+    pi: 3.14;
+    fun area(){
+      do: r * r * pi;
+    };
+  }
+;
+
+r = Rect(5,7);
+c = Circle(8);
+
+print r ".area = ";
+println (r area());
+
+print c ".area = ";
+println (c area());
+
+
+match(r){
+  Circle(r): [
+    print "It's a circle(radius = " r;
+    println ")";
+  ];
+  Rect(3,4): println "fail";
+  Rect(width, height): [
+    print "It's a rectangle(width = " width ", height = " height;
+    println ")";
+  ];
+  other: println "not match";
+};
+
+match(c){
+  Circle(2): println "fail.";
+  Circle(r): [
+    print "It's a circle(radius = " r;
+    println ")";
+  ];
+  Rect(width, height): [
+    println "It's a rectangle";
+    print "  width = " width ", height = ";
+    println height;
+  ];
+  other: println "not match";
+};
+
+
diff --git a/src/test/dtype2.sp b/src/test/dtype2.sp
new file mode 100644 (file)
index 0000000..0627bb7
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * datatype in namespace
+ */
+
+obj = {
+  datatype fig = Rect(x:int, y:int) | Circle(r:int);
+
+  fun checkRect(r:fig){
+    do: [
+      print r " is ";
+      match(r){
+        Rect(3,4): println "Rect(3,4)";
+        Rect(width, height): [
+          print "Rectangle(width = " width ", height = " height;
+          println ")";
+        ];
+        _: println "not a rect.";
+      }
+    ];
+  };
+
+  fun checkCircle(c:fig){
+    do: [
+      print c " is ";
+      match(c){
+        Circle(5): println " Circle(5)";
+        Circle(r): [
+          print "a circle(radius = " r;
+          println ")";
+        ];
+        _: println "not a circle.";
+      }
+    ];
+  };
+
+  fun main(){
+    var: [r,c];
+    do: [
+      r = Rect(2,9);
+      c = Circle(10);
+      checkRect(r);
+      checkCircle(r);
+      checkRect(c);
+      checkCircle(c);
+    ];
+  };
+};
+
+obj main();
+
diff --git a/src/test/each.sp b/src/test/each.sp
new file mode 100644 (file)
index 0000000..952f835
--- /dev/null
@@ -0,0 +1,33 @@
+
+fun f(ns){
+  do: [ns a = (ns a) + 1];
+};
+
+n1 = {a:1;};
+n2 = {a:2;};
+n3 = {a:3;};
+
+l = [n1,n2,n3];
+
+fun p(){
+  do: [
+    println "start";
+    print "n1 = "; println n1;
+    print "n2 = "; println n2;
+    print "n3 = "; println n3;
+    println "end";
+  ];
+};
+
+
+p();
+l each f;
+p();
+
+l each {
+  arg:[ns];
+  do: [ns a = (ns a) + 1];
+};
+
+p();
+
diff --git a/src/test/fact.sp b/src/test/fact.sp
new file mode 100644 (file)
index 0000000..9fc3040
--- /dev/null
@@ -0,0 +1,11 @@
+fun fact(n:int){
+  require: n >= 0;
+  do: match(n){
+        0: 1;
+        n: n * (fact(n-1));
+      };
+};
+
+print "fact(10) = ";
+println (fact(10));    # 3628800
+
diff --git a/src/test/fib.sp b/src/test/fib.sp
new file mode 100644 (file)
index 0000000..f50c751
--- /dev/null
@@ -0,0 +1,13 @@
+fun fib(n:int){
+  require: n >= 0;
+  do: match(n){
+        0: 0;
+        1: 1;
+        x: (fib(x-2)) + (fib(x-1));
+      };
+};
+
+
+x = 15;
+print "fib " x " = ";
+println (fib x);
diff --git a/src/test/filter.sp b/src/test/filter.sp
new file mode 100644 (file)
index 0000000..184d42c
--- /dev/null
@@ -0,0 +1,15 @@
+
+fun even(x){
+  do: (x % 2) == 0;
+};
+
+fun odd(x){
+  do: (x % 2) == 1;
+};
+
+
+l = [1..10];
+
+print "even: " (l filter even); println "";
+print "odd: " (l filter odd); println "";
+
diff --git a/src/test/format.sp b/src/test/format.sp
new file mode 100644 (file)
index 0000000..e573534
--- /dev/null
@@ -0,0 +1,9 @@
+
+formatString = "string:'%10s', int:'%05d', real:'%f', any object:'%s'";
+formatFunction = formatString format;
+println(formatFunction "Hello, world" 123 3.141 [1..3]);
+
+format2 = "char<%c>, hex<%#08x>, HEX<%#8X>, oct<%o>, bin<%#16b>";
+func2 = format2 format;
+println(func2 '\8a¿' 0x0707 0xabcde 00765 0b1011001101);
+
diff --git a/src/test/func.sp b/src/test/func.sp
new file mode 100644 (file)
index 0000000..41455f1
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * function
+ */
+
+fun f(x,y,z){
+  var: [n,m];  # local variables
+  require: [   # pre conditions
+    x > y;
+    y > z;
+  ];
+  do: [        # body
+    n = x + y;
+    m = y + z;
+    m + n;
+  ];
+  ensure: [    # post conditions
+    n > m;
+  ];
+  rescue: [    # rescue clause
+    x = y + z;
+    retry;
+  ];
+};
+
+print "f(5,4,2) = ";
+println (f(5,4,2));
+#print "f(2,4,5) = ";
+#println (f(2,4,5));  # pre condition error
+
+
+fun g(x){
+  require: x > 0;
+  do: [
+    print "x = ";
+    println x;
+    x = x + x;
+  ];
+  ensure: x > 7;
+  rescue: [
+    x = x + 1;
+    retry;
+  ];
+};
+
+print "g(1) = ";println(g 1);
diff --git a/src/test/gcd.sp b/src/test/gcd.sp
new file mode 100644 (file)
index 0000000..1c75419
--- /dev/null
@@ -0,0 +1,30 @@
+fun max(a,b){
+  do: match(a >= b){
+        true:  a;
+        false: b;
+      };
+};
+
+fun gcd(a,b){
+  require: [a > 0; b > 0];
+  var: [x,y];
+  do: [
+    loop {
+      from: [x = a; y = b];
+      invariant: [x > 0; y > 0];
+      variant: max(x,y);
+      until: x == y;
+      do: match(x > y){
+            true:  x = x - y;
+            false: y = y - x;
+          };
+    };
+    x;
+  ];
+};
+
+x = 3 * 5 * 7 * 11 * 17;
+y = 3 * 5 * 7 * 8;
+
+print "gcd(x,y) = "; println (gcd(x,y));  # 105
+
diff --git a/src/test/hello.sp b/src/test/hello.sp
new file mode 100644 (file)
index 0000000..a497ab5
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  fun main(){
+    do: println "Hello, world";
+  };
+} main();
+
diff --git a/src/test/http.sp b/src/test/http.sp
new file mode 100644 (file)
index 0000000..55662a3
--- /dev/null
@@ -0,0 +1,21 @@
+
+server = "soopy.sourceforge.jp";
+
+sock = Socket open server 80;
+
+w = sock writeline;
+w "GET /index.html HTTP/1.0";
+w "Accept: */*";
+w "";
+
+reader = EucJP decoderIn sock;
+loop {
+  until: reader eof?;
+  do: [
+    line = reader readline;
+    println line;
+  ];
+};
+
+sock close;
+
diff --git a/src/test/if.sp b/src/test/if.sp
new file mode 100644 (file)
index 0000000..c3c06f3
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * if -- pattern match
+ */
+
+match(3 > 2){
+  true:  println "foo";
+  false: println "bar";
+};
+
+match("hello"){
+  x: println x;    # a symbol matchs any object.
+  other: println "Hummm..";
+};
+
+match("hello"){
+  "test": println "not hello";
+  "hello": println "match 'hello'";
+  other: println "Hummm..";
+};
+
+match((2,3,4)){
+  1: 1;
+  "hello": 2;
+  (i,j): [
+    print "i: " i ", j: ";
+    println j;
+  ];
+  (5,n,m): 3;
+  (x,y,z): [
+    print "tuple: " x "," y ",";
+    println z;
+    print "n: " n ", m: ";
+    println m;
+  ];
+};
+
+match([3,4,5]){
+  1: println 1;
+  "hello": println "hello";
+  [i,j]: println 2;
+  [m,8,n]: println "not match list";
+  [x,y,z]: [
+    print "list: " x "," y ",";
+    println z;
+    print "n: " n ", m: ";
+    println m;
+  ];
+};
+
+match([5,6,7]){
+  1: println 1;
+  "test": println 2;
+  [m,n]: println 3;
+  x::xs: [
+    print "x::xs => " x "::";
+    println xs;
+    print "n: " n ", m: ";
+    println m;
+  ];
+  other: println "fail";
+};
+
+match([2..6]){
+  1: println 1;
+  "test": println 2;
+  [m,n]: println 3;
+  [m,n] @ [i,j]: println 4;
+  [x,y] @ [i,j,k]: [
+    print "list@list: " x "," y "," i "," j ",";
+    println k;
+    print "n: " n ", m: ";
+    println m;
+  ];
+  other: println "fail";
+};
+
+
+fun f(x:int){
+  do: match(x > 10){
+        true:  [print x; println " is large"];
+        false: [print x; println " is small"];
+      };
+};
+
+f 2;
+f 12;
diff --git a/src/test/japan.sp b/src/test/japan.sp
new file mode 100644 (file)
index 0000000..327d358
--- /dev/null
@@ -0,0 +1,24 @@
+\81^\81\96
+\81@\81\96\81@soopy\82Í\81A\95\8e\9a\81A\95\8e\9a\97ñ\88È\8aO\82Å\82Í\81A
+\81@\81\96\81@\91å\95\8e\9a\81E\8f¬\95\8e\9a\81E\91S\8ap\81E\94¼\8ap\82ð\8bæ\95Ê\82µ\82È\82¢\81B
+\81@\81\96\81^
+
+\95Ï\90\94\82P\81@\81\81\81@\82W\81G
+\95Ï\90\94\82Q\81@\81\81\81@\82Q\81G
+
+\82\86\82\95\82\8e\81@\8aÖ\90\94\81i\88ø\90\94\81j\81o
+\81@\81@\82\84\82\8f\81F\81@\81m
+\81@\81@\81@\81@\82\8d\82\81\82\94\82\83\82\88\81i\88ø\90\94\81j\81o
+\81@\81@\81@\81@\81@\81@\82P\81F\81@\82\90\82\92\82\89\82\8e\82\94\82\8c\82\8e\81@\81h\82P\82Å\82·\81B\81h\81G
+\81@\81@\81@\81@\81@\81@\82Q\81F\81@\82\90\82\92\82\89\82\8e\82\94\82\8c\82\8e\81@\81h\82Q\82©\82È\81H\81h\81G
+\81@\81@\81@\81@\81@\81@\82R\81F\81@\82\90\82\92\82\89\82\8e\82\94\82\8c\82\8e\81@\81h\82R\82Å\82²\82í\82·\81B\81h\81G
+\81@\81@\81@\81@\81@\81@\82S\81F\81@\82\90\82\92\82\89\82\8e\82\94\82\8c\82\8e\81@\81h\82S\82ç\82µ\82¢\81B\81h\81G
+\81@\81@\81@\81@\81@\81@\82W\81F\81@\82\90\82\92\82\89\82\8e\82\94\82\8c\82\8e\81@\81h\82â\82Á\82Ï\81A\82W\82Å\82µ\82å\81B\81h\81G
+\81@\81@\81@\81@\81p\81G
+\81@\81@\81n\81G
+\81p\81G
+
+\8aÖ\90\94\81@\95Ï\90\94\82P\81G
+\8aÖ\90\94\81@\95Ï\90\94\82Q\81G
+
+
diff --git a/src/test/keys.sp b/src/test/keys.sp
new file mode 100644 (file)
index 0000000..5f4c9d6
--- /dev/null
@@ -0,0 +1,14 @@
+
+a = {
+  "This": 1;
+  "is":   2;
+  "a":    3;
+  "pen.": 4;
+};
+
+fun f(x:string){
+  do: println x;
+};
+
+a keys sort each f;
+
diff --git a/src/test/list.sp b/src/test/list.sp
new file mode 100644 (file)
index 0000000..245c582
--- /dev/null
@@ -0,0 +1,240 @@
+# \83\8a\83X\83g\82Ì\93à\95ï\95\\8bL
+
+fun even(xs){
+  do: [
+    [x | x <- xs, x % 2 == 0]
+  ];
+};
+
+fun odd(xs){
+  do: [
+    [x | x <- xs, x % 2 == 1]
+  ];
+};
+
+match(even []){
+  []: [];  # do nothing
+  else: println "error: even [] != nil";
+};
+
+match(odd []){
+  []: [];  # do nothing
+  else: println "error: odd [] != nil";
+};
+
+list = [1..10];
+
+print "even: ";
+println (even list);
+print "odd:  ";
+println (odd list);
+
+
+#
+# primes
+#
+
+fun primes(list){
+  do: [
+    match(list){
+      x::xs : x :: (primes [n | n <- xs, n % x != 0]);
+    };
+  ];
+};
+
+print "primes: ";
+println (primes [2..30]);
+
+#
+# quick sort
+#
+
+fun qsort(list){
+  do: [
+    match(list){
+      []    : [];
+      x::xs : (qsort [y | y<- xs, y <= x]
+               @ (x :: (qsort [y | y <- xs, y > x])));
+    };
+  ];
+};
+
+list = [3, 7, 2, 8, 1, 6, 0, 4, 10, 9, 5];
+print "qsort: " list " => ";
+println (qsort list);
+
+
+#
+# quick sort 2
+#
+
+datatype Figure =
+  Rect(x:int, y:int){
+    fun area(){
+      do: x * y;
+    };
+  }
+| Circle(r:int){
+    pi: 3.14;
+    fun area(){
+      do: r * r * pi;
+    };
+  }
+;
+
+fun qsort2(less, list){
+  do: [
+    match(list){
+      []    : [];
+      x::xs : (qsort2 less [y | y<- xs, less(y, x)]
+               @ (x :: (qsort2 less [y | y <- xs, !less(y, x)])));
+    };
+  ];
+};
+
+fun less(x, y){
+  do: [
+    (x area()) < (y area())
+  ];
+};
+
+fig_list = [Rect(5,7), Circle(8), Rect(2,4), Circle(3), Rect(4,7), Rect(10, 5)];
+
+print "qsort2: "; println fig_list;
+print "    ==> "; println (qsort2 less fig_list);
+
+/*
+fig_list each {
+  comment: "fig_list\93à\82Ì\90}\8c`\82Ì\96Ê\90Ï\82ð\8f\87\94Ô\82É\8b\81\82ß\82Ä\95\\8e¦\82·\82é\81B";
+  arg: [val];
+  do: [
+    print val " => ";
+    println(val area());
+  ];
+};
+*/
+
+#
+# diagonalising ZF
+#
+
+fun cmp(t, t2){
+  do: [
+    match(t){
+      (x1, y1, z1): [
+        match(t2){
+          (x2, y2, z2): [
+            match(x1 < x2){
+              true: true;
+              false: match(y1 < y2){
+                       true: true;
+                       false: z1 < z2;
+                     };
+            }
+          ];
+        };
+      ];
+    };
+  ];
+};
+
+fun eq(t, t2){
+  do: [
+    match(t){
+      (x1, y1, z1): [
+        match(t2){
+          (x2, y2, z2): [
+            match(x1 == x2){
+              true: true;
+              false: match(y1 == y2){
+                       true: true;
+                       false: z1 == z2;
+                     };
+            }
+          ];
+        };
+      ];
+    };
+  ];
+};
+
+l2 = [(x,y,z) |  x <- [0..4], y <- [0..4], z <- [0..4]];
+l3 = [(x,y,z) // x <- [0..4], y <- [0..4], z <- [0..4]];
+l4 = qsort2 cmp l3;
+
+print "<<l2>>: "; println l2 "";
+print "<<l3>>: "; println l3 "";
+print "<<l4>>: "; println l4 "";
+
+#
+# compare l2 l3
+#
+bool = true;
+loop {
+  from: [m1 = l2;      m2 = l3];
+  step: [m1 = m1 tail; m2 = m2 tail];
+  while: !(m1 isNil?);
+  do:
+    match(eq(m1 head, m2 head)){
+      false: [
+        bool = false;
+        break;
+      ];
+    };
+};
+
+match(bool){
+  true:  println "all equal. l2 & l3";
+  false: println "not equal. l2 & l3\81i\90³\89ð\81j";  # \90³\89ð
+};
+
+#
+# compare l2 l4
+#
+bool = true;
+loop {
+  from: [m1 = l2;      m2 = l4];
+  step: [m1 = m1 tail; m2 = m2 tail];
+  while: !(m1 isNil?);
+  do:
+    match(eq(m1 head, m2 head)){
+      false: [
+        bool = false;
+        break;
+      ];
+    };
+};
+
+match(bool){
+  true:  println "all equal. l2 & l4\81i\90³\89ð\81j";  # \90³\89ð
+  false: println "not equal. l2 & l4";
+};
+
+println "" "";
+
+#
+#
+fun cartesian_product(x, y){
+  do: [
+    [(a,b) // a <- x, b <- y]
+  ];
+};
+
+print "cartesian_product: "; println(cartesian_product([1..4], [5..7]));
+
+
+#
+#
+
+println "" "\96³\8cÀ\83\8a\83X\83g\82Ì\83e\83X\83g";
+l5 = [(x,y,z) // x <- [0..], y <- [0..], z <- [0..]];
+loop {
+  from: [i = 0, l6 = l5];
+  step: [i = i + 1, l6 = l6 tail];
+  while: i < 100;
+  do: print (l6 head) ", ";
+};
+
+println "" "\82T\8e\9f\8c³\82Ì\83e\83X\83g";
+println [(a,b,c,d,e) // a <- [0..3], b <- [0..3], c <- [0..3], d <- [0..3], e <- [0..3]];
+
diff --git a/src/test/local.sp b/src/test/local.sp
new file mode 100644 (file)
index 0000000..cdb4643
--- /dev/null
@@ -0,0 +1,39 @@
+
+fun for(init, cond, step, body){
+  do: [
+    loop {
+      from:  init each {arg:[dammy]; do: [];};
+      while: cond head;
+      step:  step each {arg:[dammy]; do: [];};
+      do:    body each {arg:[dammy]; do: [];};
+    };
+  ];
+};
+
+
+fun local(vars, body){
+  var: [ns];
+  do: [
+    ns = vars + {do: body;};
+    ns eval();
+  ];
+};
+
+
+i = 100;
+j = 200;
+
+local {i: 0; j: 0;}[
+  for [i = 0][i < 10][i = i + 1][
+    println i;
+    print "  ";
+    for [j = 0][j < 10][j = j + 1][
+      print j "  ";
+    ];
+    println "";
+  ];
+];
+
+print "i = "; println i;
+print "j = "; println j;
+
diff --git a/src/test/loop.sp b/src/test/loop.sp
new file mode 100644 (file)
index 0000000..04a244c
--- /dev/null
@@ -0,0 +1,41 @@
+
+i = 0;
+
+result =
+  loop test {
+    from: i=0;
+    step: i=i+1;
+    while: i < 10;
+    do: [
+      println i;
+      match(i == 5){
+        true: exit;
+      };
+    ];
+  };
+
+print "loop result = ";
+println result;
+
+result = 
+  loop outer {
+    from: i = 5;
+    while: i < 10;
+    do: [
+      loop inner {
+        step: i = i + 1;
+        until: i == 20;
+        do: [
+          println i;
+          match(i == 15){
+            true: outer.exit("success");
+          }
+        ];
+      };
+    ];
+  };
+
+print "loop result = ";
+println result;
+
+
diff --git a/src/test/map.sp b/src/test/map.sp
new file mode 100644 (file)
index 0000000..32d300a
--- /dev/null
@@ -0,0 +1,15 @@
+fun map(f,l){
+  do: match(l){
+        []:    [];
+        x::xs: f x :: map(f,xs);
+      };
+};
+
+fun add(x){
+  do: x + 1;
+};
+
+a = [1..5];
+
+print "map(add,a) = "; println (map(add, a)); # [2,3,4,5,6];
+
diff --git a/src/test/mix2.sp b/src/test/mix2.sp
new file mode 100644 (file)
index 0000000..82fa62c
--- /dev/null
@@ -0,0 +1,43 @@
+
+{
+  fun foo(x){
+    do: {
+          fun printIt(w){ do: show(w * 2); };
+          fun show(y){ do: println (x * y); };
+        };
+  };
+
+  fun bar(x){
+    do: {
+          fun printIt(w){ do: show(w * 3); };
+          fun show(y){ do: println (x + y); };
+        };
+  };
+
+  fun zot(obj){
+    do: [
+          obj + {
+            fun show(y){
+              do: match(y < 0){
+                    true: obj show (-y);
+                    false: obj show y;
+                  };
+            };
+          };
+        ];
+  };
+
+  fun init {
+    var: [myZot1, myZot2];
+    do: [
+      myZot1 = zot(foo(10));
+      myZot2 = zot(bar(20));
+      myZot1 printIt(-5);
+      myZot1 printIt(5);
+      myZot2 printIt(-7);
+      myZot2 printIt(7);
+    ];
+  };
+
+} init();
+
diff --git a/src/test/mixin.sp b/src/test/mixin.sp
new file mode 100644 (file)
index 0000000..a1fde29
--- /dev/null
@@ -0,0 +1,31 @@
+super_obj = {
+  name: "ansi common lisp";
+  writer: "paul";
+};
+
+child_obj = super_obj + {
+  publisher: "Pearson";
+};
+
+# Mixin \82·\82é\82±\82Æ\82É\82æ\82è\81A\93¯\96¼\82Ì\8d\80\96Ú\82Í\89B\82³\82ê\82é\81B
+another_obj = child_obj + {
+  name: "hack!";
+};
+
+#  rename 
+yet_another_obj = child_obj rename {name: $rename_name;} + {
+  name: "hack?";
+};
+
+print "super_obj: ";
+println super_obj;
+
+print "child_obj: ";
+println child_obj;
+
+print "another_obj: ";
+println another_obj;
+
+print "yet_another_obj: ";
+println yet_another_obj;
+
diff --git a/src/test/mutex.sp b/src/test/mutex.sp
new file mode 100644 (file)
index 0000000..ff97c1f
--- /dev/null
@@ -0,0 +1,61 @@
+aMutex = make_mutex();
+
+t1 = Thread start {
+  arg:[this_thread];
+  var:[i,j];
+  do: [
+    loop {
+      from: [i=0];
+      step: [i=i+1];
+      while: i < 10;
+      do: [
+        aMutex synchronize {  # \94r\91¼\90§\8cä
+          do: [
+            println "hello";
+            println "world";
+          ];
+        };
+        loop { # wait loop
+          from:[j=0];
+          step:[j = j + 1];
+          while: j < 100;
+          do: match(i == 5){
+                true: [this_thread quit];  # \83X\83\8c\83b\83h\82Ì\8fI\97¹
+              };
+        };
+      ];
+    };
+  ];
+};
+
+t2 = Thread start {
+  arg:[this_thread];
+  var:[i,j];
+  do: [
+    loop {
+      from: [i=0];
+      step: [i=i+1];
+      while: i < 10;
+      do: [
+        aMutex synchronize {  # \94r\91¼\90§\8cä
+          do: [
+            println "second thread<1>";
+            println "second thread<2>";
+          ];
+        };
+        loop { # wait loop
+          from:[j=0];
+          step:[j = j + 1];
+          while: j < 10;
+          do: [];
+        };
+      ];
+    };
+  ];
+};
+
+t1 join;  # \83X\83\8c\83b\83ht1\82Ì\8fI\97¹\82ð\91Ò\82Â
+println "t1 joined.\n";
+t2 join;  # \83X\83\8c\83b\83ht2\82Ì\8fI\97¹\82ð\91Ò\82Â
+println "t2 joined.\n";
+
diff --git a/src/test/prop.sp b/src/test/prop.sp
new file mode 100644 (file)
index 0000000..04d678c
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ *
+ * property sample
+ *
+ */
+
+a = {
+     private
+        b: 1;
+        fun getf(){do: b;};
+        fun setf(x){do: b = x;};
+     public
+        property c {
+            set: setf;
+            get: getf;
+        };
+    };
+
+println (a c);     # 1
+a c = 2;           # b <- 2
+println (a c);     # 2
+a c = 3;           # b <- 3
+println (a c);     # 3
+println a;         # print a
diff --git a/src/test/queen.sp b/src/test/queen.sp
new file mode 100644 (file)
index 0000000..d3e1942
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Mac OSX ÈǤǤÎÃí°Õ
+ *   ¤½¤Î¤Þ¤Þ¤Ç¤Ï¥¹¥¿¥Ã¥¯¤¬ÉÔ­¤·¤ÆÆ°¤«¤Ê¤¤¤Î¤Ç,
+ *   ¥¹¥¿¥Ã¥¯¥µ¥¤¥º¤òÂ礭¤¯¤·¤Æ¤«¤é¼Â¹Ô¤·¤Æ¤¯¤À¤µ¤¤¡£
+ *   ex.
+ *     (bash¤Î¾ì¹ç): ulimit -s 65535
+ */
+
+
+fun member(val, lst){
+  do: match(lst){
+        []: false;
+        x::xs: match(x == val){
+                 true:  true;
+                 false: member(val, xs);
+                };
+      };
+};
+
+fun queen(n:int){
+  do: [println "START" ""; queen1(n, 0, 0, [], [],[]); println "" "" "END"; false];
+};
+
+fun queen1(n, i, j, column, left, right){
+  var: temp;
+  do: [
+        match(i == n){
+          true: [ println ""; print_solution(n, column); false ];
+          false: [
+            match(j == n){
+              true: false;
+              false: [
+                match(member(j,column) or
+                   member(i + j, left) or
+                   member(i - j, right)){
+                  true:  queen1(n, i, j+1, column, left, right);
+                  false: [
+                    temp = queen1(n, i+1, 0, j :: column, (i+j) :: left, (i-j) :: right);
+                    match(temp){
+                      true:  true;
+                      false: queen1(n, i, j+1, column, left, right);
+                    };
+                  ];
+                };
+              ];
+            };
+          ];
+        };
+      ];
+};
+
+fun print_solution(n, x){
+  var: [y, i];
+  do: loop {
+        from: y = x;
+        step: y = y tail;
+        until: y == [];
+        do: [
+          println "";
+          loop {
+            from: i=0;
+            step: i=i+1;
+            until: i == (y head);
+            do: print ". ";
+          };
+          print "Q ";
+          loop {
+            from: i=0;
+            step: i=i+1;
+            until: i == (n - (y head) - 1);
+            do: print ". ";
+          };
+        ];
+      };
+};
+
+queen 8;
+
diff --git a/src/test/ssock.sp b/src/test/ssock.sp
new file mode 100644 (file)
index 0000000..3a66acc
--- /dev/null
@@ -0,0 +1,21 @@
+/* see also 'csock.sp' */
+
+/* server socket */
+
+/* open server socket */
+srv_sock = ServerSocket open(2000);
+match(srv_sock isNil?){
+  true: [ println "can't open server socket"; quit(); ];
+};
+
+println "init";
+sock = srv_sock accept;
+print "accept....";
+sock writeline "Hello!";
+println "message sended.";
+sock close;
+
+println "sock closed.";
+
+srv_sock close;
+
diff --git a/src/test/ssock2.sp b/src/test/ssock2.sp
new file mode 100644 (file)
index 0000000..8620d52
--- /dev/null
@@ -0,0 +1,40 @@
+/* see also 'csock2.sp' */
+
+/* server socket */
+
+/* init data */
+const bufsize = 5;
+buf1 = array:byte(bufsize);
+buf2 = array:byte(bufsize);
+buf3 = array:byte(bufsize);
+loop {
+  from: [i=0; j=0;];
+  step: [i=i+1; j=j+1;];
+  while: i < bufsize;
+  do: [
+    buf1 i = j;
+    buf2 i = j + bufsize;
+    buf3 i = j + (bufsize * 2);
+  ];
+};
+
+/* open server socket */
+srv_sock = ServerSocket open(2000);
+match(srv_sock isNil?){
+  true: [ println "can't open server socket"; quit(); ];
+};
+
+println "init";
+sock = srv_sock accept;
+print "accept....";
+send = sock send bufsize;
+send buf1;
+send buf2;
+send buf3;
+println "message sended.";
+sock close;
+
+println "sock closed.";
+
+srv_sock close;
+
diff --git a/src/test/thread.sp b/src/test/thread.sp
new file mode 100644 (file)
index 0000000..b3fbad0
--- /dev/null
@@ -0,0 +1,58 @@
+t1 = Thread start {
+  arg:[this_thread];
+  var:[i,j];
+  do: [
+    loop {
+      from: [i=0];
+      step: [i=i+1];
+      while: i < 10;
+      do: [
+        println "hello";
+        loop { # wait loop
+          from:[j=0];
+          step:[j = j + 1];
+          while: j < 100;
+          do: match(i == 5){
+                true: [this_thread quit];
+              };
+        };
+      ];
+    };
+  ];
+};
+
+t2 = Thread start {
+  arg:[this_thread];
+  var:[i,j];
+  do: [
+    loop {
+      from: [i=0];
+      step: [i=i+1];
+      while: i < 10;
+      do: [
+        println "second thread";
+        loop { # wait loop
+          from:[j=0];
+          step:[j = j + 1];
+          while: j < 10;
+          do: [];
+        };
+      ];
+    };
+  ];
+};
+
+t1 join;
+println "t1 joined.\n";
+t2 join;
+println "t2 joined.\n";
+
+/*
+loop {  # wait loop
+  from: [i=0];
+  step: [i = i + 1];
+  while: i < 10000;
+  do: [];
+};
+*/
+
diff --git a/src/test/wiki.cgi b/src/test/wiki.cgi
new file mode 100644 (file)
index 0000000..f2667a5
--- /dev/null
@@ -0,0 +1,974 @@
+#!/home/groups/s/so/soopy/soopy
+#!/usr/local/bin/soopy
+#
+# SoopyWiki Version 1.0
+#
+# wiki.cgi
+#
+# Copyright (C) 2003 by SUZUKI Jun.
+# <randy@users.sourceforge.jp>
+# http://soopy.sourceforge.jp/
+#
+# $Id: wiki.cgi,v 1.44 2007/01/30 05:21:59 randy Exp $
+#
+
+  #########################
+  # ½é´üÀßÄê
+  #########################
+
+  dbdir      = "spwiki/";
+  baseurl    = "http://soopy.sourceforge.jp/cgi-bin/";
+  cgi_name   = "wiki.cgi";  # ¤³¤Î£Ã£Ç£É¤Î¥Õ¥¡¥¤¥ë̾
+  frontpage  = "FrontPage"; # FrontPage¤Îɽ¼¨Ì¾
+  recentpage = "Recent";    # Recent¤Î¥¿¥¤¥È¥ë̾
+  indexpage  = "Index";     # Index¤Î¥¿¥¤¥È¥ë̾
+  errorpage  = "Error";     # Error¤Î¥¿¥¤¥È¥ë̾
+  naviwrite  = "Write";     # Write¤Î¥¿¥¤¥È¥ë̾
+  naviedit   = "Edit";      # Edit¤Î¥Ê¥Ó¥²¡¼¥¿É½¼¨Ì¾
+  navirecent = "Recent";    # Recent¤Î¥Ê¥Ó¥²¡¼¥¿É½¼¨Ì¾
+  naviindex  = "Index";     # Index¤Î¥Ê¥Ó¥²¡¼¥¿É½¼¨Ì¾
+  navi_rss   = "RSS";       # RSS¤Î¥Ê¥Ó¥²¡¼¥¿É½¼¨Ì¾
+  use_rss    = true;        # RSS¤ò»È¤¦¤«¤É¤¦¤«
+  msgdeleted = " is deleted.";
+  msgforspam = " spam?";
+  editchar   = "?";
+  cols = 80;                 # Edit»þ¤Î¥Æ¥­¥¹¥È¥¨¥ê¥¢¤Î·å¿ô
+  rows = 20;                 # Edit»þ¤Î¥Æ¥­¥¹¥È¥¨¥ê¥¢¤Î¹Ô¿ô
+  recents    = 10;           # Recent»þ¤Ëɽ¼¨¤¹¤ë¥¿¥¤¥È¥ë¿ô
+  titlecolor = "#F0E0E7";    # Wiki¥¿¥¤¥È¥ë¤Î¿§
+  bgcolor    = "white";      # background¿§
+  rss = {
+    file:  "../htdocs/wiki/rss.rdf";   # RSS¥Õ¥¡¥¤¥ë̾
+    #file:  "rss.rdf";   # RSS¥Õ¥¡¥¤¥ë̾
+    #location: "http://soopy.sourceforge.jp/wiki/rss.rdf";
+    location: "http://soopy.sourceforge.jp/cgi-bin/wiki.cgi?cmd=rss";
+    title: "Soopy";
+    link:  "http://soopy.sourceforge.jp/wiki/";
+    description: "Soopy";
+    max_item: 15;
+    TZ: "+09:00";
+  };
+  style = "
+<style type=\"text/css\">
+<!--
+pre     { line-height: 130% }
+a       {}
+a:hover {
+          color: red;
+          background-color: white;
+          text-decoration: underline
+        }
+h2      { text-align: left;
+          border: #b9a 1px solid;
+          color: black;
+          background: #f0e0e7;
+          padding: .3em .5em .2em .5em;
+        }
+h3      { text-align: left;
+          border-bottom: #b9a 1px solid;
+          color: black;
+          background: #f0e0e7;
+          padding: .2em .5em .0em .5em;
+        }
+-->
+</style>
+";  # ¥¹¥¿¥¤¥ë¡¡¤³¤³¤Þ¤Ç
+
+  # contenttype = "Content-type: text/html; charset=Shift_JIS";
+  contenttype = "Content-type: text/html; charset=euc-jp";
+  rss_contenttype = "Content-type: text/xml; charset=euc-jp";
+
+  #####################
+  # ½é´üÀßÄê¡¡¤³¤³¤Þ¤Ç
+  #####################
+
+  KANJI_DECODER = Japanese;
+
+
+  /*
+   * utility routines
+   */
+
+  fun with_openIn_file(filename, body){
+    comment: "open input-file & eval body & close file";
+    var: [fin];
+    do: [
+      fin = openIn filename;
+      body eval(fin);
+      fin close;
+    ];
+    rescue: [
+      match(fin isNil?){
+        false: fin close;
+      };
+    ];
+  };
+
+  fun with_openOut_file(filename, body){
+    comment: "open output-file & eval body & close file";
+    var: [fout];
+    do: [
+      fout = openOut filename;
+      body eval(fout);
+      fout close;
+    ];
+    rescue: [
+      match(fout isNil?){
+        false: fout close;
+      };
+    ];
+  };
+
+  fun with_openAppend_file(filename, body){
+    comment: "open output-file for append & eval body & close file";
+    var: [fout];
+    do: [
+      fout = openAppend filename;
+      body eval(fout);
+      fout close;
+    ];
+    rescue: [
+      match(fout isNil?){
+        false: fout close;
+      };
+    ];
+  };
+
+  fun add_line(x, y){
+    do: x + "\n" + y;
+  };
+
+  fun encode_url(url:string){
+    var: [reader];
+    do: [
+      reader = EucJP encoderIn (url reader);
+      reader = URLencoder encoderIn reader;
+      reader readline;
+    ];
+  };
+
+  fun make_link(url:string){
+    var: [list, mail, name, link];
+    do: [
+      list = url split1 ':';
+      match(list head){
+        "http":  "<a href=\"" + url + "\">" + url + "</a>";
+        "https": "<a href=\"" + url + "\">" + url + "</a>";
+        "ftp":   "<a href=\"" + url + "\">" + url + "</a>";
+        "mailto": [
+            mail = list nth 1;
+            "<a href=\"" + url + "\">" + mail + "</a>";
+          ];
+        other: [
+          let [name, link] = url split1 '|';
+          match(link){
+            "": [
+              match((database get url length) == 0){
+                true: url + "<a href=\"" + cgi_name + "?cmd=edit&mypage=" + (encode_url url) + "\">" + editchar + "</a>";
+                false: "<a href=\"" + cgi_name + "?cmd=read&mypage=" + (encode_url url) + "\">" + url + "</a>";
+              };
+            ];
+            else: [
+                "<a href=\"" + link + "\">" + name + "</a>";
+            ];
+          };
+        ];
+      };
+    ];
+  };
+
+  fun convert_link(line){
+    var: [f, g, start, end, prev, res];
+    do: [
+      loop {
+        from: [
+          start = 0;
+          prev = 0;
+          f = line find "[[";
+          g = line find "]]";
+          res = "";
+        ];
+        step: [
+          start = end + 2;
+          prev = start;
+        ];
+        do: [
+          start = f start;
+          match(start >= 0){
+            false: [
+              res = res + (line sub prev ((line length) - prev));
+              exit;
+            ];
+            true: [
+              end = g start;
+              match(end >= 0){
+                true: [
+                  res = res + (line sub prev (start - prev))
+                            + (make_link (line sub (start+2) (end - (start+2))));
+                ];
+              };
+            ];
+          };
+        ];
+      };
+      res;
+    ];
+  };
+
+  fun tag_convert(line){
+    do: [
+      match(line length > 0){
+        true: [
+          match(line nth 0){
+            '*': [
+               match((line length) >= 2){
+                 true: [
+                   match(line nth 1){
+                     '*': line = "<H3>" + (line sub 2 (line length - 2)) + "</H3>\n";
+                     _:   line = "<H2>" + (line sub 1 (line length - 1)) + "</H2>\n";
+                   };
+                 ];
+               };
+            ];
+            _: [
+              match((line length) >= 4){
+                true: [
+                  match(line sub 0 4){
+                    "----": line = "<HR>\n";
+                    _: [
+                      line = convert_link line;
+                      line = line + "\n";
+                    ];
+                  };
+                ];
+                false: [
+                  line = line + "\n";
+                ];
+              };
+            ];
+          };
+        ];
+        false: [ # null line
+              line = "\n";
+        ];
+      };
+      line;
+    ];
+  };
+
+  fun print_content(){
+    var: [temp];
+    do: [
+      temp = escape(database get (form "mypage"));
+
+      reader = temp reader;
+      temp = "";
+      loop {
+        until: reader eof?;
+        do: [
+          line = reader readline;
+          line = tag_convert line;
+          temp = temp + line;
+        ];
+      };
+
+      print "<pre>" temp; println "</pre>";
+    ];
+  };
+
+  fun escape(str:string){
+    do: [
+      str = str replace "&" "&amp;";
+      str = str replace "<" "&lt;";
+      str = str replace ">" "&gt;";
+      str = str replace "\"" "&quot;";
+      str;
+    ];
+  };
+
+  fun print_footer(){
+    do: [
+      println "</body></html>";
+    ];
+  };
+
+  fun print_header(title:string, canedit:bool){
+    do: [
+      println contenttype;
+      println "";
+      println "<html>";
+      println ("<head><title>" + title + "</title>");
+      println ("  <link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"" + (rss location) + "\" />");
+      println style;
+      println "</head>";
+      println ("<body bgcolor=\"" + bgcolor + "\">");
+      println ("  <table width=\"100%\" bgcolor=\"" + titlecolor + "\" border=\"0\">");
+      println ("    <tr valign=\"top\">");
+      println ("      <td><b><tt>" + title + "</tt></b></td>");
+      println "      <td align=\"right\"><tt>";
+      println ("        <a href=\"" + cgi_name + "?cmd=read&mypage=" + (encode_url frontpage) + "\">" + frontpage + "</a> | ");
+      println ("        <a href=\"" + cgi_name + "?cmd=new\">New</a> | ");
+      match(canedit){
+        true: [
+          println ("        <a href=\"" + cgi_name + "?cmd=edit&mypage=" + (encode_url (form "mypage")) + "\">" + naviedit + "</a> | ");
+        ];
+      };
+      println ("        <a href=\"" + cgi_name + "?cmd=recent\">" + navirecent + "</a> | ");
+      match(use_rss){
+        true: [
+          println ("        <a href=\"" + (rss location) + "\">" + navi_rss + "</a> | ");
+        ];
+      };
+      println ("        <a href=\"" + cgi_name + "?cmd=index\">" + naviindex + "</a> | ");
+      println ("        <a href=\"http://soopy.sourceforge.jp/wiki/\">Soopy Wiki</a>");
+      println "      </tt></td>";
+      println "    </tr>";
+      println "  </table>";
+    ];
+  };
+
+  fun print_error(msg:string){
+    do: [
+      print_header(errorpage, false);
+      print ("<h1>" + msg + "</h1>");
+      print_footer();
+      quit();
+    ];
+  };
+
+  #
+  # RSS
+  #
+
+  fun print_rss_header(fout){
+    do: [
+      fout writeline "<?xml version=\"1.0\" encoding=\"EUC-JP\" ?>";
+      fout writeline "<rdf:RDF";
+      fout writeline "  xmlns=\"http://purl.org/rss/1.0/\"";
+      fout writeline "  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"";
+      fout writeline "  xmlns:dc=\"http://purl.org/dc/elements/1.1/\"";
+      fout writeline "  xml:lang=\"ja\">";
+    ];
+  };
+
+  fun print_rss_channel(fout, lines){
+    var: [i, item];
+    do: [
+      fout writeline ("  <channel rdf:about=\"" + (rss link) + "\">");
+      fout writeline ("    <title>" + (rss title) + "</title>");
+      fout writeline ("    <link>" + (rss link) + "</link>");
+      fout writeline ("    <description>" + (rss description) + "</description>");
+      fout writeline  "    <items>";
+      fout writeline  "      <rdf:Seq>";
+      loop {
+        from: i = 0;
+        step: i = i + 1;
+        while: (i < (rss max_item)) and (!(lines isNil?));
+        do: [
+          item = lines head;
+          print_channel_item fout item;
+          lines = lines tail;
+        ];
+      };
+      fout writeline  "      </rdf:Seq>";
+      fout writeline  "    </items>";
+      fout writeline  "  </channel>" "";
+    ];
+  };
+
+  fun make_rss_item_url(item){
+    var: [name, ext];
+    do: [
+      let [name, ext] = item split1('.');
+      baseurl + cgi_name + "?cmd=read&amp;mypage=" + (encode_url name);
+    ];
+  };
+
+  fun print_channel_item(fout, item){
+    do: [
+      fout writeline ("        <rdf:li rdf:resource=\"" + (make_rss_item_url item) + "\" />");
+    ];
+  };
+
+  fun print_rss_items(fout, lines){
+    var: [i, item];
+    do: [
+      loop {
+        from: i = 0;
+        step: i = i + 1;
+        while: (i < (rss max_item)) and (!(lines isNil?));
+        do: [
+          item = lines head;
+          print_rss_anItem fout item;
+          lines = lines tail;
+        ];
+      };
+    ];
+  };
+
+  fun print_rss_anItem(fout, item){
+    var: [url, name, ext, t, day, tm, retried];
+    do: [
+      url = make_rss_item_url item;
+      let [name, ext] = item split1('.');
+      let [ext, t]    = ext  split1('.');
+      let [day, tm]   = t split1(' ');
+      fout writeline ("  <item rdf:about=\"" + url + "\">");
+      fout writeline ("    <title>" + name + "</title>");
+      fout writeline ("    <link>" + url + "</link>");
+      fout writeline ("    <description>" + (rss description) + ":" + name + "(" + t + ")" + "</description>");
+      fout writeline ("    <dc:date>" + day + "T" + tm + (rss TZ) + "</dc:date>");
+      fout writeline ("  </item>");
+      fout writeline  "";
+    ];
+    rescue: [
+      match(retried isNil?){
+        true: [
+          line = line + ".2000-1-1 0:0:0";
+          retried = true;
+          retry;
+        ];
+      }
+    ];
+  };
+
+  fun print_rss_footer(fout){
+    do: [
+      fout writeline "</rdf:RDF>";
+    ];
+  };
+
+  fun make_rss(lines){
+    do: [
+      with_openOut_file(rss file){
+        arg: [fout];
+        do: [
+          print_rss_header(fout);
+          print_rss_channel fout lines;
+          print_rss_items fout lines;
+          print_rss_footer(fout);
+        ];
+      };
+    ];
+  };
+
+/*
+ * Main Object
+ */
+{
+  /*
+   * variables
+   */
+  form:     {};
+  database: nil;
+
+  /*
+   * Databse
+   */
+
+  db: {
+   private
+
+    index_file: "wiki.index";
+    index: {}; # key: WikiName, value: (Version, datetime)
+
+    # each line: key.version.datetime
+
+    fun find(key){
+      var: [str, values, ver, file_datetime];
+      do: [
+        let values = index lookup key;
+        match(values isNil?){
+          true: ("", false);
+          false: [
+            let (ver, file_datetime) = values;
+            with_openIn_file (dbdir + key + "." + ver) {
+              arg: [fin];
+              var: [list];
+              do: [
+                list = fin readLines;
+                str = list foldl add_line;
+              ];
+            };
+            (str, true);
+          ];
+        };
+      ];
+    };
+
+    fun append_index(line:string){
+      var: [name, ver, t, retried];
+      do: [
+        # let [filename, ext] = line split1(',');
+        let [name, ver] = line split1('.');
+        let [ver, t] = ver split1('.');
+        index append name (ver, t);
+      ];
+      rescue: [
+        match(retried isNil?){
+          true: [
+            line = line + ".2000-1-1 0:0:0";
+            retried = true;
+            retry;
+          ];
+        }
+      ];
+    };
+
+    fun update_index(key:string, ver:string){
+      var: [idx, data];
+      do: [
+        with_openIn_file (dbdir + index_file) {
+          arg: [fin];
+          do: [
+            idx = fin readlines;
+          ];
+        };
+        data = key + "." + ver + "." + (datetime now toString);
+        match((index lookup key) isNil?){
+          true:  idx = data :: idx;
+          false: idx = data :: (idx filter (not_eq_key key));
+        };
+        with_openOut_file (dbdir + index_file) {
+          arg: [fout];
+          do: [
+            fout writelines idx;
+          ];
+        };
+        match(use_rss){
+          true: make_rss idx;
+        };
+        # update var 'index'
+        index = {};
+        idx map append_index;
+      ];
+    };
+
+    fun line2tuple(str:string){
+      var: [key, ext, t, retried];
+      do: [
+        let [key, ext] = str split1('.');
+        let [ext, t]   = ext split1('.');
+        (key, ext, t);
+      ];
+      rescue: [
+        match(retried isNil?){
+          true: [
+            str = str + ".2000-1-1 0:0:0";
+            retried = true;
+            retry;
+          ];
+        }
+      ];
+    };
+
+   public
+
+    fun get_indexes(){
+      var: [lines, tuples];
+      do: [
+        with_openIn_file (dbdir + index_file) {
+          arg: [fin];
+          var: [i, line, key, rest];
+          do: [
+            lines = fin readlines;
+            tuples = lines map line2tuple;
+          ];
+        };
+        tuples;
+      ];
+    };
+
+    fun cut_ext(filename:string){
+      var: [name, ext];
+      do: [
+        let [name, ext] = filename split1('.');
+        name;
+      ];
+    };
+
+    fun get_keys(){
+      var: [dlist];
+      do: [
+        dlist = index keys;
+        dlist map cut_ext;
+      ];
+    };
+
+    fun not_eq_key(key, key2){
+      var: [name, ext];
+      do: [
+        match(key2 split1('.')){
+          [name, ext]: key != name;
+          _: true;
+        }
+      ];
+    };
+
+    fun delete(key){
+      var: [idx];
+      do: [
+        with_openIn_file (dbdir + index_file) {
+          arg: [fin];
+          do: [
+            idx = fin readlines;
+            idx = idx filter (not_eq_key key);
+          ];
+        };
+        with_openOut_file (dbdir + index_file) {
+          arg: [fout];
+          do: [
+            fout writelines idx;
+          ];
+        };
+        # update var 'index'
+        index = {};
+        idx map append_index;
+      ];
+    };
+
+    fun set(key, value){
+      var: [ver, filename, t];
+      do: [
+        ver = index lookup key;
+        match(ver isNil?){
+          true: [
+            ver = "1";
+          ];
+          false: [
+            let (ver, t) = ver;
+            ver = (ver toInt + 1) toString;
+          ];
+        };
+        filename = key + "." + ver;
+        with_openOut_file (dbdir + filename) {
+          arg: [fout];
+          do: [
+            fout write value;
+          ];
+        };
+        update_index(key, ver);
+      ];
+    };
+
+    fun get(key){
+      var: [found, str];
+      do: [
+        let (str, found) = find key;
+        match(found){
+          true:  str;
+          false: "";
+        };
+      ];
+    };
+
+    fun open(){
+      var: [filelist];
+      do: [
+        with_openIn_file (dbdir + index_file) {
+          arg: [fin];
+          do: [
+            filelist = fin readlines;
+            filelist map append_index;
+          ];
+        };
+      ];
+    };
+
+    fun close(){
+    };
+
+  }; /* end db */
+
+
+  /*
+   * Main Program
+   */
+
+  fun init_form(){
+    var: [query, pairs];
+    do: [
+      match(Env "REQUEST_METHOD"){
+        "GET":  [query = Env "QUERY_STRING"];
+        "POST": [query = STDIN read(Env "CONTENT_LENGTH" toInt)];
+      };
+      pairs = query split('&');
+      pairs each {
+        arg: [pair];
+        var: [key, value, reader];
+        do: [
+          let [key, value] = pair split1('=');
+          value = value tr '+' ' ';
+          reader = value reader; # get string reader;
+          reader = URLencoder decoderIn reader;
+          reader = KANJI_DECODER decoderIn reader;
+          reader = CRLF2LF encoderIn reader;
+          value = reader readlines;
+          match(value isNil?){
+            true:  value = "";
+            false: value = value foldl add_line;
+          };
+          form append (key, value);
+        ];
+      };
+    ];
+  };
+
+  fun check_spam(){
+    comment: "if maybe spam, return true.";
+    var: [addr];
+    do: [
+      addr = Env "REMOTE_ADDR";
+      match(addr isNil?){
+        true: true;
+        false: [
+
+          match((addr length) > 3){
+            false: true;
+            true: [
+              match((addr find ".jp" 0) < 0){
+                false: false;
+                true: [
+                  addr = Socket getname addr;
+                  (addr find ".jp" 0) < 0;
+                ];
+              };
+            ];
+          };
+        ];
+      };
+
+    ];
+  };
+
+  fun write_log(){
+    comment: "write access log.";
+    var: [log_file, addr, remote];
+    do: [
+      log_file = "write.log";
+      remote = Env "REMOTE_ADDR";
+      addr = Socket getname remote;
+#      log_file = "spwiki/" + log_file;
+#      with_openAppend_file (dbdir + log_file) {
+      with_openAppend_file (log_file) {
+        arg: [fout];
+        do: [
+          match(addr isNil?){
+            true: fout writeline ((form "mypage") + ": " + remote);
+            false: fout writeline ((form "mypage") + ": " + remote + ": " + addr);
+          };
+        ];
+      };
+    ];
+  };
+
+  fun do_write(){
+    do: [
+      write_log();
+
+      match(check_spam()){
+        true: [
+          print_header((form "mypage") + msgforspam, false);
+          print "<p>";
+          print "Can't write page without from '.jp'.";
+          println "</p>";
+        ];
+        false: [
+          match(form "mymsg"){
+            "": [
+                database delete (form "mypage");
+                print_header((form "mypage") + msgdeleted, false);
+              ];
+            else: [
+                database set((form "mypage"), (form "mymsg"));
+                print_header(form "mypage", true);
+                print_content();
+              ];
+          };
+        ];
+      };
+      print_footer();
+    ];
+  };
+
+/*
+  fun do_write(){
+    do: [
+      #match(form "mymsg" isNil?){
+      match(form "mymsg"){
+        "": [
+            database delete (form "mypage");
+            print_header((form "mypage") + msgdeleted, false);
+          ];
+        else: [
+            database set((form "mypage"), (form "mymsg"));
+            print_header(form "mypage", true);
+            print_content();
+          ];
+      };
+      print_footer();
+    ];
+  };
+*/
+
+  fun do_index(){
+    do: [
+      print_header(indexpage, false);
+      println "<ul>";
+      database get_keys() sort each {
+        arg: [key];
+        do: [
+          print "<li><a href=\"" cgi_name "?cmd=read&mypage=" (encode_url key) "\"><tt>" key "</tt></a></li>";
+          println "";
+        ];
+      };
+      println "</ul>";
+      print_footer();
+    ];
+  };
+
+  fun do_edit(){
+    var: [mymsg];
+    do: [
+      print_header(form "mypage", false);
+      mymsg = escape(database get (form "mypage"));
+
+      println ("<form action=\"" + cgi_name + "\" method=\"POST\">");
+      println ("  <input type=\"hidden\" name=\"cmd\" value=\"write\">");
+      println ("  <input type=\"hidden\" name=\"mypage\" value=\"" + (form "mypage") + "\">");
+      println ("  <input type=\"submit\" value=\"" + naviwrite + "\"><br>");
+      println ("  <textarea cols=\"" + (cols toString)
+               + "\" rows=\"" + (rows tostring)
+               + "\" name=\"mymsg\" wrap=\"virtual\">" + mymsg
+               + "</textarea><br>");
+      println ("  <input type=\"submit\" value=\"" + naviwrite + "\">");
+      println "</form>";
+
+      println "<H1>¥Æ¥­¥¹¥ÈÀ°·Á¤Î¥ë¡¼¥ë</H1>";
+      println "Ä̾ï¤ÏÆþÎϤ·¤¿Ê¸»ú¤¬¤½¤Î¤Þ¤ÞÆþÎϤµ¤ì¤Þ¤¹¡£<br>";
+      println "¥¿¥°¤Ï»ÈÍѤǤ­¤Þ¤»¤ó¡£<br>";
+      println "<br>";
+      println "¥Þ¥¤¥Ê¥¹£´¸Ä(----)¤ò¹ÔƬ¤Ë½ñ¤¯¤È¿åÊ¿Àþ¤Ë¤Ê¤ê¤Þ¤¹¡£<br>";
+      println "¥¢¥¹¥¿¥ê¥¹¥¯(*)¤ò¹ÔƬ¤Ë½ñ¤¯¤ÈÂ縫½Ð¤·¤Ë¤Ê¤ê¤Þ¤¹¡£<br>";
+      println "¥¢¥¹¥¿¥ê¥¹¥¯£²¸Ä(**)¤ò¹ÔƬ¤Ë½ñ¤¯¤È¾®¸«½Ð¤·¤Ë¤Ê¤ê¤Þ¤¹¡£<br>";
+      println "£²½Å¤ÎÂç³ç¸Ì[[]]¤Ç¤¯¤¯¤Ã¤¿Ê¸»úÎó¤ò½ñ¤¯¤È¡¢¥ê¥ó¥¯¤Ë¤Ê¤ê¤Þ¤¹¡£<br>";
+      println "[[]]¤Î¤Ê¤«¤Ç¥Ð¡¼(|)¤Ç¶èÀÚ¤ë¤È¥Ð¡¼¤ÎÁ°¤¬É½¼¨Ì¾¡¢¸å¤í¤¬¥ê¥ó¥¯À襢¥É¥ì¥¹¤Ë¤Ê¤ê¤Þ¤¹¡£<br>";
+      println "<br>";
+
+      print_footer();
+    ];
+  };
+
+  fun do_read(){
+    do: [
+      print_header(form "mypage", true);
+      print_content();
+      print_footer();
+    ];
+  };
+
+  fun do_new(){
+    do: [
+      print_header("Create New Page", false);
+      println "<br><br>";
+      println "ºîÀ®¤¹¤ë¥Ú¡¼¥¸Ì¾¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£";
+      println ("<form action=\"" + cgi_name + "\" method=\"POST\">");
+      println ("  <input type=\"hidden\" name=\"cmd\" value=\"edit\">");
+      println ("  <input type=\"text\" name=\"mypage\" size=\"20\">");
+      println ("  <input type=\"submit\" value=\"" + naviwrite + "\"><br>");
+      println "</form>";
+      print_footer();
+    ];
+  };
+
+  fun do_recent(){
+    var: [key, ver, t, tuples, i];
+    do: [
+      print_header(recentpage, false);
+      println "<ul>";
+
+      tuples = database get_indexes();
+      loop {
+        from: i = 0;
+        step: [i = i + 1; tuples = tuples tail];
+        while: (i < recents) and (! (tuples isNil?));
+        do: [
+          let (key, ver, t) = tuples head;
+          print "<li><a href=\"" cgi_name "?cmd=read&mypage=" (encode_url key) "\"><tt>" key "</tt></a> (" t ")</li>";
+          println "";
+        ];
+      };
+
+      println "</ul>";
+      print_footer();
+    ];
+  };
+
+  fun do_rss(){
+    var: [lines];
+    do: [
+      with_openIn_file(rss file){
+        arg: [fin];
+        do: [
+          lines = fin readLines;
+        ];
+      };
+      println rss_contenttype;
+      println "";
+      lines each {
+        arg: [line];
+        do: [
+          println line;
+        ];
+      };
+    ];
+  };
+
+  fun open_database(){
+    do: [
+      database = db;
+      database open();
+    ];
+  };
+
+  fun close_database(){
+    do: [
+      database close();
+    ];
+  };
+
+  #
+  # main program
+  #
+  fun main(){
+    do: [
+      init_form();
+
+      #### database open ####
+      open_database();
+
+      match(form "cmd"){
+        "read":   do_read();
+        "write":  do_write();
+        "edit":   do_edit();
+        "index":  do_index();
+        "new":    do_new();
+        "recent": do_recent();
+        "rss":    do_rss();
+        other: [
+          form "mypage" = frontpage;
+          do_read();
+        ];
+      };
+
+      #### database close ####
+      close_database();
+
+    ];
+    rescue: [
+      print_header("Soopy Error", false);
+      print_footer();
+    ];
+  };
+
+} main();