OSDN Git Service

sublexer.cppに定義されていたlexerの再定義が完了したため、削除。
authorderui <derutakayu@user.sourceforge.jp>
Tue, 19 Jan 2010 14:51:36 +0000 (23:51 +0900)
committerderui <derutakayu@user.sourceforge.jp>
Tue, 19 Jan 2010 14:51:36 +0000 (23:51 +0900)
lexer_dispatcherの存在意義が消えたため、削除。
safe boolをクラスに持たせるためのlib/bool_comparebleを追加。
lib/counterが不要であったまえ削除。削除。
term_checkerに、comment用のtermを追加。
comment_lexerを追加。

19 files changed:
Makefile
Rakefile
config.log
config.status
lib/any.h
lib/bool_compareble.h [new file with mode: 0755]
lib/counter.h [deleted file]
lib/crtp.h
lib/textarrayformat.h
src/lexer/comment_lexer.cpp [new file with mode: 0755]
src/lexer/comment_lexer.h [new file with mode: 0755]
src/lexer/lexer_dispatcher.cpp [deleted file]
src/lexer/lexer_dispatcher.h [deleted file]
src/lexer/sublexer_impl.cpp.bk [deleted file]
src/lexer/term_checker.cpp
src/lexer/term_checker.h
test/comment_lexer_test.cpp [new file with mode: 0755]
test/lexer_dispatcher_test.cpp.bk [deleted file]
test/sublexer_test.cpp.bk [deleted file]

index b102303..e52a6a9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -69,11 +69,11 @@ DIST_ARCHIVES = $(distdir).tar.gz
 GZIP_ENV = --best
 distuninstallcheck_listfiles = find . -type f -print
 distcleancheck_listfiles = find . -type f -print
-ACLOCAL = ${SHELL} /home/derui/develop/utakata/missing --run aclocal-1.10
-AMTAR = ${SHELL} /home/derui/develop/utakata/missing --run tar
-AUTOCONF = ${SHELL} /home/derui/develop/utakata/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/derui/develop/utakata/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/derui/develop/utakata/missing --run automake-1.10
+ACLOCAL = ${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run aclocal-1.10
+AMTAR = ${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run tar
+AUTOCONF = ${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run autoconf
+AUTOHEADER = ${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run autoheader
+AUTOMAKE = ${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run automake-1.10
 AWK = gawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
@@ -83,16 +83,16 @@ CPPFLAGS =
 CXX = g++
 CXXDEPMODE = depmode=gcc3
 CXXFLAGS = -g -O2
-CYGPATH_W = echo
+CYGPATH_W = cygpath -w
 DEFS = -DHAVE_CONFIG_H
 DEPDIR = .deps
 ECHO_C = 
 ECHO_N = -n
 ECHO_T = 
 EGREP = /bin/grep -E
-EXEEXT = 
+EXEEXT = .exe
 GREP = /bin/grep
-INSTALL = /usr/bin/install -c
+INSTALL = /bin/install -c
 INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
@@ -101,7 +101,7 @@ LDFLAGS =
 LIBOBJS = 
 LIBS = 
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /home/derui/develop/utakata/missing --run makeinfo
+MAKEINFO = ${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run makeinfo
 MKDIR_P = /bin/mkdir -p
 OBJEXT = o
 PACKAGE = utakata
@@ -115,10 +115,10 @@ SET_MAKE =
 SHELL = /bin/sh
 STRIP = 
 VERSION = 0.0.1
-abs_builddir = /home/derui/develop/utakata
-abs_srcdir = /home/derui/develop/utakata
-abs_top_builddir = /home/derui/develop/utakata
-abs_top_srcdir = /home/derui/develop/utakata
+abs_builddir = /cygdrive/c/meadow/develop/utakata
+abs_srcdir = /cygdrive/c/meadow/develop/utakata
+abs_top_builddir = /cygdrive/c/meadow/develop/utakata
+abs_top_srcdir = /cygdrive/c/meadow/develop/utakata
 ac_ct_CC = gcc
 ac_ct_CXX = g++
 am__include = include
@@ -138,7 +138,7 @@ host_alias =
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = $(SHELL) /home/derui/develop/utakata/install-sh
+install_sh = $(SHELL) /cygdrive/c/meadow/develop/utakata/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
index c592350..26f8e3f 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -22,9 +22,9 @@ TEST_SRCS = FileList["./test/*.cpp"]
 TEST_OBJECTS = TEST_SRCS.ext("o")
 TEST_OBJECTS.include(OBJS)
 TEST_DEPS = TEST_SRCS.ext("mf")
-TEST_PROGRAMS = TEST_SRCS.ext("")
+TEST_PROGRAMS = TEST_SRCS.ext(".exe")
 
-EXEEXT = ""
+EXEEXT = ".exe"
 
 # lists of clean objects
 CLEAN.include(OBJS, TEST_OBJECTS)
index 34ea0ab..e885965 100644 (file)
@@ -10,16 +10,16 @@ generated by GNU Autoconf 2.63.  Invocation command line was
 ## Platform. ##
 ## --------- ##
 
-hostname = vaio_z
+hostname = c2007
 uname -m = i686
-uname -r = 2.6.32-gentoo-r1
-uname -s = Linux
-uname -v = #2 SMP Wed Jan 13 20:45:37 JST 2010
+uname -r = 1.7.1(0.218/5/3)
+uname -s = CYGWIN_NT-5.0
+uname -v = 2009-12-07 11:48
 
-/usr/bin/uname -p = Intel(R) Core(TM)2 Duo CPU P8800 @ 2.66GHz
+/usr/bin/uname -p = unknown
 /bin/uname -X     = unknown
 
-/bin/arch              = unknown
+/bin/arch              = i686
 /usr/bin/arch -k       = unknown
 /usr/convex/getsysinfo = unknown
 /usr/bin/hostinfo      = unknown
@@ -27,7 +27,9 @@ uname -v = #2 SMP Wed Jan 13 20:45:37 JST 2010
 /usr/bin/oslevel       = unknown
 /bin/universe          = unknown
 
+PATH: /cygdrive/d/Program Files/OMake/bin
 PATH: /home/derui/bin
+PATH: /usr/local/stow/bin
 PATH: /usr/local/bin
 PATH: /usr/local/sbin
 PATH: /usr/sbin
@@ -44,7 +46,7 @@ PATH: /usr/X11R6/bin
 ## ----------- ##
 
 configure:1883: checking for a BSD-compatible install
-configure:1951: result: /usr/bin/install -c
+configure:1951: result: /bin/install -c
 configure:1962: checking whether build environment is sane
 configure:2005: result: yes
 configure:2030: checking for a thread-safe mkdir -p
@@ -55,11 +57,11 @@ configure:2109: result: gawk
 configure:2120: checking whether make sets $(MAKE)
 configure:2142: result: yes
 configure:2386: checking for g++
-configure:2402: found /usr/bin/g++
+configure:2402: found /bin/g++
 configure:2413: result: g++
 configure:2440: checking for C++ compiler version
 configure:2448: g++ --version >&5
-g++ (Gentoo 4.3.4 p1.0, pie-10.1.5) 4.3.4
+g++ (GCC) 4.3.4 20090804 (release) 1
 Copyright (C) 2008 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -67,10 +69,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 configure:2452: $? = 0
 configure:2459: g++ -v >&5
 Using built-in specs.
-Target: i686-pc-linux-gnu
-Configured with: /var/tmp/portage/sys-devel/gcc-4.3.4/work/gcc-4.3.4/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.4 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.4 p1.0, pie-10.1.5'
+Target: i686-pc-cygwin
+Configured with: /gnu/gcc/releases/packaging/4.3.4-3/gcc4-4.3.4-3/src/gcc-4.3.4/configure --srcdir=/gnu/gcc/releases/packaging/4.3.4-3/gcc4-4.3.4-3/src/gcc-4.3.4 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --infodir=/usr/share/info --mandir=/usr/share/man --datadir=/usr/share --infodir=/usr/share/info --mandir=/usr/share/man -v --with-gmp=/usr --with-mpfr=/usr --enable-bootstrap --enable-version-specific-runtime-libs --with-slibdir=/usr/bin --libexecdir=/usr/lib --enable-static --enable-shared --enable-shared-libgcc --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2 --disable-sjlj-exceptions --enable-languages=ada,c,c++,fortran,java,objc,obj-c++ --disable-symvers --enable-libjava --program-suffix=-4 --enable-libgomp --enable-libssp --enable-libada --enable-threads=posix --with-arch=i686 --with-tune=generic --enable-libgcj-sublibs CC=gcc-4 CXX=g++-4 CC_FOR_TARGET=gcc-4 CXX_FOR_TARGET=g++-4 GNATMAKE_FOR_TARGET=gnatmake GNATBIND_FOR_TARGET=gnatbind AS=/opt/gcc-tools/bin/as.exe AS_FOR_TARGET=/opt/gcc-tools/bin/as.exe LD=/opt/gcc-tools/bin/ld.exe LD_FOR_TARGET=/opt/gcc-tools/bin/ld.exe --with-ecj-jar=/usr/share/java/ecj.jar
 Thread model: posix
-gcc version 4.3.4 (Gentoo 4.3.4 p1.0, pie-10.1.5
+gcc version 4.3.4 20090804 (release) 1 (GCC
 configure:2463: $? = 0
 configure:2470: g++ -V >&5
 g++: '-V' option must have argument
@@ -78,17 +80,17 @@ configure:2474: $? = 1
 configure:2497: checking for C++ compiler default output file name
 configure:2519: g++    conftest.cpp  >&5
 configure:2523: $? = 0
-configure:2561: result: a.out
+configure:2561: result: a.exe
 configure:2580: checking whether the C++ compiler works
-configure:2590: ./a.out
+configure:2590: ./a.exe
 configure:2594: $? = 0
 configure:2613: result: yes
 configure:2620: checking whether we are cross compiling
 configure:2622: result: no
 configure:2625: checking for suffix of executables
-configure:2632: g++ -o conftest    conftest.cpp  >&5
+configure:2632: g++ -o conftest.exe    conftest.cpp  >&5
 configure:2636: $? = 0
-configure:2662: result: 
+configure:2662: result: .exe
 configure:2668: checking for suffix of object files
 configure:2694: g++ -c   conftest.cpp >&5
 configure:2698: $? = 0
@@ -106,11 +108,11 @@ configure:2989: result: GNU
 configure:3014: checking dependency style of g++
 configure:3105: result: gcc3
 configure:3168: checking for gcc
-configure:3184: found /usr/bin/gcc
+configure:3184: found /bin/gcc
 configure:3195: result: gcc
 configure:3427: checking for C compiler version
 configure:3435: gcc --version >&5
-gcc (Gentoo 4.3.4 p1.0, pie-10.1.5) 4.3.4
+gcc (GCC) 4.3.4 20090804 (release) 1
 Copyright (C) 2008 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -118,10 +120,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 configure:3439: $? = 0
 configure:3446: gcc -v >&5
 Using built-in specs.
-Target: i686-pc-linux-gnu
-Configured with: /var/tmp/portage/sys-devel/gcc-4.3.4/work/gcc-4.3.4/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.4 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.4 p1.0, pie-10.1.5'
+Target: i686-pc-cygwin
+Configured with: /gnu/gcc/releases/packaging/4.3.4-3/gcc4-4.3.4-3/src/gcc-4.3.4/configure --srcdir=/gnu/gcc/releases/packaging/4.3.4-3/gcc4-4.3.4-3/src/gcc-4.3.4 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --infodir=/usr/share/info --mandir=/usr/share/man --datadir=/usr/share --infodir=/usr/share/info --mandir=/usr/share/man -v --with-gmp=/usr --with-mpfr=/usr --enable-bootstrap --enable-version-specific-runtime-libs --with-slibdir=/usr/bin --libexecdir=/usr/lib --enable-static --enable-shared --enable-shared-libgcc --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2 --disable-sjlj-exceptions --enable-languages=ada,c,c++,fortran,java,objc,obj-c++ --disable-symvers --enable-libjava --program-suffix=-4 --enable-libgomp --enable-libssp --enable-libada --enable-threads=posix --with-arch=i686 --with-tune=generic --enable-libgcj-sublibs CC=gcc-4 CXX=g++-4 CC_FOR_TARGET=gcc-4 CXX_FOR_TARGET=g++-4 GNATMAKE_FOR_TARGET=gnatmake GNATBIND_FOR_TARGET=gnatbind AS=/opt/gcc-tools/bin/as.exe AS_FOR_TARGET=/opt/gcc-tools/bin/as.exe LD=/opt/gcc-tools/bin/ld.exe LD_FOR_TARGET=/opt/gcc-tools/bin/ld.exe --with-ecj-jar=/usr/share/java/ecj.jar
 Thread model: posix
-gcc version 4.3.4 (Gentoo 4.3.4 p1.0, pie-10.1.5
+gcc version 4.3.4 20090804 (release) 1 (GCC
 configure:3450: $? = 0
 configure:3457: gcc -V >&5
 gcc: '-V' option must have argument
@@ -181,9 +183,9 @@ configure:4285: result: /bin/grep -E
 configure:4290: checking for ANSI C header files
 configure:4320: gcc -c -g -O2  conftest.c >&5
 configure:4327: $? = 0
-configure:4426: gcc -o conftest -g -O2   conftest.c  >&5
+configure:4426: gcc -o conftest.exe -g -O2   conftest.c  >&5
 configure:4430: $? = 0
-configure:4436: ./conftest
+configure:4436: ./conftest.exe
 configure:4440: $? = 0
 configure:4458: result: yes
 configure:4482: checking for sys/types.h
@@ -230,8 +232,8 @@ configure:4660: checking for _Bool
 configure:4688: gcc -c -g -O2  conftest.c >&5
 configure:4695: $? = 0
 configure:4722: gcc -c -g -O2  conftest.c >&5
-conftest.c: In function 'main':
-conftest.c:56: error: expected expression before ')' token
+conftest.c: In function ‘main’:
+conftest.c:56: error: expected expression before ‘)’ token
 configure:4729: $? = 1
 configure: failed program was:
 | /* confdefs.h.  */
@@ -303,8 +305,8 @@ configure:4841: checking for size_t
 configure:4869: gcc -c -g -O2  conftest.c >&5
 configure:4876: $? = 0
 configure:4903: gcc -c -g -O2  conftest.c >&5
-conftest.c: In function 'main':
-conftest.c:58: error: expected expression before ')' token
+conftest.c: In function ‘main’:
+conftest.c:58: error: expected expression before ‘)’ token
 configure:4910: $? = 1
 configure: failed program was:
 | /* confdefs.h.  */
@@ -385,7 +387,7 @@ generated by GNU Autoconf 2.63.  Invocation command line was
   CONFIG_COMMANDS = 
   $ ./config.status 
 
-on vaio_z
+on c2007
 
 config.status:778: creating Makefile
 config.status:778: creating Rakefile
@@ -424,6 +426,7 @@ ac_cv_env_host_alias_set=
 ac_cv_env_host_alias_value=
 ac_cv_env_target_alias_set=
 ac_cv_env_target_alias_value=
+ac_cv_exeext=.exe
 ac_cv_header_inttypes_h=yes
 ac_cv_header_memory_h=yes
 ac_cv_header_stdbool_h=yes
@@ -438,7 +441,7 @@ ac_cv_header_unistd_h=yes
 ac_cv_objext=o
 ac_cv_path_EGREP='/bin/grep -E'
 ac_cv_path_GREP=/bin/grep
-ac_cv_path_install='/usr/bin/install -c'
+ac_cv_path_install='/bin/install -c'
 ac_cv_path_mkdir=/bin/mkdir
 ac_cv_prog_AWK=gawk
 ac_cv_prog_CPP='gcc -E'
@@ -457,14 +460,14 @@ am_cv_CXX_dependencies_compiler_type=gcc3
 ## Output variables. ##
 ## ----------------- ##
 
-ACLOCAL='${SHELL} /home/derui/develop/utakata/missing --run aclocal-1.10'
+ACLOCAL='${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run aclocal-1.10'
 AMDEPBACKSLASH='\'
 AMDEP_FALSE='#'
 AMDEP_TRUE=''
-AMTAR='${SHELL} /home/derui/develop/utakata/missing --run tar'
-AUTOCONF='${SHELL} /home/derui/develop/utakata/missing --run autoconf'
-AUTOHEADER='${SHELL} /home/derui/develop/utakata/missing --run autoheader'
-AUTOMAKE='${SHELL} /home/derui/develop/utakata/missing --run automake-1.10'
+AMTAR='${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run tar'
+AUTOCONF='${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run autoconf'
+AUTOHEADER='${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run autoheader'
+AUTOMAKE='${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run automake-1.10'
 AWK='gawk'
 CC='gcc'
 CCDEPMODE='depmode=gcc3'
@@ -474,14 +477,14 @@ CPPFLAGS=''
 CXX='g++'
 CXXDEPMODE='depmode=gcc3'
 CXXFLAGS='-g -O2'
-CYGPATH_W='echo'
+CYGPATH_W='cygpath -w'
 DEFS='-DHAVE_CONFIG_H'
 DEPDIR='.deps'
 ECHO_C=''
 ECHO_N='-n'
 ECHO_T=''
 EGREP='/bin/grep -E'
-EXEEXT=''
+EXEEXT='.exe'
 GREP='/bin/grep'
 INSTALL_DATA='${INSTALL} -m 644'
 INSTALL_PROGRAM='${INSTALL}'
@@ -491,7 +494,7 @@ LDFLAGS=''
 LIBOBJS=''
 LIBS=''
 LTLIBOBJS=''
-MAKEINFO='${SHELL} /home/derui/develop/utakata/missing --run makeinfo'
+MAKEINFO='${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run makeinfo'
 MKDIR_P='/bin/mkdir -p'
 OBJEXT='o'
 PACKAGE='utakata'
@@ -528,7 +531,7 @@ host_alias=''
 htmldir='${docdir}'
 includedir='${prefix}/include'
 infodir='${datarootdir}/info'
-install_sh='$(SHELL) /home/derui/develop/utakata/install-sh'
+install_sh='$(SHELL) /cygdrive/c/meadow/develop/utakata/install-sh'
 libdir='${exec_prefix}/lib'
 libexecdir='${exec_prefix}/libexec'
 localedir='${datarootdir}/locale'
index e1726bb..4bbfd37 100755 (executable)
@@ -363,9 +363,9 @@ Copyright (C) 2008 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='/home/derui/develop/utakata'
+ac_pwd='/cygdrive/c/meadow/develop/utakata'
 srcdir='.'
-INSTALL='/usr/bin/install -c'
+INSTALL='/bin/install -c'
 MKDIR_P='/bin/mkdir -p'
 AWK='gawk'
 test -n "$AWK" || AWK=awk
@@ -554,7 +554,7 @@ S["am__quote"]=""
 S["am__include"]="include"
 S["DEPDIR"]=".deps"
 S["OBJEXT"]="o"
-S["EXEEXT"]=""
+S["EXEEXT"]=".exe"
 S["ac_ct_CXX"]="g++"
 S["CPPFLAGS"]=""
 S["LDFLAGS"]=""
@@ -562,7 +562,7 @@ S["CXXFLAGS"]="-g -O2"
 S["CXX"]="g++"
 S["am__untar"]="${AMTAR} xf -"
 S["am__tar"]="${AMTAR} chof - \"$$tardir\""
-S["AMTAR"]="${SHELL} /home/derui/develop/utakata/missing --run tar"
+S["AMTAR"]="${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run tar"
 S["am__leading_dot"]="."
 S["SET_MAKE"]=""
 S["AWK"]="gawk"
@@ -570,15 +570,15 @@ S["mkdir_p"]="/bin/mkdir -p"
 S["MKDIR_P"]="/bin/mkdir -p"
 S["INSTALL_STRIP_PROGRAM"]="$(install_sh) -c -s"
 S["STRIP"]=""
-S["install_sh"]="$(SHELL) /home/derui/develop/utakata/install-sh"
-S["MAKEINFO"]="${SHELL} /home/derui/develop/utakata/missing --run makeinfo"
-S["AUTOHEADER"]="${SHELL} /home/derui/develop/utakata/missing --run autoheader"
-S["AUTOMAKE"]="${SHELL} /home/derui/develop/utakata/missing --run automake-1.10"
-S["AUTOCONF"]="${SHELL} /home/derui/develop/utakata/missing --run autoconf"
-S["ACLOCAL"]="${SHELL} /home/derui/develop/utakata/missing --run aclocal-1.10"
+S["install_sh"]="$(SHELL) /cygdrive/c/meadow/develop/utakata/install-sh"
+S["MAKEINFO"]="${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run makeinfo"
+S["AUTOHEADER"]="${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run autoheader"
+S["AUTOMAKE"]="${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run automake-1.10"
+S["AUTOCONF"]="${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run autoconf"
+S["ACLOCAL"]="${SHELL} /cygdrive/c/meadow/develop/utakata/missing --run aclocal-1.10"
 S["VERSION"]="0.0.1"
 S["PACKAGE"]="utakata"
-S["CYGPATH_W"]="echo"
+S["CYGPATH_W"]="cygpath -w"
 S["am__isrc"]=""
 S["INSTALL_DATA"]="${INSTALL} -m 644"
 S["INSTALL_SCRIPT"]="${INSTALL}"
index 6e57673..9823342 100644 (file)
--- a/lib/any.h
+++ b/lib/any.h
@@ -7,6 +7,8 @@
 #ifndef _DEVELOP_UTAKATA_LIB_ANY_H_
 #define _DEVELOP_UTAKATA_LIB_ANY_H_
 
+#include <type_info>
+
 namespace akebono {
 
 class any {
@@ -71,6 +73,8 @@ class any {
     }
   };
 
+ private:
+
   holder_base* content_;
 };
 }
diff --git a/lib/bool_compareble.h b/lib/bool_compareble.h
new file mode 100755 (executable)
index 0000000..c6c1438
--- /dev/null
@@ -0,0 +1,101 @@
+// safe boolイディオムの実装をサポートするCRTPを提供します
+// 以下のように利用されることを想定しています。
+// class Test : private bool_compareble<Test> {
+//   bool operator!() const {return true;}
+// };
+// Test t;
+// if (t) {std::cout << "true" << std::endl;}
+// if (!t) {}
+// if (t != false) {std::cout << "OK" << std::endl;}
+//
+// このファイルで提供されるbool_comparebleを利用した場合、bool_compareble
+// を継承したクラス間においては、operator==、operator!==の利用を
+// 行うことができなくなります。
+#ifndef _UATKATA_LIB_BOOL_COMPAREBLE_H_
+#define _UTAKATA_LIB_BOOL_COMPAREBLE_H_
+
+namespace akebono {
+namespace crtp {
+
+// コンパイルエラーを発生させるためのヘルパ構造体です。
+// それぞれ、this_type_support_comparisonsは、コンパイル可能である
+// 場合に利用され、this_type_does_not_support_comparisonsは、
+// コンパイル不能である場合に利用されます。
+struct bool_compareble_helper {
+  void this_type_support_comparisons() const {}
+ private:
+  bool this_type_does_not_support_comparisons() const {}
+};
+
+// 継承先のクラスに対して、自動的にsafe-boolイディオムを適用するための
+// テンプレートです。
+// class hoge : private bool_compareble<hoge>のように利用します。
+// 継承先のクラスでは、必ずoperator!が定義されていなければなりません。
+template<class T>
+class bool_compareble {
+
+  // コンパイル時の確認のために利用されます。
+  typedef void (bool_compareble<T>::*unspecified_bool)() const;
+
+  // unspecified_bool型の有効である関数ポインタを返します。
+  unspecified_bool bool_value_() {
+    reinterpret_cast<unspecified_bool>(
+        &bool_compareble_helper().this_type_support_comparisons);
+  }
+
+ public:
+
+  // void()型への型変換時に実行される関数ですが、この関数は実行される
+  // ことは無く、実行可能であるかどうかを判別するための関数
+  // となります。
+  // operator!が存在しない場合、コンパイルエラーが発生します。
+  operator unspecified_bool() const {
+    return !(static_cast<const T*>(this)->operator!()) ? bool_value_() : 0;
+  }
+
+  // boolとの比較の際、ADPでのみLookupが行われるように定義される
+  // friendなoperatorです。
+  // ただし、この場合x == 1のような表現が許容されます。
+  friend bool operator==(const T& lhs, bool rhs) const {
+    return static_cast<bool>(lhs) == rhs;
+  }
+
+  friend bool operator==(bool lhs, const T& rhs) const {
+    return lhs == static_cast<bool>(rhs);
+  }
+
+  friend bool operator!=(const T& lhs, bool rhs) const {
+    return static_cast<bool>(lhs) == rhs;
+  }
+
+  friend bool operator!=(bool lhs, const T& rhs) const {
+    return lhs == static_cast<bool>(rhs);
+  }
+
+  // それぞれ、bool_compareble同士の比較を許可しないための
+  // オペレータオーバーロードとなります。
+  // すべてのbool_comparebleを対象とするため、テンプレート引数は
+  // 指定されません。
+  // 元の同士に対して、比較が必要である場合、適宜operator==を定義する
+  // 必要があります。
+  friend bool operator==(const bool_compareble& lhs,
+                         const bool_compareble& lhs) {
+    return bool_compareble_helper().this_type_does_not_support_comparisons();
+  }
+
+  friend bool operator!=(const bool_compareble& lhs,
+                         const bool_compareble& lhs) {
+    return bool_compareble_helper().this_type_does_not_support_comparisons();
+  }
+
+ protected:
+
+  // 外部からの明示的な生成は許可されません。
+  bool_compareble() {}
+  ~bool_compareble() {}
+};
+
+} // end of namespace crtp
+} // end of namespace akebono
+
+#endif /* _UTAKATA_LIB_BOOL_COMPAREBLE_H_ */
diff --git a/lib/counter.h b/lib/counter.h
deleted file mode 100755 (executable)
index 5367a43..0000000
+++ /dev/null
@@ -1,386 +0,0 @@
-#ifndef ___HGL___counter___
-#define ___HGL___counter___
-
-/*
- CCounter
- 基本カウンタークラス。
- 基本的なcounterであり、使用方法は
- CCounter hoge(1,0,100);
- とすると、初期値が0、最大値が100、一回のインクリメントにつき
- 1ずつ増加する、というカウンターになる。
- この時、カウントが最大値を超えたら、初期値に戻る
- CCounter hoge(2,0,100,true)
- とすると、超えた分の値を持ち越す
-*/
-class CCounter {
-public:
-
-       CCounter(int nMargin,int nInit,int nMax,int nMin, bool b = false) {
-               m_nMax = nMax;
-               m_nInit = nInit;
-               m_nMargin = nMargin;
-               m_nNowCount = nInit;
-               m_nMin = nMin;
-               m_bCarry = b;
-       }
-
-       CCounter() {
-               m_nMax = 0;
-               m_nInit = 0;
-               m_nMargin = 0;
-               m_nNowCount = 0;
-               m_nMin = 0;
-               m_bCarry = false;
-       }
-
-       //オペレーターオーバーロード
-       //インクリメント、デクリメント、-=、+=、==、<><=>=
-       //などを全て判定できるようにする。
-       CCounter& operator++() {inc();return *this;}
-       CCounter& operator++(int n) {inc();return *this;}
-       CCounter& operator--() {dec();return *this;}
-       CCounter& operator--(int n) {dec();return *this;}
-
-       CCounter& operator+=(int n) {inc(n);return *this;}
-       CCounter& operator-=(int n) {dec(n);return *this;}
-
-       bool operator!=(int n) {return get() != n?true:false;}
-       bool operator==(int n) {return get() == n?true:false;}
-       bool operator>=(int n) {return get() >= n?true:false;}
-       bool operator<=(int n) {return get() <= n?true:false;}
-       bool operator>(int n) {return get() > n?true:false;}
-       bool operator<(int n) {return get() < n?true:false;}
-       bool operator==(const CCounter& n) {return get() == n.get()?true:false;}
-       bool operator>=(const CCounter& n) {return get() >= n.get()?true:false;}
-       bool operator<=(const CCounter& n) {return get() <= n.get()?true:false;}
-       bool operator>(const CCounter& n) {return get() > n.get()?true:false;}
-       bool operator<(const CCounter& n) {return get() < n.get()?true:false;}
-
-       /**
-        * 現在の値を取得する
-        * @access public
-        * @return int
-        */
-       int get() const {return m_nNowCount;}
-
-       /**
-        * 状態を初期化する。初期化される値は、初期値として設定した値である。
-        * @access public
-        * @return void
-        */
-       void reset() {m_nNowCount = m_nInit;}
-
-       /**
-        * マージンを設定する
-        * @param int nMargin マージン
-        * @access public
-        * @return void
-        */
-       void setMargin(int nMargin) {m_nMargin = nMargin;}
-       
-       /**
-        * マージンを取得する
-        * @access public
-        * @return int
-        */
-       int getMargin() const {return m_nMargin;}
-
-       /**
-        * 初期値を設定する
-        * @param int nInit 初期値
-        * @access public
-        * @return void
-        */
-       void setInit(int nInit) {m_nInit = nInit;}
-       
-       /**
-        * 初期値を取得する
-        * @access public
-        * @return int
-        */
-       int getInit() const {return m_nInit;}
-
-       /**
-        * 最大値を設定する
-        * @param int nMax 最大値
-        * @access public
-        * @return void
-        */
-       void setMax(int nMax) {m_nMax = nMax;}
-       
-       /**
-        * 最大値を取得する
-        * @access public
-        * @return int
-        */
-       int getMax() const {return m_nMax;}
-
-       int getMin() const {return m_nMin;}
-       void setMin(int min) {m_nMin = min;}
-
-private:
-
-       /**
-        * @brief カウンタのインクリメントを行う。このカウンタでは、
-        * 単純なインクリメントによる、内部マージンの加算を行う。
-        */
-       void inc() {
-               //内部マージンの加算
-               m_nNowCount += m_nMargin;
-
-               if (!m_bCarry) {
-                       //加算するマージンによって、どちらと判定するかを決定する。
-                       if (m_nMargin > 0) {
-                               if (m_nNowCount > m_nMax) {
-                                       m_nNowCount = m_nMax;
-                               }
-                       } else {
-                               if (m_nNowCount < m_nMin) {
-                                       m_nNowCount = m_nMin;
-                               }
-                       }
-               } else {
-                       //キャリーオーバーするのは、あくまで最大値のみ。
-                       if (m_nNowCount > m_nMax) {
-                               //キャリーオーバーは、最大値と最小値それぞれの絶対値の差分を引く。
-                               m_nNowCount -= (abs(m_nMax) - abs(m_nMin));
-                       } else if (m_nNowCount < m_nMin) {
-                               m_nNowCount += (abs(m_nMax) - abs(m_nMin));
-                       }
-               }
-       }
-
-       /**
-        * カウンタのインクリメントを行う
-        * @param int nInc 指定された数だけインクリメントする。
-        * @access protected
-        * @return void
-        */
-       void inc(int nInc) {
-               
-               m_nNowCount += nInc;
-
-               if (!m_bCarry) {
-                       if (nInc > 0) {
-                               if (m_nNowCount > m_nMax) {
-                                       m_nNowCount = m_nMax;
-                               }
-                       } else {
-                               if (m_nNowCount < m_nMin) {
-                                       m_nNowCount = m_nMin;
-                               }
-                       }
-               } else {
-                       //キャリーオーバーするのは、あくまで最大値のみ。
-                       if (m_nNowCount > m_nMax) {
-                               //キャリーオーバーは、最大値と最小値それぞれの絶対値の差分を引く。
-                               m_nNowCount -= (abs(m_nMax) - abs(m_nMin));
-                       } else if (m_nNowCount < m_nMin) {
-                               m_nNowCount += (abs(m_nMax) - abs(m_nMin));
-                       }
-               }
-       }
-
-       /**
-        * @brief 単純なインクリメントによる、内部マージンの減算。
-        */
-       void dec() {
-               m_nNowCount -= m_nMargin;
-
-               if (!m_bCarry) {
-                       //減算するマージンによって、どちらと判定するかを決定する。
-                       if (m_nMargin < 0) {
-                               if (m_nNowCount > m_nMax) {
-                                       m_nNowCount = m_nMax;
-                               }
-                       } else {
-                               if (m_nNowCount < m_nMin) {
-                                       m_nNowCount = m_nMin;
-                               }
-                       }
-               } else {
-                       //キャリーオーバーするのは、あくまで最大値のみ。
-                       if (m_nNowCount > m_nMax) {
-                               //キャリーオーバーは、最大値と最小値それぞれの絶対値の差分を引く。
-                               m_nNowCount -= (abs(m_nMax) - abs(m_nMin));
-                       } else if (m_nNowCount < m_nMin) {
-                               m_nNowCount += (abs(m_nMax) - abs(m_nMin));
-                       }
-               }
-       }
-
-       /**
-        * カウンタのデクリメントを行う
-        * @param int nDec デフォルトは-1であり、-1である場合は設定値が使われる
-        * @access protected
-        * @return void
-        */
-       void dec(int nDec) {
-               m_nNowCount -= nDec;
-
-               if (!m_bCarry) {
-                       if (nDec < 0) {
-                               if (m_nNowCount > m_nMax) {
-                                       m_nNowCount = m_nMax;
-                               }
-                       } else {
-                               if (m_nNowCount < m_nMin) {
-                                       m_nNowCount = m_nMin;
-                               }
-                       }
-               } else {
-                       //キャリーオーバーするのは、あくまで最大値のみ。
-                       if (m_nNowCount > m_nMax) {
-                               //キャリーオーバーは、最大値と最小値それぞれの絶対値の差分を引く。
-                               m_nNowCount -= (abs(m_nMax) - abs(m_nMin));
-                       } else if (m_nNowCount < m_nMin) {
-                               m_nNowCount += (abs(m_nMax) - abs(m_nMin));
-                       }
-               }
-       }
-
-private:
-
-       int m_nNowCount;        //現在カウント
-       int m_nInit;            //初期値
-       int m_nMargin;          //一回の増減値
-       int m_nMax;                     //最大値
-       int m_nMin;                     //最低値
-       bool m_bCarry;          //持ち越しを行うかどうか
-};
-
-/**
- CFractionalCounter
- 分数関数を用いたカウンター。
- 具体的な使用方法は、次のような用途に。
-
- //0から22までを、三回のインクリメントで。
- //最高値に達したら、0にもどらない
- CFractionalCounter counter(0,22,3);
- counter++;
-
- //0から22まで、三回のインクリメントで。
- //最高値に達した場合、0に戻ってもう一度行う。
- CFractionalCounter counter(0,22,3,true);
-
- //最大値よりも最小値が小さい場合でも、意味は同じ
- CFractionalCounter counter(23,0,3);
- counter++;                    
-*/
-class CFractionalCounter {
-public:
-
-       CFractionalCounter(int nInit,int nThreshold,int nCount,bool bLoop = false) {
-               set(nInit,nThreshold,nCount,bLoop);
-       }
-       CFractionalCounter() {
-               set(0,0,0,false);
-       }
-       
-       //基本的にインクリメントのみ。
-       //比較などしようがないかもしれないが、intとの比較くらいは出来るように。
-       CFractionalCounter& operator++() {inc();return *this;}
-       CFractionalCounter& operator++(int n) {inc();return *this;}
-       
-       //他のカウンターと使用方法が違うので、intとの比較だけで十分だろう。
-       bool operator==(int n) {return (m_dwNowCount >> 16) == n?true:false;}
-       bool operator>=(int n) {return (m_dwNowCount >> 16) >= n?true:false;}
-       bool operator<=(int n) {return (m_dwNowCount >> 16) <= n?true:false;}
-       bool operator>(int n) {return (m_dwNowCount >> 16) > n?true:false;}
-       bool operator<(int n) {return (m_dwNowCount >> 16) < n?true:false;}
-
-       /**
-        * 現在の値を取得する
-        * @access public
-        * @return int
-        */
-       int get() const {return (m_dwNowCount >> 16);}
-
-       /**
-        * 初期状態に戻す
-        * @access public
-        * @return void
-        */
-       void reset() {
-               m_dwNowCount = m_nInit << 16;
-               m_nNowNum = 0;
-       }
-
-       /**
-        * 変数の設定、コピーで使用する。
-        * @param int nInit 初期値
-        * @param int nMax 最大値
-        * @param int nCount 初期値から最大値までの回数
-        * @param bool bLoop ループするかどうか
-        * @access public
-        * @return void
-        */
-       void set(int nInit,int nThreshold,int nCount,bool bLoop = false) {
-               m_nInit = nInit;
-               m_nThreshold = nThreshold;
-               m_dwNowCount = nInit << 16;
-               m_nNum = nCount;
-               m_bLoop = bLoop;
-               m_nNowNum = 0;
-               calc();
-       }
-
-private:
-
-       /**
-        * 計算を行う
-        * @access protected
-        * @return void
-        */
-       void calc() {
-               //計算を行う。ここで行う計算とは、与えられた値を元に、
-               //一回ずつの増分、減分を取得することである。
-               unsigned long tmp = abs(m_nThreshold - m_nInit) << 16;
-               (m_nThreshold - m_nInit) <= 0?m_bReduce = true:m_bReduce = false;
-
-               //16ビットまでしか計算できない。が、十分だろ。
-               m_dwMargin = tmp / m_nNum;
-       }
-
-       /**
-        * 一回分の増減を行う。
-        * @access protected
-        * @return void
-        */
-       void inc() {
-               //一回分の加算・減算を行う。
-               //誤差が出たりするのは仕方ないと思う。
-               
-               if (m_nNowNum >= m_nNum) {
-                       if (m_bLoop) {
-                               m_dwNowCount = m_nInit << 16;
-                               m_nNowNum = 0;
-                       } else {
-                               m_dwNowCount = m_nThreshold << 16;
-                               m_nNowNum = m_nNum;
-                       }
-               } else {
-                       m_nNowNum++;
-                       if (m_bReduce) {
-                               m_dwNowCount -= m_dwMargin;
-                       } else {
-                               m_dwNowCount += m_dwMargin;
-                       }
-               }
-       }       
-
-private:
-
-       int m_nInit;
-       int m_nThreshold;
-       unsigned long m_dwNowCount;
-       int m_nNum;
-       int m_nNowNum;
-       bool m_bLoop;
-
-       bool m_bReduce;         //マイナスかどうか
-
-       unsigned long m_dwMargin;               //一回のマージン
-
-};
-#endif
\ No newline at end of file
index c002ae2..c10ad19 100755 (executable)
@@ -43,7 +43,6 @@ class less_than_comparable {
     return !lhs.operator<(rhs);
   }
 };
-
 }
 }
 
index 004d071..ccf1722 100644 (file)
@@ -112,4 +112,4 @@ class TextArrayReader {
 };
 }; // end of namespace utility
 
-#endif /* _C:_MEADOW_DEVELOP_UTAKATA_LIB_TEXTARRAYFORMAT_H_ */
+#endif /* _UTAKATA_LIB_TEXTARRAYFORMAT_H_ */
diff --git a/src/lexer/comment_lexer.cpp b/src/lexer/comment_lexer.cpp
new file mode 100755 (executable)
index 0000000..f76df95
--- /dev/null
@@ -0,0 +1,35 @@
+#include <algorithm>
+
+#include "src/exception_macro.h"
+#include "src/lexeme.h"
+#include "src/lexer/comment_lexer.h"
+#include "src/lexer/lexer_interface.h"
+#include "src/lexer/term_lexer.h"
+#include "src/lexer/term_checker.h"
+#include "src/unicode.h"
+#include "src/encoding_reader.h"
+
+namespace lexer = utakata::lexer;
+namespace term = utakata::lexer::term;
+namespace unicode = utakata::unicode;
+
+// 宣言のコメントを参照してください。
+lexer::Lexeme* lexer::CommentLexer::Lex(reader::EncodingReader* reader) {
+  lexer::TermLexer<term::DatumComment> datum_comment;
+  lexer::TermLexer<term::SpecialComment> special_comment;
+
+  unicode::UniChar ch(reader->Peek());
+  if (ch.rawcode() == ';') {
+    SkipByLineComment(reader);
+
+  } else if (datum_comment.CheckToken(reader)) {
+    return lexer::Lexeme(unicode::UniString(), lexer::Lexeme::kDatumComment);
+  } else if (special_comment.CheckToken(reader)) {
+    reader->Read(special_comment.ReadToken(reader));
+    return lexer::Lexeme(unicode::UniString(), lexer::Lexeme::kSpecialComment);
+  } else {
+    lexer::detail::NestedLexer().Lex(reader);
+  }
+
+  return NULL;
+}
diff --git a/src/lexer/comment_lexer.h b/src/lexer/comment_lexer.h
new file mode 100755 (executable)
index 0000000..3ef3f75
--- /dev/null
@@ -0,0 +1,33 @@
+// <comment>に該当する字句を読み出す機能を提供します。
+// 原則として、<comment>は読み飛ばされますが、字句解析内では読み飛ばし
+// ができない部分が存在するため、一部に対しては字句として返却が行われます。
+#ifndef _UTAKATA_SRC_LEXER_COMMENT_LEXER_H_
+#define _UTAKATA_SRC_LEXER_COMMENT_LEXER_H_
+
+#include "src/lexer/lexer_interface.h"
+
+namespace utakata {
+namespace reader {
+class EncodingReader;
+}
+
+namespace lexer {
+
+class Lexeme;
+// <comment>に一致する字句を解釈する機能を提供します。
+class CommentLexer : public IPartOfLexer {
+ public:
+
+  // readerの先頭から、<comment>に一致するかどうかを返却します。
+  // <nested comment>、及び;より開始されるコメントについては、
+  // 当該部分が読み飛ばされた上で、NULLが返却されますが、
+  // #; <interlexeme space> <datum>、また#!<identifier>については、
+  // それぞれ個別のLexemeが返却されます。
+  // Parserは、受け取ったLexemeに対して処理を行うことができますが、
+  // コメントが必ず読み飛ばされることを保証しなければなりません。
+  lexer::Lexeme* Lex(reader::EncodingReader* reader);
+};
+}
+}
+
+#endif /* _UTAKATA_SRC_LEXER_COMMENT_LEXER_H_ */
diff --git a/src/lexer/lexer_dispatcher.cpp b/src/lexer/lexer_dispatcher.cpp
deleted file mode 100644 (file)
index 6c119f1..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "src/lexer/lexer_dispatcher.h"
-
diff --git a/src/lexer/lexer_dispatcher.h b/src/lexer/lexer_dispatcher.h
deleted file mode 100755 (executable)
index 8fc9356..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-// SchemeLexer内部で利用される、各非終端記号毎の字句解析器への振り分けを
-// 行うためのLexerDispatcherを定義します。
-// LexerDispatcherは、ILexerCreaterインターフェースを実装した各クラスを、
-// LexerDispatchTermsと対にして保持し、抽出した文字列から、LexerDispatchTerms
-// に一致したIPartOfLexerインターフェースのLexerを実行します。
-//
-// example
-// -------
-// LexerDispatcher dis();
-// dis.Append(new CLexerCreator());
-// UniString str("hoge");
-// ILexeme i;
-// bool b = dis.Dispatch(str, &i);
-#ifndef _UTAKATA_SRC_SUBLEXER_IMPL_H_
-#define _UTAKATA_SRC_SUBLEXER_IMPL_H_
-
-#include <string>
-#include <map>
-#include "lib/uncopyable.h"
-#include "lib/smart_ptr.h"
-
-namespace utakata {
-
-namespace unicode {
-class UniString;
-class UniChar;
-};
-
-namespace reader {
-class EncodingReader;
-};
-
-namespace lexer {
-
-class Lexeme;
-class ILexerCreator;
-class IPartOfLexer;
-class ILexerDispatchTerm;
-class LexerDispatcher : private akebono::uncopyable {
-  // IPartOfLexerインターフェースを実装したクラスを、同じくIPartOfLexer
-  // インターフェースから返されるLexerDispatchTermsと対にし、
-  // LexerDispatchTermsと一致した場合に、ILexerCreatorより生成された
-  // Lexerに処理を委譲します。
- public:
-  LexerDispatcher() : dispatch_lexer_() {}
-  virtual ~LexerDispatcher() {}
-
-  // 渡された文字列から、各Lexerへの条件チェックを行い、ディスパッチ
-  // される場合、該当するLexerを返します。
-  // Lexerにディスパッチした場合、trueが返されます。
-  // Lexerにディスパッチされなかった場合、引数のlexerの値は操作されず、
-  // 渡した時の値が保持されます。
-  bool Dispatch(const unicode::UniString& string,
-                IPartOfLexer* lexer);
-
-  // 追加するLexerを生成するILexerCreatorを渡し、ディスパッチ
-  // 対象として追加します。
-  // ILexerCreatorから生成されるIPartOfLexerは、自身を適用させるための
-  // 判定に利用するLexerDispatchTermsを返す必要があります。
-  void AppendLexer(const ILexerCreator& creator);
-
- private:
-
-  // ディスパッチ条件と、ディスパッチ対象の対です。
-  std::map<akebono::smart_ptr<ILexerDispatchTerm>,
-           akebono::smart_ptr<IPartOfLexer> > dispatch_lexer_;
-};
-
-// class StringLexer : public ISubLexer {
-//   // 文字列だと判断された場合に実行されるsublexer。
-//   // 文字列が不正に終わったりしている場合には、その時点で例
-//   // 外を発行する。
-//  public:
-//   StringLexer() {}
-//   virtual ~StringLexer() {}
-
-//   smart_ptr<Lexeme> lex(smart_ptr<reader::StreamReader> stream,
-//                                  smart_ptr<ISubLexer>& next);
-// };
-
-// class OneLineCommentLexer : public ISubLexer
-// {
-//   // コメントを返す。
-//   // と言っても、;から開始されるコメントは完全に無視されるので、lexeme
-//   // を保存する必要すらない。
-//  public:
-
-//   OneLineCommentLexer(){}
-//   virtual ~OneLineCommentLexer(){}
-
-//   smart_ptr<Lexeme> lex(smart_ptr<reader::StreamReader> stream,
-//                                  smart_ptr<ISubLexer>& next);
-// };
-
-// class NestedCommentLexer : public ISubLexer
-// {
-//   // コメントを返す。
-//   // と言っても、;から開始されるコメントは完全に無視されるので、lexeme
-//   // を保存する必要すらない。
-//  public:
-
-//   NestedCommentLexer(){}
-//   virtual ~NestedCommentLexer(){}
-
-//   smart_ptr<Lexeme> lex(smart_ptr<reader::StreamReader> stream,
-//                                  smart_ptr<ISubLexer>& next);
-// };
-
-// class CharactorLexer : public ISubLexer
-// {
-//   // 文字名、及び16進数による文字指定の解析を行なう。
-//   // #\文字名、#\x<hex>;の両方を解釈する。
-//  public:
-
-//   CharactorLexer(){}
-//   virtual ~CharactorLexer(){}
-
-//   smart_ptr<Lexeme> lex(smart_ptr<reader::StreamReader> stream,
-//                                  smart_ptr<ISubLexer>& next);
-//  private:
-
-//   // 渡された文字列に該当するunicodeスカラー値を取得する。
-//   unsigned long parseCharSpec(const unicode::UniString& s);
-
-// };
-
-// class NumberLexer : public ISubLexer
-// {
-//   // 数値を解析する。
-//   // ここで解析する数値は、<number>に相当する。
-//   const unsigned char BINARY;
-//   const unsigned char OCTET;
-//   const unsigned char DECIMAL;
-//   const unsigned char HEX;
-//  public:
-
-//   NumberLexer(const utakata::unicode::UniString& str);
-//   virtual ~NumberLexer(){}
-
-//   smart_ptr<Lexeme> lex(smart_ptr<reader::StreamReader> stream,
-//                                  smart_ptr<ISubLexer>& next);
-//  private:
-
-//   smart_ptr<Lexeme> innerLex_(smart_ptr<reader::StreamReader> stream,
-//                                        smart_ptr<ISubLexer>& next,
-//                                        const utakata::unicode::UniString& str);
-
-
-//   // 渡した文字列からprefixを抽出して返す。
-//   unsigned char getPrefix_(const utakata::unicode::UniString& str);
-//   // 正確性を抽出して返す。
-//   void checkExactness_(const utakata::unicode::UniString& str); 
-
-//  private:
-            
-//   smart_ptr<utakata::unicode::UniString> str_;
-
-//   bool exact_;        // 正確性を設定する。
-//   unsigned char prefix_;       // prefixを設定する。
-            
-// };
-
-// class IdentifierLexer : public ISubLexer
-// {
-//   // コメントを返す。
-//   // と言っても、;から開始されるコメントは完全に無視されるので、lexeme
-//   // を保存する必要すらない。
-//  public:
-
-//   IdentifierLexer(const utakata::unicode::UniString& str);
-//   virtual ~IdentifierLexer(){}
-
-//   smart_ptr<Lexeme> lex(smart_ptr<reader::StreamReader> stream,
-//                                  smart_ptr<ISubLexer>& next);
-
-//  private:
-
-//   smart_ptr<utakata::unicode::UniString> str_;
-// };
-
-// class BooleanLexer : public ISubLexer
-// {
-//   // #t、または#fを返す。
-//   // いずれかの次には、必ず区切り文字がなければならない。
-//  public:
-
-//   BooleanLexer(const utakata::unicode::UniChar& ch);
-//   virtual ~BooleanLexer(){}
-
-//   smart_ptr<Lexeme> lex(smart_ptr<reader::StreamReader> stream,
-//                                  smart_ptr<ISubLexer>& next);
-
-//  private:
-
-//   smart_ptr<utakata::unicode::UniChar> ch_;
-// };
-
-// class ByteVectorLexer : public ISubLexer
-// {
-//   // #vu8であるかどうかを検査する。
-//   // vu8ではない場合には、エラーとなる。
-//  public:
-
-//   ByteVectorLexer(const utakata::unicode::UniChar& ch);
-//   virtual ~ByteVectorLexer(){}
-
-//   smart_ptr<Lexeme> lex(smart_ptr<reader::StreamReader> stream,
-//                                  smart_ptr<ISubLexer>& next);
-
-//  private:
-
-//   smart_ptr<utakata::unicode::UniChar> ch_;
-// };
-
-}
-
-}
-
-#endif /* __HOME_DERUI_DEVELOP_UTAKATA_SRC_SUBLEXER_IMPL_H_ */
diff --git a/src/lexer/sublexer_impl.cpp.bk b/src/lexer/sublexer_impl.cpp.bk
deleted file mode 100755 (executable)
index 0b3e1a3..0000000
+++ /dev/null
@@ -1,607 +0,0 @@
-#include <iostream>
-#include <assert.h>
-#include <sstream>
-
-#include "unicode.h"
-#include "reader.h"
-#include "sublexer_impl.h"
-#include "lexeme_impl.h"
-#include "delimiter.h"
-#include "number_lexer.h"
-#include "lexeme_id.h"
-
-using namespace utakata;
-using namespace utakata::unicode;
-
-smart_ptr<lexeme::ILexeme> sublexer::FirstLexer::lex(smart_ptr<reader::StreamReader> stream,
-                                                     smart_ptr<sublexer::ISubLexer>& next)
-{
-    // chにはlexerから渡された、今回読みだした文字が渡されている。
-
-    UniString str;
-
-    // 最初に実行されるので、最初の空白を読み飛ばす。
-    
-    UniChar ch(stream->read());
-    {
-        lexer_delimiter::Whitespace sps;
-        while (sps(ch)) {
-            ch = stream->read();
-        }
-    }
-    // ここまで来た段階で、chには調べる対象となる文字が入っている。
-
-    if (stream->isEOF())
-    {
-        return lexeme::makeEOS();
-    }
-
-    smart_ptr<lexeme::ILexeme> ret;
-    // ()[]`'が最初だった場合、それぞれを返してやる。
-    
-    if (ch == '(' || ch == '[')
-    {
-        ret = lexeme::makeOpenParen();
-    }
-    else if (ch == ')' || ch == ']')
-    {
-        ret = lexeme::makeCloseParen();;
-    }
-    else if (ch == '`')
-    {
-        ret = lexeme::makeBackQuote();
-    }
-    else if (ch == '\'')
-    {
-        ret = lexeme::makeQuote();
-    }
-    else if (ch == '.')
-    {
-        // 次の文字がデリミタで終了していなければならない。
-        if (lexer_delimiter::Normal()(UniChar(stream->peek())))
-        {
-            ret = lexeme::makeDot();
-        }
-    }
-    else if (unicode::is_numeric(ch))
-    {
-        // 先頭が数値だった場合、これは10進数だと判断して次に進む。
-        next.add(new sublexer::NumberLexer(UniString(ch, 1)));
-        ret = smart_ptr<lexeme::ILexeme>();
-    }
-    else if (unicode::is_alpha(ch) ||
-             ch == '!' || ch == '$' ||
-             ch == '%' || ch == '&' ||
-             ch == '*' || ch == '/' ||
-             ch == ':' || ch == '<' ||
-             ch == '>' || ch == '?' ||
-             ch == '^' || ch == '_' ||
-             ch == '~' || ch == '+' ||
-             ch == '.')
-    {
-        // やたらと多いが、上記のどれかである場合には、identityとして解析を
-        // 開始させる。
-        next.add(new sublexer::IdentifierLexer(UniString(ch, 1)));
-        ret = smart_ptr<lexeme::ILexeme>();
-    }
-    else if (ch == ';')
-    {
-        // 一行コメントになるため、そちらに任せる。
-        next.add(new sublexer::OneLineCommentLexer());
-    }
-    else if (ch == '"')
-    {
-        // 先頭が"の場合、stringと判断される。
-        next.add(new sublexer::StringLexer());
-    }
-
-    if (!ret.isNull())
-    {
-        return ret;
-    }
-    else if (next.isNull())
-    {
-        // ここ以降になると、決定するまで読んでから決定させる。
-        str += ch;
-    
-        ret = lex_(str, stream, next);
-        if (!ret.isNull())
-        {
-            return ret;
-        }
-    }
-
-    // ここに来る場合、次の解析結果が存在する場合のみである。
-    if (next.isNull() && ret.isNull())
-    {
-        throw sublexer::LexException(stream->pos(), "lex exception");
-    }
-    return smart_ptr<lexeme::ILexeme>();
-}
-
-smart_ptr<lexeme::ILexeme> sublexer::FirstLexer::lex_(const utakata::unicode::UniString& str,
-                                                      smart_ptr<utakata::reader::StreamReader> stream,
-                                                      smart_ptr<ISubLexer>& next)
-{
-    if (str[0] == ',')
-    {
-        UniChar ch = stream->peek();
-        // 次の一文字で決定できる。
-        if (ch == '@')
-        {
-            stream->read();
-            return lexeme::makeUnquoteSplicing();
-        }
-        else
-        {
-            // 次の文字が@では無い場合、とりあえず,で返す。
-            return lexeme::makeUnquote();
-        }
-    }
-    else if (str[0] == '#')
-    {
-        // コメントなどに繋がる時もあるため、面倒。
-        UniChar ch = stream->peek();
-        if (ch == '\'')
-        {
-            stream->read();
-            return lexeme::makeSyntax();
-        }
-        else if (ch == '`')
-        {
-            stream->read();
-            return lexeme::makeQuasiSyntax();
-        }
-        else if (ch == ',')
-        {
-            // 更に次の文字を読む。
-            stream->read();
-            ch = stream->peek();
-            if (ch == '@')
-            {
-                stream->read();
-                return lexeme::makeUnsyntaxSplicing();
-            }
-            else
-            {
-                return lexeme::makeUnsyntax();
-            }
-        }
-        else if (ch == '|')
-        {
-            // ネストコメントの開始という判断がなされ、ネストコメント
-            // 用の字句解析に移る。
-            stream->read();
-            next.add(new sublexer::NestedCommentLexer());
-        }
-        else if (ch == 'e' || ch == 'E' ||
-                 ch == 'i' || ch == 'I' ||
-                 ch == 'b' || ch == 'B' ||
-                 ch == 'o' || ch == 'O' ||
-                 ch == 'd' || ch == 'D' ||
-                 ch == 'x' || ch == 'X')
-        {
-            // 数値のプレフィックス、もしくはexactnessになるため、これは
-            // 数値として判定させる。
-            stream->read();
-            next.add(new sublexer::NumberLexer(str + ch));
-        }
-        else if (ch == '\\')
-        {
-            // #\の場合、次には文字が出てくるはずなので、そのまま進む。
-            stream->read();
-            next.add(new sublexer::CharactorLexer());
-        }
-        else if (ch == 't' || ch == 'f' ||
-                 ch == 'T' || ch == 'F')
-        {
-            stream->read();
-            next.add(new sublexer::BooleanLexer(ch));
-        }
-        else if (ch == 'v')
-        {
-            // この場合、bytevectorとなる可能性がある。
-            stream->read();
-            next.add(new sublexer::ByteVectorLexer(ch));
-        }
-        else if (ch == '(')
-        {
-            stream->read();
-            return lexeme::makeVector();
-        }
-    }
-    else if (str[0] == '-')
-    {
-        // 先頭が-の場合、次の文字を見てから決める。
-        // 基本的には数値だが、次の文字によってはidentifierになりうる。
-        UniChar ch(stream->peek());
-        lexer_delimiter::Normal nor;
-        if (ch == '>' || nor(ch))
-        {
-            next.add(new sublexer::IdentifierLexer(str));
-        }
-        else
-        {
-            next.add(new sublexer::NumberLexer(str));
-        }
-    }
-
-    return smart_ptr<lexeme::ILexeme>();
-}
-
-
-//================================================================================
-
-smart_ptr<lexeme::ILexeme> sublexer::StringLexer::lex(smart_ptr<reader::StreamReader> stream,
-                                                      smart_ptr<sublexer::ISubLexer>& next)
-{
-    // 文字列を解析する。
-
-    lexer_delimiter::Normal nor;
-    lexer_delimiter::String st;
-    lexer_delimiter::Whitespace w;
-    unicode::UniString str;
-
-    while (!stream->isEOF()) {
-        UniChar tmp(stream->peek());
-        if (st(tmp)) {
-            // readしておく。
-            stream->read();
-            break;
-        }
-
-        if (tmp == '\\')
-        {
-            // 空白及び改行を飛ばす。
-            while (!stream->isEOF() &&
-                   (w(tmp) || nor(tmp)))
-            {
-                tmp = stream->read();
-            }
-        } else {
-            str += stream->read();
-        }
-    }
-
-    return lexeme::makeString(str);
-}
-
-//================================================================================
-
-smart_ptr<lexeme::ILexeme> sublexer::NestedCommentLexer::lex(smart_ptr<reader::StreamReader> stream,
-                                                             smart_ptr<sublexer::ISubLexer>& next)
-{
-    // ネストしたコメントを解釈する。基本的には改行も関係無く処理する。
-    int count = 1;
-    while (!stream->isEOF() && count > 0) {
-        unicode::UniChar tmp(stream->read());
-
-        if (tmp == '#')
-        {
-            // 次の文字を調べる。
-            unicode::UniChar t2(stream->read());
-            if (t2 == '|')
-            {
-                ++count;
-            }
-        }
-        else if (tmp == '|')
-        {
-            // 次の文字を調べる。
-            unicode::UniChar t2(stream->read());
-            if (t2 == '#')
-            {
-                --count;
-            }
-        }
-    }
-
-    return smart_ptr<lexeme::ILexeme>();
-}
-
-//================================================================================
-
-sublexer::NumberLexer::NumberLexer(const unicode::UniString& str) :
-    BINARY(2), OCTET(8), DECIMAL(10), HEX(16),
-    str_(new unicode::UniString(str)), exact_(false), prefix_(0)
-{
-}
-
-smart_ptr<lexeme::ILexeme> sublexer::NumberLexer::innerLex_(smart_ptr<reader::StreamReader> stream,
-                                                            smart_ptr<sublexer::ISubLexer>& next,
-                                                            const unicode::UniString& str)
-{
-
-    // prefixをチェックして、返すべきものを決定する。
-    if (prefix_ == BINARY)
-    {
-        return number::Number<2>().lex(stream, next, str, exact_);
-    }
-    else if (prefix_ == OCTET)
-    {
-        return number::Number<8>().lex(stream, next, str, exact_);
-    }
-    else if (prefix_ == DECIMAL)
-    {
-        return number::Number<10>().lex(stream, next, str, exact_);
-    }
-    else if (prefix_ == HEX)
-    {
-        return number::Number<16>().lex(stream, next, str, exact_);
-    }
-    else
-    {
-        return smart_ptr<lexeme::ILexeme>();
-    }
-}
-
-void sublexer::NumberLexer::checkExactness_(const unicode::UniString& str)
-{
-    // 正確性をチェックする。2文字目だけを調べればそれですむ。
-    if (str[1] == 'e' || str[1] == 'E')
-    {
-        exact_ = true;
-    }
-    else if (str[1] == 'i' || str [1] == 'I')
-    {
-        exact_ = false;
-    }
-}
-
-unsigned char sublexer::NumberLexer::getPrefix_(const unicode::UniString& str)
-{
-    // 2文字目の値を見て判断を返す。
-    if (str[1] == 'b' ||
-        str[1] == 'B')
-    {
-        return BINARY;
-    }
-    else if (str[1] == 'o' ||
-             str[1] == 'O')
-    {
-        return OCTET;
-    }
-    else if (str[1] == 'd' ||
-             str[1] == 'D')
-    {
-        return DECIMAL;
-    }
-    else if (str[1] == 'x' ||
-             str[1] == 'X')
-    {
-        return HEX;
-    }
-
-    return DECIMAL;
-}
-
-smart_ptr<lexeme::ILexeme> sublexer::NumberLexer::lex(smart_ptr<reader::StreamReader> stream,
-                                                      smart_ptr<sublexer::ISubLexer>& next)
-{
-    // 数値を解釈する。
-    lexer_delimiter::Exactness e;
-    lexer_delimiter::Prefix p;
-    
-
-    // 先頭はすでに読みとばされている。次に続く可能性があるため、継続して調査をしてみる。
-
-    if (p(*str_))
-    {
-        prefix_ = getPrefix_(*str_);
-        // 次にexactnessが続いているかどうかを調べる。
-        unicode::UniString s = unicode::substring(*str_, 2);
-        if (e(s))
-        {
-            // Exactnessである場合、実際にそうであるかどうかをチェックする。
-            checkExactness_(s);
-        }
-        s = unicode::substring(s, 2);
-        return innerLex_(stream, next, s);
-    }
-    else if (e(*str_))
-    {
-        // Exactnessであるため、次にprefixの必要がある。
-        checkExactness_(*str_);
-
-        unicode::UniString s = unicode::substring(*str_, 2);
-        if (p(s))
-        {
-            prefix_ = getPrefix_(s);
-        }
-        else
-        {
-            prefix_ = DECIMAL;
-        }
-        return innerLex_(stream, next, s);
-    }
-    else
-    {
-        // どっちでもない場合、基本的に10進数として処理する。
-        prefix_ = DECIMAL;
-        return innerLex_(stream, next, *str_);
-    }
-}
-
-//================================================================================
-
-sublexer::IdentifierLexer::IdentifierLexer(const unicode::UniString& str) :
-    str_(new unicode::UniString(str))
-{}
-
-smart_ptr<lexeme::ILexeme> sublexer::IdentifierLexer::lex(smart_ptr<reader::StreamReader> stream,
-                                                          smart_ptr<sublexer::ISubLexer>& next)
-{
-    // Identityを解析する。解釈自体は結構簡単。
-    
-    // 一文字目はすでに判定されているため、二文字目以降で判定する。
-    // 二文字名以降でなければ判定できないものもあるため、一度まとめてみる。
-    lexer_delimiter::Normal nor;
-    unicode::UniString& str = *str_;
-    if (str[0] == '+')
-    {
-        return lexeme::makeIdentifier(str);
-    }
-    else if (str[0] == '-')
-    {
-        // 次の文字がデリミタの場合には、そのまま返す。
-        UniChar next(stream->peek());
-        if (nor(next))
-        {
-            return lexeme::makeIdentifier(str);
-        }
-        else if (next == '>')
-        {
-            // この場合、そのまま続けてもよし。
-        }
-    }
-
-    while (!stream->isEOF()) {
-        UniChar tmp(stream->peek());
-        if (nor(tmp)) {
-            break;
-        }
-        str += stream->read();
-    }
-    
-    return lexeme::makeIdentifier(str);
-}
-
-//================================================================================
-
-smart_ptr<lexeme::ILexeme> sublexer::CharactorLexer::lex(smart_ptr<reader::StreamReader> stream,
-                                                         smart_ptr<sublexer::ISubLexer>& next)
-{
-    // #\に続く文字名、あるいは#\xに続く16進数のチェックを行なう。
-    // ここに来た時点で、#\までは読まれている。
-    UniChar ch(stream->read());
-    bool flag = ch == 'x' ? true : false;
-
-    // Hexを解釈する。解釈部分を書くと面倒になるため、単純な別関数にしておく。
-    UniString str(ch, 1);
-    lexer_delimiter::Normal nor;
-    lexer_delimiter::HexValue hex;
-    while (!stream->isEOF()) {
-        UniChar tmp(stream->peek());
-        if (nor(tmp))
-        {
-            break;
-        }
-        else if (flag && !hex(tmp))
-        {
-            // hex valueではなかった場合には、これはエラーであると
-            // して返す。
-            std::stringstream ss;
-            ss << tmp.getRawCode() << "は16進数中の文字名として利用できません";
-            throw sublexer::LexException(stream->pos(), ss.str());
-        }
-        str += stream->read();
-    }
-
-    // 抜けた時点で、構成文字は問題ないこととなっている。ここからは、対象とする一文字を
-    // 生成する処理を開始する。
-    UniChar c(parseCharSpec(str));
-
-    return lexeme::makeCharactor(c);
-}
-
-unsigned long sublexer::CharactorLexer::parseCharSpec(const UniString& c)
-{
-    return 0x0;
-}
-
-//================================================================================
-
-sublexer::BooleanLexer::BooleanLexer(const unicode::UniChar& ch) : ch_(new unicode::UniChar(ch))
-{
-}
-
-smart_ptr<lexeme::ILexeme> sublexer::BooleanLexer::lex(smart_ptr<reader::StreamReader> stream,
-                                                         smart_ptr<sublexer::ISubLexer>& next)
-{
-    // true/falseを判別する必要は特に無いため、次の文字が区切り文字だかどうか
-    // だけを気にする。
-
-    if (!stream->isEOF())
-    {
-        UniChar ch(stream->peek());
-
-        lexer_delimiter::Normal nor;
-        if (!nor(ch))
-        {
-            // hex valueではなかった場合には、これはエラーであると
-            // して返す。
-            std::stringstream ss;
-            ss << ch.getRawCode() << "はbooleanの直後では認識されません";
-            throw sublexer::LexException(stream->pos(), ss.str());
-        }
-    }
-
-    return lexeme::makeBoolean(ch_);
-}
-
-//================================================================================
-
-sublexer::ByteVectorLexer::ByteVectorLexer(const unicode::UniChar& ch) : ch_(new unicode::UniChar(ch))
-{
-}
-
-smart_ptr<lexeme::ILexeme> sublexer::ByteVectorLexer::lex(smart_ptr<reader::StreamReader> stream,
-                                                         smart_ptr<sublexer::ISubLexer>& next)
-{
-    // この時点で#vまでは読まれているため、以降2文字がvu(であるかどうかを
-    // 調べる。
-
-    UniString str(utakata::unicode::convert(stream->read(3)));
-    if (str != utakata::unicode::convert("u8("))
-    {
-        std::stringstream ss;
-        ss << "バイトベクタとして認識できません";
-        throw sublexer::LexException(stream->pos(), ss.str());
-    }
-
-    return lexeme::makeByteVector();
-}
-
-
-//================================================================================
-
-
-smart_ptr<lexeme::ILexeme> sublexer::OneLineCommentLexer::lex(
-    smart_ptr<reader::StreamReader> stream,
-    smart_ptr<sublexer::ISubLexer>& next)
-{
-
-
-    // 一行コメントであるかどうかを返す。
-    // なおコメントは原則として全て読み飛ばされるため、解釈が完了した
-    // 後、FirstLexerが再び返される。
-    lexer_delimiter::LineEnding end;
-    while (!stream->isEOF()) {
-        // 改行が出力されるまで全て読み飛ばす。
-        UniChar ch = stream->read();
-        if (end(ch, stream))
-        {
-            // この時点で、読み飛ばしまで行われている。
-            next.add(new sublexer::FirstLexer());
-            break;
-        }
-    }
-    return smart_ptr<lexeme::ILexeme>();
-}
-
-
-//================================================================================
-
-sublexer::LexException::LexException(size_t pos, std::string str) : pos_(pos),
-                                                                    str_()
-{
-    // エラーメッセージを定義する。
-    std::stringstream ss;
-    ss << "lex error ! -- pos : [" << pos << "] message : [" << str << "]" << std::endl;
-    str_ = ss.str();
-}
-
-const char* sublexer::LexException::what() const throw()
-{
-    return str_.c_str();
-}
index 780cd3c..e91020a 100755 (executable)
@@ -266,3 +266,27 @@ bool term::Boolean::operator()(reader::IReader* reader, unsigned int* size) {
   }
   return false;
 }
+
+// 宣言のコメントを参照してください。
+bool term::DatumComment::operator()(reader::IReader* reader,
+                                    unsigned int* size) {
+  unicode::UniString code(unicode::Convert(
+      reader->Peek(kDatumCommentReadSize)));
+  if (code == unicode::Convert("#;")) {
+    *size = kDatumCommentReadSize;
+    return true;
+  }
+  return false;
+}
+
+// 宣言のコメントを参照してください。
+bool term::SpecialComment::operator()(reader::IReader* reader,
+                                    unsigned int* size) {
+  unicode::UniString code(unicode::Convert(
+      reader->Peek(kSpecialCommentReadSize)));
+  if (code == unicode::Convert("#!r6rs")) {
+    *size = kSpecialCommentReadSize;
+    return true;
+  }
+  return false;
+}
index 96b5f55..a914568 100644 (file)
@@ -321,6 +321,26 @@ struct Boolean {
   // trueを返した場合、sizeにはトークンの文字数が返却されます。
   bool operator()(reader::IReader* reader, unsigned int* size);
 };
+
+// commentにおける、#; のチェックを提供します。
+struct DatumComment {
+  // readerからチェックのために読み出すサイズです。
+  static const int kDatumCommentReadSize = 2;
+
+  // readerの先頭から、#;に一致するかどうかを返します。
+  // trueを返した場合、sizeにはトークンの文字数が返却されます。
+  bool operator()(reader::IReader* reader, unsigned int* size);
+};
+
+// commentにおける #!r6rsのチェックを提供します。
+struct SpecialComment {
+  // readerからチェックのために読み出すサイズです。
+  static const int kSpecialCommentReadSize = 6;
+
+  // readerの先頭から、#!r6rsに一致するかどうかを返します。
+  // trueを返した場合、sizeにはトークンの文字数が返却されます。
+  bool operator()(reader::IReader* reader, unsigned int* size);
+};
 }
 }
 }
diff --git a/test/comment_lexer_test.cpp b/test/comment_lexer_test.cpp
new file mode 100755 (executable)
index 0000000..f4c634b
--- /dev/null
@@ -0,0 +1,118 @@
+#include <test/gtest/gtest.h>
+#include "lib/textarrayformat.h"
+#include "src/lexer/comment_lexer.h"
+#include "src/encoding_reader.h"
+#include "src/string_reader.h"
+#include "src/unicode.h"
+#include "lib/scoped_ptr.h"
+#include "src/utf8_transcoder.h"
+#include "src/lexeme.h"
+
+namespace textarrayformat = utility::textarrayformat;
+namespace lexer = utakata::lexer;
+namespace unicode = utakata::unicode;
+namespace reader = utakata::reader;
+namespace transcoder = utakata::transcoder;
+
+class CommentLexerTest : public ::testing::Test {
+ protected:
+  virtual void SetUp() {
+    gen.reset(new textarrayformat::TextArrayGenerator("========="));
+    gen->Punctuate("(hoge) ; comment \nhuga");
+    gen->Punctuate("#!r6rs");
+    gen->Punctuate("#| hoge \n #|ss");
+    gen->Punctuate("#| \nhoge #|huga|# \n|#123");
+    gen->Punctuate("#;data");
+  }
+
+  akebono::scoped_ptr<textarrayformat::TextArrayGenerator> gen;
+};
+
+TEST_F(CommentLexerTest, OnelineComment) {
+  textarrayformat::TextArrayReader textarray(*gen);
+
+  reader::StringReader sr(textarray.GetBlockAt(0));
+  reader::EncodingReader reader(&sr, new transcoder::UTF8Transcoder);
+
+  lexer::CommentLexer lexer;
+  EXPECT_FALSE(lexer.Lex(&reader));
+  reader.Read(7);
+
+  akebono::scoped_ptr<lexer::Lexeme> l(lexer.Lex(&reader));
+  EXPECT_TRUE(l.get() == NULL);
+  unicode::UniString st(unicode::Convert(reader.Read(4)));
+  EXPECT_TRUE(st == unicode::UniString("huga"));
+}
+
+TEST_F(CommentLexerTest, SpecialComment) {
+  textarrayformat::TextArrayReader textarray(*gen);
+
+  reader::StringReader sr(textarray.GetBlockAt(1));
+  reader::EncodingReader reader(&sr, new transcoder::UTF8Transcoder);
+
+  lexer::CommentLexer lexer;
+  akebono::scoped_ptr<lexer::Lexeme> l(lexer.Lex(&reader));
+
+  EXPECT_TRUE(l.get() ==  NULL);
+  EXPECT_TRUE(reader.IsEof());
+}
+
+TEST_F(CommentLexerTest, BlockCommentNoNested) {
+  textarrayformat::TextArrayReader textarray(*gen);
+  akebono::scoped_ptr<lexer::Lexeme> l;
+  reader::StringReader sr(textarray.GetBlockAt(2));
+  reader::EncodingReader reader(&sr, new transcoder::UTF8Transcoder);
+  lexer::CommentLexer lexer;
+  l.reset(lexer.Lex(&reader));
+
+  EXPECT_TRUE(l.get() ==  NULL);
+  unicode::UniString tmp(unicode::Convert(reader.Read(2)));
+  EXPECT_TRUE(tmp == unicode::Convert("ss"));
+}
+
+TEST_F(CommentLexerTest, NestedBlockComment) {
+  textarrayformat::TextArrayReader textarray(*gen);
+  akebono::scoped_ptr<lexer::Lexeme> l;
+  reader::StringReader sr(textarray.GetBlockAt(3));
+  reader::EncodingReader reader(&sr, new transcoder::UTF8Transcoder);
+  lexer::CommentLexer lexer;
+  l.reset(lexer.Lex(&reader));
+
+  EXPECT_TRUE(lexer.Lex(&reader));
+  unicode::UniString tmp(unicode::Convert(reader.Read(3)));
+  EXPECT_TRUE(tmp == unicode::Convert("123"));
+}
+
+TEST_F(CommentLexerTest, DatumComment) {
+  textarrayformat::TextArrayReader textarray(*gen);
+  akebono::scoped_ptr<lexer::Lexeme> l;
+  reader::StringReader sr(textarray.GetBlockAt(4));
+  reader::EncodingReader reader(&sr, new transcoder::UTF8Transcoder);
+  lexer::CommentLexer lexer;
+
+  // datum comment\82Ì\8fê\8d\87\82É\8cÀ\82è\81A\83g\81[\83N\83\93\82Ì\95Ô\8bp\82ª\95K\97v\82Æ\82È\82è\82Ü\82·\81B
+  // \82±\82ê\82Í#; <interlexeme space> <datum>\82Ì<datum>\82ª\91O\95û\90é\8c¾\82³\82ê\82Ä\82¢\82é
+  // \8aÖ\8cW\8fã\81A\8e\9a\8bå\89ð\90Í\82Å\82Í\82È\82­\8d\\95\89ð\90Í\83\8c\83x\83\8b\82Å\82Ì\83R\83\81\83\93\83g\82ª\95K\97v\82Æ\82È\82é\82½\82ß\81A
+  // \82»\82Ì\94»\95Ê\82ª\95K\97v\82Å\82 \82é\82½\82ß\82Å\82·\81B
+  // datum comment\82Í\81A\82»\82Ì\90«\8e¿\8fã\81A\8aô\8fd\82É\82à\83l\83X\83g\82·\82é\89Â\94\\90«\82ª\82 \82è\82Ü\82·\81B
+  l.reset(lexer.Lex(&reader));
+  EXPECT_TRUE(l.get() != NULL);
+  unicode::UniString tmp(unicode::Convert(reader.Read(4)));
+  EXPECT_TRUE(tmp == unicode::Convert("data"));
+}
+
+
+int main(int argc, char** argv) {
+  testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/test/lexer_dispatcher_test.cpp.bk b/test/lexer_dispatcher_test.cpp.bk
deleted file mode 100644 (file)
index 1ed1bca..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#include <test/gtest/gtest.h>
-#include "src/lexer_dispatcher.h"
-#include "src/lexer_interface.h"
-#include "src/unicode.h"
-
-
-namespace lexer = ::utakata::lexer;
-namespace reader = ::utakata::reader;
-namespace lexeme = ::utakata::lexeme;
-namespace unicode = ::utakata::unicode;
-
-class Lexer1 : public lexer::IPartOfLexer {
- public:
-  virtual ~Lexer1() {}
-
-  lexeme::ILexeme* Lex(const unicode::UniString& string,
-                       reader::StreamReader* stream) {
-    stream.read(1);
-    
-  }
-};
-
-class Term1 : public lexer::ILexerDispatchTerm {
- public:
-  virtual ~Term1() {}
-
-  bool IsDispatch(const unicode::UniString& string) const {
-    if (string == UniString("test")) {
-      return true;
-    }
-    return false;
-  }
-};
-
-class Creator1 : public lexer::ILexerCreator {
- public:
-  virtual ~Creator1() {}
-
-  virtual IPartOfLexer* Create() const;
-  virtual ILexerDispatchTerm* GetTerm() const;
-
-};
-
-class LexerTest : public ::testing::Test {
- protected:
-  virtual void SetUp() {
-    Creator1 c;
-    lexer::LexerDispatcher dispatcher;
-    dispatcher.AppendLexer(c);
-
-    reader.append("test string 'hoge'");
-  }
-
-  lexer::LexerDispatcher dispatcher;
-  reader::StreamReader reader;
-};
-
-TEST(LexerTest, Dispatch1) {
-  // ディスパッチを行うテスト。
-
-
-  lexer::IPartOfLexer* lexer = NULL;
-  unicode::UniString& string("test");
-
-  EXPECT_TRUE(dispatcher.Dispatch(string, lexer));
-  EXPECT_NE(NULL, lexer);
-
-  smart_ptr<lexeme::ILexeme> lexeme(lexer->Lex(reader));
-  EXPECT_FALSE(lexeme.IsNull());
-}
-
-int main(int argc, char** argv)
-{
-  testing::InitGoogleTest(&argc, argv);
-  
-  return RUN_ALL_TESTS();
-}
-
diff --git a/test/sublexer_test.cpp.bk b/test/sublexer_test.cpp.bk
deleted file mode 100755 (executable)
index 1830a9d..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <functional>
-
-
-#include "../simpletest.h"
-
-#include "../sublexer.h"
-
-
-int main(int argc, char *argv[])
-{
-    simpletest::SimpleTestSuite suite("sublexer's test");
-//     suite.addTester(sfcr::screate(utf8_multichar_test, suite.getAsserter()));
-//     suite.addTester(sfcr::screate(unicode_test, suite.getAsserter()));
-//     suite.addTester(sfcr::screate(unicode_util_test, suite.getAsserter()));
-    return suite.run();
-}