Index: /cfg_oil/trunk/cfg/cfg.cpp
===================================================================
--- /cfg_oil/trunk/cfg/cfg.cpp	(revision 8)
+++ /cfg_oil/trunk/cfg/cfg.cpp	(revision 8)
@@ -0,0 +1,355 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ *  Copyright (C) 2010 by Meika Sugimoto
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include "cfg.hpp"
+#include <boost/program_options.hpp>
+#include <boost/spirit.hpp>
+
+#include <crtdbg.h>
+
+namespace
+{
+
+  //! A±µ½XbV
+ / ðPêÌXbV
+Éu··é
+  std::string slashes_to_single_slash( std::string const& str )
+  {
+    std::string result( str );
+    std::string::size_type pos = 0; 
+    while ( ( pos = result.find( "//", pos ) ) != std::string::npos )
+    {
+      result.erase( pos, 1 );
+    }
+    return result;
+  }
+
+  //! N®IvVÌðÍ
+  int parse_program_options( int argc, char* argv[] )
+  {
+    namespace po = boost::program_options;
+    int pass = 0;
+
+    // êÊIvV
+    po::options_description generic( _( "Generic options" ) );
+    generic.add_options()
+      ( "help", _( "display this information" ) )    
+      ( "version,v", _( "display cfg version number" ) )
+      ;
+
+    // ÝèIvV
+    po::options_description config( _( "Configuration" ) );
+    config.add_options()
+      ( "kernel,k", po::value< std::string >()->default_value( std::string( "atk" ) ), _( "kernel type (default: atk)" ) )
+      ( "pass,p", po::value< int >( &pass )->default_value( 0 ), _( "run for pass #`arg\'" ) )
+      ( "include-path,I", po::value< std::vector< std::string > >(), _( "include path" ) )
+      ( "template-file,T", po::value< std::string >(), _( "template file" ) )
+      ( "input-charset", po::value< std::string >()->default_value( std::string( "ascii" ) ), _( "character set of input file (default: ascii)" ) )
+      ( "api-table", po::value< std::vector< std::string > >(), _( "specify static API table" ) )
+      ( "cfg1-def-table", po::value< std::vector< std::string > >(), _( "specify cfg1 definition table" ) )
+      ( "cfg1_out", po::value< std::string >()->default_value( std::string( "cfg1_out" ) ), _( "specify file name instead of `cfg1_out.srec\' (default: cfg1_out)" ) )
+      ( "rom-image,r", po::value< std::string >(), _( "ROM image (S-record)" ) )
+      ( "symbol-table,s", po::value< std::string >(), _( "Symbol table (`nm' style)" ) )
+      ( "cfg-directory,d", po::value< std::string >(), _( "cfg directory" ) )
+      ( "msgcat-directory,m", po::value< std::vector< std::string > >(), _( "msgcat(*.po) directory" ) )
+      ( "destination-directory,n", po::value< std::string >()->default_value( "." ), _( "destination directory" ) )
+      ( "alignof-fp", po::value< std::size_t >()->default_value( 1 ), _( "alignment of pointer to function" ) )
+      ( "print-dependencies,M", po::value< std::string >(), _( "output dependencies of source file (for `make\')" ) )
+      ;
+
+    // ñ\¦IvV
+    po::options_description hidden( _( "Hidden options" ) );
+    hidden.add_options()
+      ( "input-file,s", po::value< std::string >(), _( "input file" ) )
+      ;
+    
+    po::options_description cmdline_options;
+    cmdline_options.add( generic ).add( config ).add( hidden );
+
+    po::options_description visible( _( "Allowed options" ) );
+    visible.add( generic ).add( config );
+    
+    po::positional_options_description p;
+    p.add( "input-file", -1 );
+    
+    po::variables_map vm;
+    try
+    {
+      store( po::command_line_parser( argc, argv ).
+            options( cmdline_options ).positional( p ).run(), vm );
+      notify( vm );
+    }
+    catch ( boost::program_options::error& )
+    {
+      toppers::fatal( _( "illegal options" ) );
+    }
+
+    // O[oÏÌÝè
+    if ( vm.count( "print-dependencies" ) )
+    {
+      toppers::global( "print-dependencies" ) = vm["print-dependencies"].as< std::string >();
+      pass = 1; // Ë¶ÖWÌoÍªKvÈêA­§IÉpX1ÉÏX
+    }
+
+    toppers::global( "pass" ) = pass;
+    if ( vm.count( "kernel" ) )
+    {
+      std::string kernel = toppers::tolower( vm["kernel"].as< std::string >() );
+      toppers::global( "kernel" ) = kernel;
+      bool has_class = false;
+      bool has_domain = false;
+
+      if ( kernel == "fmp" )
+      {
+        has_class = true;
+      }
+      if ( kernel == "hrp2" )
+      {
+        has_domain = true;
+      }
+
+      toppers::global( "max-pass" ) = ( has_domain ? 4 : 3 );
+      toppers::global( "has-class" ) = has_class;
+      toppers::global( "has-domain" ) = has_domain;
+    }
+    if ( vm.count( "include-path" ) )
+    {
+      std::vector< std::string > v( vm["include-path"].as< std::vector< std::string > >() );
+      std::transform( v.begin(), v.end(), v.begin(), &slashes_to_single_slash );
+      toppers::global( "include-path" ) = v;
+    }
+    if ( vm.count( "template-file" ) )
+    {
+      toppers::global( "template-file" )
+        = slashes_to_single_slash( vm["template-file"].as< std::string >() );
+    }
+    if ( vm.count( "input-file" ) )
+    {
+      toppers::global( "input-file" )
+        = slashes_to_single_slash( vm["input-file"].as< std::string >() );
+    }
+    if ( vm.count( "input-charset" ) )
+    {
+      std::string input_charset( toppers::tolower( vm["input-charset"].as< std::string >() ) );
+      toppers::global( "input-charset" ) = input_charset;
+
+      toppers::codeset_t codeset = toppers::ascii;
+      if ( ( input_charset == "cp932" )
+        || ( input_charset == "shift_jis" )
+        || ( input_charset == "sjis" ) )
+      {
+        codeset = toppers::shift_jis;
+      }
+      else if ( ( input_charset == "eucjp" )
+        || ( input_charset == "euc-jp" )
+        || ( input_charset == "euc" ) )
+      {
+        codeset = toppers::euc_jp;
+      }
+      else if ( ( input_charset == "utf-8" )
+        || ( input_charset == "utf8" ) )
+      {
+        codeset = toppers::utf8;
+      }
+      toppers::global( "codeset" ) = codeset;
+    }
+    if ( vm.count( "api-table" ) )
+    {
+      std::vector< std::string > v( vm["api-table"].as< std::vector< std::string > >() );
+      std::transform( v.begin(), v.end(), v.begin(), &slashes_to_single_slash );
+      toppers::global( "api-table" ) = v;
+    }
+    if ( vm.count( "cfg1-def-table" ) )
+    {
+      std::vector< std::string > v( vm["cfg1-def-table"].as< std::vector< std::string > >() );
+      std::transform( v.begin(), v.end(), v.begin(), &slashes_to_single_slash );
+      toppers::global( "cfg1-def-table" ) = v;
+    }
+    if ( vm.count( "cfg1_out" ) )
+    {
+      toppers::global( "cfg1_out" ) = vm["cfg1_out"].as< std::string >();
+    }
+    else
+    {
+      toppers::global( "cfg1_out" ) = std::string( "cfg1_out" );
+    }
+    if ( vm.count( "cfg-directory" ) )
+    {
+      std::string cfg_directory( vm["cfg-directory"].as< std::string >() );
+      toppers::global( "cfg-directory" ) = slashes_to_single_slash( cfg_directory );
+      toppers::load_msgcat( cfg_directory );
+    }
+    if ( vm.count( "msgcat-directory" ) )
+    {
+      std::vector< std::string > msgcat_dirs( vm["msgcat-directory"].as< std::vector< std::string > >() );
+      std::transform( msgcat_dirs.begin(), msgcat_dirs.end(), msgcat_dirs.begin(), &slashes_to_single_slash );
+      std::for_each( msgcat_dirs.begin(), msgcat_dirs.end(), &toppers::load_msgcat );
+    }
+    if ( true ) // include-path ðóÉµÄÍÈçÈ¢
+    {
+      std::vector< std::string > include_path;
+      boost::any t( toppers::global( "include-path" ) );
+      if ( !t.empty() )
+      {
+        include_path = boost::any_cast< std::vector< std::string > >( t );
+      }
+      include_path.push_back( toppers::get_global< std::string >( "cfg-directory" ) );
+      toppers::global( "include-path" ) = include_path;
+    }
+    if ( vm.count( "output-directory" ) )
+    {
+      toppers::global( "output-directory" ) = slashes_to_single_slash( vm["output-directory"].as< std::string >() );
+    }
+    if ( vm.count( "rom-image" ) )
+    {
+      toppers::global( "rom-image" ) = slashes_to_single_slash( vm["rom-image"].as< std::string >() );
+    }
+    if ( vm.count( "symbol-table" ) )
+    {
+      toppers::global( "symbol-table" ) = slashes_to_single_slash( vm["symbol-table"].as< std::string >() );
+    }
+    else
+    {
+      toppers::global( "symbol-table" ) = toppers::get_global< std::string >( "kernel" ) + ".syms";
+    }
+    if ( vm.count( "id-output-file" ) )
+    {
+      toppers::global( "id-output-file" ) = slashes_to_single_slash( vm["id-output-file"].as< std::string >() );
+    }
+    if ( vm.count( "id-input-file" ) )
+    {
+      toppers::global( "id-input-file" ) = slashes_to_single_slash( vm["id-input-file"].as< std::string >() );
+    }
+    if ( vm.count( "alignof-fp" ) )
+    {
+      toppers::global( "alignof-fp" ) = vm["alignof-fp"].as< std::size_t >();
+    }
+    toppers::global( "external-id" ) = vm.count( "external-id" ) ? true : false;
+
+    toppers::global( "version" ) = std::string( CFG_VERSION );
+
+    if ( vm.count( "version" ) )
+    {
+      std::cout << "TOPPERS Kernel Configurator version " << CFG_VERSION << std::endl;
+      toppers::global( "pass0" ) = true;
+    }
+    if ( vm.count( "help" ) )
+    {
+      toppers::global( "help" ) = boost::lexical_cast< std::string >( visible );
+      std::cout << visible << std::endl;
+      toppers::global( "pass0" ) = true;
+    }
+    return pass;
+  }
+
+}
+
+//! RtBM
+[^ÌC
+int cfg_main( int argc, char* argv[] )
+{
+  using namespace toppers;
+
+  std::string const cfg_path( argv[0] );
+  std::string const cfg_name( "cfg" );
+  std::string::const_iterator iter = std::find_end( cfg_path.begin(), cfg_path.end(), cfg_name.begin(), cfg_name.end() );
+  // Â«ÏÌT[`ÜÅÍsíÈ¢
+  std::string cfg_dir( cfg_path.begin(), iter );
+  if ( *cfg_dir.rbegin() == '/' || *cfg_dir.rbegin() == '\\' )
+  {
+    cfg_dir.resize( cfg_dir.size() - 1 );
+  }
+  toppers::global( "cfg-directory" ) = cfg_dir;
+  toppers::global( "argv0" ) = std::string( argv[ 0 ] );  // vO¼
+  toppers::global( "timestamp" ) = cfg_timestamp();       // ^CX^v
+
+  int pass = parse_program_options( argc, argv );
+  bool ( * pfn_cfg[] )() = { &cfg0_main, &cfg1_main, &cfg2_main, };
+  int max_pass = toppers::get_global< int >( "max-pass" );
+
+  if ( pass < 0 || max_pass < pass )
+  {
+    fatal( _( "illegal cfg pass #%d" ), pass );
+  }
+
+  if ( !( *pfn_cfg[ pass ] )() )
+  {
+    return EXIT_FAILURE;
+  }
+  return EXIT_SUCCESS;
+}
+
+int main( int arg, char* argv[] )
+{
+  int status;
+  
+  // [N¸pÌú»
+  _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+
+  try
+  {
+    toppers::set_program_name( "cfg" );
+    status = cfg_main( arg, argv );
+    if ( status != EXIT_SUCCESS && toppers::get_error_count() == 0 )
+    {
+      std::fprintf( stderr, "cfg: %s\n", _( "unknown error" ) );
+    }
+    if ( toppers::get_error_count() > 0 )
+    {
+      status = EXIT_FAILURE;
+    }
+  }
+  catch ( toppers::normal_exit& )
+  {
+    status = EXIT_SUCCESS;
+  }
+  catch ( std::exception& e )
+  {
+    std::fprintf( stderr, "cfg: %s\n", e.what() );
+    status = EXIT_FAILURE;
+  }
+  catch ( ... )
+  {
+    std::fprintf( stderr, "cfg: %s\n", _( "internal error" ) );
+    status = EXIT_FAILURE;
+  }
+  return status;
+}
Index: /cfg_oil/trunk/cfg/cfg.hpp
===================================================================
--- /cfg_oil/trunk/cfg/cfg.hpp	(revision 8)
+++ /cfg_oil/trunk/cfg/cfg.hpp	(revision 8)
@@ -0,0 +1,78 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#ifndef CFG_HPP_
+#define CFG_HPP_
+
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+#include <vector>
+#include <sstream>
+#include <iostream>
+#include <algorithm>
+#include <map>
+#include "toppers/workaround.hpp"
+#include "toppers/codeset.hpp"
+#include "toppers/global.hpp"
+#include "toppers/diagnostics.hpp"
+#include "toppers/text.hpp"
+#include "toppers/misc.hpp"
+#include "toppers/oil/preprocess.hpp"
+#include "toppers/oil/factory.hpp"
+#include "toppers/oil/cfg1_out.hpp"
+#include <boost/utility.hpp>
+#include <boost/format.hpp>
+
+#define CFG_VERSION cfg_version
+
+bool cfg0_main();
+bool cfg1_main();
+bool cfg2_main();
+void cfg_init();
+
+extern char const cfg_version[];
+
+std::tr1::int64_t cfg_timestamp();
+
+void assign_id( toppers::oil::oil_definition::object_parameter_def api_map );
+
+#endif  // ! CFG_HPP_
Index: /cfg_oil/trunk/cfg/cfg.vcproj
===================================================================
--- /cfg_oil/trunk/cfg/cfg.vcproj	(revision 8)
+++ /cfg_oil/trunk/cfg/cfg.vcproj	(revision 8)
@@ -0,0 +1,433 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="cfg"
+	ProjectGUID="{0C8E059D-E1E3-4753-8BD5-1A7098316F6E}"
+	RootNamespace="cfg"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/GR /D &quot;_CONSOLE&quot;"
+				Optimization="0"
+				AdditionalIncludeDirectories="$(SolutionDir)"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				GenerateDebugInformation="true"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				AdditionalIncludeDirectories="$(SolutionDir)"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				GenerateDebugInformation="true"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="source"
+			>
+			<Filter
+				Name="cfg"
+				>
+				<File
+					RelativePath=".\cfg.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\cfg0.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\cfg1.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\cfg2.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\cfg_init.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\cfg_version.cpp"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="toppers"
+				>
+				<File
+					RelativePath="..\toppers\builtin_function.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\c_chlit_parser.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\c_ident_parser.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\c_int_parser.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\c_keywords.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\c_plus_plus_keywords.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\c_strlit_parser.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\cpp.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\diagnostics.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\gettext.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\global.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\io.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\macro_processor.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\mbchar_parser.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\nm_symbol.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\output_file.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\s_record.cpp"
+					>
+				</File>
+				<Filter
+					Name="oil"
+					>
+					<File
+						RelativePath="..\toppers\oil\cfg1_out.cpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\configuration_manager.cpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\factory.cpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\oil_object.cpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\oil_parse.cpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\preprocess.cpp"
+						>
+					</File>
+				</Filter>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="header"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<Filter
+				Name="toppers"
+				>
+				<File
+					RelativePath="..\toppers\c_expr.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\c_parser.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\c_pp_line.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\codeset.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\config.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\cpp.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\csv.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\debug.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\diagnostics.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\gettext.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\global.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\io.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\macro_processor.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\misc.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\nm_symbol.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\output_file.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\s_record.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\text.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\text_line.hpp"
+					>
+				</File>
+				<File
+					RelativePath="..\toppers\workaround.hpp"
+					>
+				</File>
+				<Filter
+					Name="oil"
+					>
+					<File
+						RelativePath="..\toppers\oil\cfg1_out.hpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\configuration_manager.hpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\factory.hpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\oil_object.hpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\oil_parser.hpp"
+						>
+					</File>
+					<File
+						RelativePath="..\toppers\oil\preprocess.hpp"
+						>
+					</File>
+				</Filter>
+			</Filter>
+			<Filter
+				Name="cfg"
+				>
+				<File
+					RelativePath=".\cfg.hpp"
+					>
+				</File>
+				<File
+					RelativePath=".\require_modules.hpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="\[X t@C"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /cfg_oil/trunk/cfg/cfg0.cpp
===================================================================
--- /cfg_oil/trunk/cfg/cfg0.cpp	(revision 8)
+++ /cfg_oil/trunk/cfg/cfg0.cpp	(revision 8)
@@ -0,0 +1,64 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include "toppers/global.hpp"
+#include "toppers/diagnostics.hpp"
+
+bool cfg0_main()
+{
+  using namespace toppers;
+
+  try
+  {
+    if ( global( "pass0" ).empty() && !get_global< bool >( "pass0" ) )
+    {
+      goto failure;
+    }
+  }
+  catch ( boost::bad_any_cast& )
+  {
+    goto failure;
+  }
+  return true;
+
+failure:
+  fatal( _( "pass # is not specified" ) );
+  return false;
+}
Index: /cfg_oil/trunk/cfg/cfg1.cpp
===================================================================
--- /cfg_oil/trunk/cfg/cfg1.cpp	(revision 8)
+++ /cfg_oil/trunk/cfg/cfg1.cpp	(revision 8)
@@ -0,0 +1,80 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <fstream>
+#include "toppers/output_file.hpp"
+#include "cfg.hpp"
+
+/*!
+ *  \brief  pXP
+ *  \retval true  ¬÷
+ *  \retval false ¸s
+ */
+bool cfg1_main()
+{
+  using namespace toppers;
+  using namespace toppers::oil;
+
+  std::string kernel( get_global< std::string >( "kernel" ) );
+  oil::factory factory( kernel );
+
+  std::string input_file;
+  try
+  {
+    input_file = get_global< std::string >( "input-file" );
+  }
+  catch ( boost::bad_any_cast& )
+  {
+    fatal( _( "no input files" ) );
+  }
+  codeset_t codeset = get_global< codeset_t >( "codeset" );
+
+  std::string cfg1_out_name( get_global< std::string >( "cfg1_out" ) );
+  std::auto_ptr< cfg1_out > cfg1_out( factory.create_cfg1_out( cfg1_out_name + ".c" ) );
+  cfg1_out->load_cfg( input_file, codeset, factory.get_object_definition_info() );
+  cfg1_out->generate();
+
+  if ( get_error_count() > 0 )
+  {
+    return false;
+  }
+  output_file::save();
+  return true;
+}
Index: /cfg_oil/trunk/cfg/cfg2.cpp
===================================================================
--- /cfg_oil/trunk/cfg/cfg2.cpp	(revision 8)
+++ /cfg_oil/trunk/cfg/cfg2.cpp	(revision 8)
@@ -0,0 +1,130 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <fstream>
+#include <sstream>
+#include "toppers/diagnostics.hpp"
+#include "toppers/s_record.hpp"
+#include "toppers/macro_processor.hpp"
+#include "cfg.hpp"
+#include <boost/spirit.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+
+
+/*!
+ *  \brief  pXQ
+ *  \retval true  ¬÷
+ *  \retval false ¸s
+ */
+bool cfg2_main()
+{
+  using namespace toppers;
+  using namespace toppers::oil;
+
+  std::string kernel( get_global< std::string >( "kernel" ) );
+  oil::factory factory( kernel );
+
+  // *.cfgÆcfg1_out.srecÌÇÝÝ
+  std::string input_file;
+  try
+  {
+    input_file = get_global< std::string >( "input-file" );
+  }
+  catch ( boost::bad_any_cast& )
+  {
+    fatal( _( "no input files" ) );
+  }
+  std::string cfg1_out_name( get_global< std::string >( "cfg1_out" ) );
+  std::auto_ptr< cfg1_out > cfg1_out( factory.create_cfg1_out( cfg1_out_name ) );
+
+  codeset_t codeset = get_global< codeset_t >( "codeset" );
+  cfg1_out->load_cfg( input_file, codeset, factory.get_object_definition_info() );
+  cfg1_out->load_srec();
+  cfg1_out::cfg_obj_map cfg_obj_map( cfg1_out->merge() );
+
+  // IDÔÌt¯
+  //assign_id(cfg_obj_map);
+  std::auto_ptr< macro_processor > mproc( factory.create_macro_processor( factory.get_hook_on_assign(), *cfg1_out, cfg_obj_map ) );
+
+  // ev[g
+  boost::any template_file( global( "template-file" ) );
+  namespace fs = boost::filesystem;
+  fs::path cfg_dir( get_global< std::string >( "cfg-directory" ), fs::native );
+  std::vector< std::string > include_paths = get_global< std::vector< std::string > >( "include-path" );
+  include_paths.push_back( cfg_dir.empty() ? "." : cfg_dir.native_file_string() );
+  if ( !template_file.empty() )
+  {
+    toppers::text in_text;
+    toppers::text pp_text;
+    std::string file_name( boost::any_cast< std::string& >( template_file ) );
+
+    in_text.set_line( file_name, 1 );
+    std::ifstream ifs( file_name.c_str() );
+    in_text.append( ifs );
+    macro_processor::preprocess( in_text, pp_text );
+    mproc->evaluate( pp_text );
+  }
+  else  // ev[gt@Cªwè³êÄ¢È¢ÌÅA¤Êªikernel.tfjÌÝð
+  {
+    fs::path kernel_cfg_template_file( cfg_dir/fs::path( "../../kernel/kernel.tf" ) );
+    if ( !fs::exists( kernel_cfg_template_file ) )
+    {
+      error( _( "cannot open file `%1%\'" ), kernel_cfg_template_file.native_file_string() );
+    }
+    else
+    {
+      toppers::text in_text;
+      toppers::text pp_text;
+
+      in_text.set_line( kernel_cfg_template_file.native_file_string(), 1 );
+      std::ifstream ifs( kernel_cfg_template_file.native_file_string().c_str() );
+      in_text.append( ifs );
+      macro_processor::preprocess( in_text, pp_text );
+      mproc->evaluate( pp_text );
+    }
+  }
+  if ( get_error_count() > 0 )
+  {
+    return false;
+  }
+  output_file::save();
+  return true;
+}
Index: /cfg_oil/trunk/cfg/cfg_init.cpp
===================================================================
--- /cfg_oil/trunk/cfg/cfg_init.cpp	(revision 8)
+++ /cfg_oil/trunk/cfg/cfg_init.cpp	(revision 8)
@@ -0,0 +1,44 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+void cfg_init()
+{
+}
Index: /cfg_oil/trunk/cfg/cfg_version.cpp
===================================================================
--- /cfg_oil/trunk/cfg/cfg_version.cpp	(revision 8)
+++ /cfg_oil/trunk/cfg/cfg_version.cpp	(revision 8)
@@ -0,0 +1,82 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#define __STDC_CONSTANT_MACROS  1
+#include "cfg.hpp"
+#include <ctime>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+//! cfgÌo[Wîñ
+extern char const cfg_version[] = "1.5.0";
+
+/*!
+ *  \brief  vOt@C(cfg or cfg.exe)Ì^CX^vðæ¾·éB
+ *  \return ^CX^vð64rbg®lÆµÄÔ·B
+ *
+ *  ÔplÌ`®Í
+ *
+ *  YYYYMMDDhhmmss
+ *
+ *  ÆÈéBYYYYÍNAMMÍADDÍúAhhÍAmmÍªAssÍb
+ *
+ *  \note   t@C¼Í main Ìø argv[0] ðgÁÄ¢éBPATH ÍõµÈ¢ÌÅÓ!
+ *  \note   ±ÌÖÍ stat ÖÉË¶µÄ¢é½ßÚA«Éâèª éB
+ */
+std::tr1::int64_t cfg_timestamp()
+{
+  std::tr1::int64_t result;
+
+  try
+  {
+    std::string program_name = toppers::get_global< std::string >( "argv0" );
+
+    struct stat sb;
+    stat( program_name.c_str(), &sb );
+    struct tm t = *localtime( &sb.st_mtime );
+    result = ( t.tm_year + 1900 ) * INT64_C( 10000000000 ) + ( t.tm_mon + 1 ) * INT64_C( 100000000 ) + t.tm_mday * 1000000
+      + t.tm_hour * 10000 + t.tm_min * 100 + t.tm_sec;
+  }
+  catch ( ... )
+  {
+    result = -1;
+  }
+  return result;
+}
Index: /cfg_oil/trunk/cfg/require_modules.hpp
===================================================================
--- /cfg_oil/trunk/cfg/require_modules.hpp	(revision 8)
+++ /cfg_oil/trunk/cfg/require_modules.hpp	(revision 8)
@@ -0,0 +1,56 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   require_module.hpp
+ *  \brief  T|[gÎÛJ[lÌ½ßÌW
+[v
+ *
+ *  \todo   ASPÈOÌJ[lðT|[g·éÆ«ÍA±Ìwb_t@Cð¶Ý·éfBNgð³É
+ *          ©®¶¬³¹é±ÆBiOSEK SGÆÞÌû@Hj
+ */
+#define REQUIRE_MODULE( name ) \
+  namespace name { bool init(); bool call_init = init(); }
+
+namespace toppers { namespace oil {
+
+  REQUIRE_MODULE( atk1 )
+
+} }
Index: /cfg_oil/trunk/system_generator.sln
===================================================================
--- /cfg_oil/trunk/system_generator.sln	(revision 8)
+++ /cfg_oil/trunk/system_generator.sln	(revision 8)
@@ -0,0 +1,20 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cfg", "cfg\cfg.vcproj", "{0C8E059D-E1E3-4753-8BD5-1A7098316F6E}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{0C8E059D-E1E3-4753-8BD5-1A7098316F6E}.Debug|Win32.ActiveCfg = Debug|Win32
+		{0C8E059D-E1E3-4753-8BD5-1A7098316F6E}.Debug|Win32.Build.0 = Debug|Win32
+		{0C8E059D-E1E3-4753-8BD5-1A7098316F6E}.Release|Win32.ActiveCfg = Release|Win32
+		{0C8E059D-E1E3-4753-8BD5-1A7098316F6E}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: /cfg_oil/trunk/toppers/builtin_function.cpp
===================================================================
--- /cfg_oil/trunk/toppers/builtin_function.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/builtin_function.cpp	(revision 8)
@@ -0,0 +1,788 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <cstdlib>
+#include <cerrno>
+#include <string>
+#include <vector>
+#include <utility>
+#include <algorithm>
+#include <ostream>
+#include <utility>
+#include "toppers/macro_processor.hpp"
+#include "toppers/diagnostics.hpp"
+#include "toppers/gettext.hpp"
+#include "toppers/cpp.hpp"
+#include <boost/format.hpp>
+#include <boost/utility.hpp>
+#include <boost/lexical_cast.hpp>
+
+namespace toppers
+{
+  namespace
+  {
+    typedef macro_processor::element element;
+    typedef macro_processor::var_t var_t;
+    typedef macro_processor::context context;
+
+    inline std::tr1::int64_t get_i( var_t const& var, context const* p_ctx )
+    {
+      return macro_processor::to_integer( var, p_ctx );
+    }
+    inline std::string get_s( var_t const& var, context const* p_ctx )
+    {
+      return macro_processor::to_string( var, p_ctx );
+    }
+
+  }
+
+  /*!
+    *  \brief  øÌÂ`FbN
+    *  \param[in]  line    sÔîñ
+    *  \param[in]  arity   øÌÂ
+    *  \param[in]  valid   úÒµÄ¢éøÌÂ
+    *  \param[in]  function_name gÝÝÖ¼
+    */
+  bool macro_processor::check_arity( text_line const& line, std::size_t arity, std::size_t valid, char const* function_name )
+  {
+    bool result = false;
+    if ( arity < valid )
+    {
+      error( line, _( "too few arguments for `%1%\'" ), function_name );
+    }
+    else if ( arity > valid )
+    {
+      error( line, _( "too many arguments for `%1%\'" ), function_name );
+    }
+    else
+    {
+      result = true;
+    }
+    return result;
+  }
+
+  /*!
+   *  \brief  Ï_vÌ½ßÌ<<Zq
+   *  \param[in,out]  ostr  oÍXg[
+   *  \param[in]      arg   ÏðQÆ·é½ßÌyA
+   *  \return         ostrðÔ·
+   *  \note »ÝÌÀÅÍAarg.second ÍgpµÄ¢È¢B
+   */
+  std::ostream& operator<<( std::ostream& ostr, std::pair< var_t const*, context const* > const& arg )
+  {
+    for ( var_t::const_iterator iter( arg.first->begin() ), last( arg.first->end() ); iter != last; ++iter )
+    {
+      if ( !iter->s.empty() )
+      {
+        ostr << iter->s;
+      }
+      else if ( iter->i )
+      {
+        ostr << iter->i.get();
+      }
+      if ( boost::next( iter ) != last )
+      {
+        ostr << ",";
+      }
+    }
+    return ostr;
+  }
+
+  /*!
+   *  \brief  XgÌ·³
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÆµÄwèµ½t«XgÌvfðÔ·B
+   *  æ1}NÀøªt«XgÅÈ¢êÍ1ðÔ·BÜ½Aæ1}NÀøª³øÈÏÌêÍ0ðÔ·B
+   */
+  var_t bf_length( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 1, "LENGTH" ) )
+    {
+      std::tr1::int64_t size = arg_list.front().size();
+      e.i = size;
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  ¶ñÌêv»è
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÆæ2}NÀøð¶ñÆµÄärµAêv·éêÍ^ðA»¤ÅÈ¯êÎUðÔ·B
+   */
+  var_t bf_eq( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "EQ" ) )
+    {
+      e.i = get_s( arg_list[ 0 ], p_ctx ) == get_s( arg_list[ 1 ], p_ctx );
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  ãÖl
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøª³øÈÏÌêÍæ2ÀøðÔ·B»Ì¼Íæ1ÀøðÔ·B
+   */
+  var_t bf_alt( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "ALT" ) )
+    {
+      if ( !arg_list[0].empty() )
+      {
+        return arg_list[ 0 ];
+      }
+      else
+      {
+        return arg_list[ 1 ];                
+      }
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  XgÌ®ñ
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÆµÄ^¦½t«XgÌevfðAæ2}NÀøÌY¦Æµ½êÌÏð]¿µA
+   *  »Ì]¿ÊÉîÃ«¸É®ñ·éB
+   *
+   *  \example
+   *  $FOO[1] = 20$
+   *  $FOO[2] = 10$
+   *  $FOO[3] = 30$
+   *  $SORT({ 1,2,3 }, "FOO")$
+   *  ¨ { 2,1,3 }
+   *  \endexample
+   */
+  var_t bf_sort( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    var_t result;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "SORT" ) )
+    {
+      var_t list( arg_list[ 0 ] );
+      std::string field( get_s( arg_list[ 1 ], p_ctx ) );
+      std::vector< std::pair< element, std::tr1::int64_t > > temp;
+
+      for ( var_t::const_iterator iter( list.begin() ), last( list.end() ); iter != last; ++iter )
+      {
+        std::tr1::int64_t order = iter->i.get();
+        std::string name( ( boost::format( "%s[%d]" ) % field % order ).str() );
+        std::map< std::string, var_t >::const_iterator m_iter( p_ctx->var_map.find( name ) );
+        if ( m_iter == p_ctx->var_map.end() )
+        {
+          return var_t();
+        }
+        if ( !m_iter->second.empty() )
+        {
+          temp.push_back( std::make_pair( m_iter->second.front(), order ) );
+        }
+      }
+
+      std::stable_sort( temp.begin(), temp.end() );
+
+      for ( std::vector< std::pair< element, std::tr1::int64_t > >::const_iterator iter( temp.begin() ), last( temp.end() );
+            iter != last;
+            ++iter )
+      {
+        element e;
+        e.i = iter->second;
+        result.push_back( e );
+      }
+    }
+    return result;
+  }
+
+  /*!
+   *  \brief  Â«ÏÌæ¾
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÅwèµ½Â«ÏÌlðÔ·B
+   */
+  var_t bf_environ( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 1, "ENVIRON" ) )
+    {
+      std::string name = get_s( arg_list[ 0 ], p_ctx );
+      char const* env = std::getenv( name.c_str() );
+      if ( env == 0 )
+      {
+        return var_t();
+      }
+      e.s = env;
+      errno = 0;
+      char* endptr;
+      if ( std::tr1::int64_t value = std::strtol( env, &endptr, 0 ) )
+      {
+        if ( *endptr == '\0' && errno == 0 )
+        {
+          e.i = value;
+        }
+      }
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  lÌ¶¬
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøðeLXgAæ2}NÀøðlÆµÄAlð¶¬·éB
+   */
+  var_t bf_value( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "VALUE" ) )
+    {
+      if ( !arg_list[0].empty() )
+      {
+        e.s = get_s( arg_list[ 0 ], p_ctx );
+      }
+      if ( !arg_list[1].empty() )
+      {
+        e.i = get_i( arg_list[ 1 ], p_ctx );
+      }
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  ¶ñÌA
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÆæ2}NÀøðAµÄVµ¢¶ñð¶¬·éB
+   */
+  var_t bf_concat( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "CAT" ) )
+    {
+      e.s = get_s( arg_list[ 0 ], p_ctx ) + get_s( arg_list[ 1 ], p_ctx );
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  XgÌI[ÉvfðÇÁ
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÆæ2}NÀøðAµÄVµ¢t«Xgð¶¬·éB
+   */
+  var_t bf_append( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    var_t result;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "APPEND" ) )
+    {
+      result = arg_list[ 0 ];
+      result.insert( result.end(), arg_list[ 1 ].begin(), arg_list[1].end() );
+    }
+    return result;
+  }
+
+  /*!
+   *  \brief  XgÌwèvfÌQÆ
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÅwèµ½XgÌAæ2}NÀøÅwèµ½vfðÔ·B
+   */
+  var_t bf_at( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "CAT" ) )
+    {
+      try
+      {
+        e = arg_list[ 0 ].at( static_cast< std::vector< var_t >::size_type >( get_i( arg_list[1], p_ctx ) ) );
+      }
+      catch ( std::out_of_range& )
+      {
+        // Y¦ªs³
+        // ÁÉ½àµÈ¢ ¨ ±Ì_Å e ªólÅ é±ÆðúÒ
+      }
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  eLXgÌ|ó
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÅwèµ½¶ñð|ó·éB
+   */
+  var_t bf_gettext( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 1, "GETTEXT" ) )
+    {
+      std::string message = get_s( arg_list[ 0 ], p_ctx );
+      e.s = gettext( message );
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  }NÀøÌ®»
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÅwèµ½ú»¶ñÉæÁÄAæ2}NÀøÈ~ð®»·éB
+   *  ®»¶ñÍA%nªg¦È¢±Æð«AprintfÖÌX[p[ZbgÅ éB
+   *  ³mÈdlÍAboost::formatðQÆÌ±ÆB
+   */
+  var_t bf_format( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    std::size_t arity = arg_list.size();
+    if ( arity < 1 )
+    {
+      error( line, _( "too few arguments for `%1%\'" ), "FORMAT" );
+    }
+    boost::format fmt( get_s( arg_list[ 0 ], p_ctx ) );
+    for ( std::size_t i = 1; i < arity; i++ )
+    {
+      std::pair< var_t const*, context const* > arg( &arg_list[i], p_ctx );
+      fmt % arg;
+    }
+    e.s = fmt.str();
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  t«XgàÌTõ
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÅwèµ½t«XgÉÜÜêéæ2}NÀøÅwèµ½lÉµ¢vfðA
+   *  æª©çÉTõ·éB
+   *  µ¢vfª©Â©êÎ»ÌvfÖÌCfbNXðA»¤ÅÈ¯êÎólðÔ·B
+   */
+  var_t bf_find( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "FIND" ) )
+    {
+      var_t list( arg_list[ 0 ] );
+      std::tr1::int64_t value( get_i( arg_list[ 1 ], p_ctx ) );
+
+      for ( var_t::const_iterator iter( list.begin() ), last( list.end() ); iter != last; ++iter )
+      {
+        if ( iter->i.get() == value ) // ­©I
+        {
+          e.i = iter - list.begin();  // iter Í RandomAccessIterator
+          return var_t( 1, e );
+        }
+      }
+    }
+    return var_t();
+  }
+
+  /*!
+   *  \brief  ÍÍwèÉæét«Xg
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÅÅÌlðAæ2}NÀøÅÅãÌlðwè·éB
+   *  { ÅÌl, ÅÌl + 1, ... ÅãÌl }
+   *  ÆÈét«Xgð¶¬·éB
+   *  øª³µ­È¢êÍólðÔ·B
+   */
+  var_t bf_range( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    var_t result;
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "RANGE" ) )
+    {
+      std::tr1::int64_t arg1( get_i( arg_list[ 0 ], p_ctx ) );
+      std::tr1::int64_t arg2( get_i( arg_list[ 1 ], p_ctx ) );
+
+      for ( ; arg1 <= arg2; ++arg1 )
+      {
+        element e;
+        e.i = arg1;
+        result.push_back( e );
+      }
+    }
+    return result;
+  }
+
+  /*!
+   *  \brief  SÏÌ_v
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  }NÀøðwèµ½êA»Ì¶ñ®«Åwèµ½t@CÉ_vµ½¶ñðÇL·éB
+   *  t@C¼ÆµÄA"stdout"ðwèµ½êÍWoÍA"stderr"ðwèµ½êÍWG[ÉoÍ·éB
+   *  t@C¼ðÈªµ½êÍ"stderr"ðwèµ½àÌÆµÄU¤B
+   */
+  var_t bf_dump( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    std::size_t arity = arg_list.size();
+
+    if ( arity > 1 )
+    {
+      error( line, _( "too many arguments for `%1%\'" ), "DUMP" );
+    }
+
+    std::string dump_str;
+
+    // SÏðÈßé
+    for ( std::map< std::string, var_t >::const_iterator iter( p_ctx->var_map.begin() ), last( p_ctx->var_map.end() );
+          iter != last;
+          ++iter )
+    {
+      dump_str += "$" + iter->first + "$ = { ";
+      if ( !iter->second.empty() )
+      {
+        // eÏÌSvf
+        for ( var_t::const_iterator iter2( iter->second.begin() ), last2( iter->second.end() );
+              iter2 != last2;
+              ++iter2 )
+        {
+          dump_str += "\"" + iter2->s + "\"(";
+          if ( iter2->i ) // l®«ª êÎ...
+          {
+            dump_str += boost::lexical_cast< std::string >( *iter2->i );
+          }
+          dump_str += "), ";
+        }
+      }
+      dump_str += " }\n";
+    }
+
+    std::string filename( "stderr" );
+    if ( arity == 1 )
+    {
+      filename = get_s( arg_list[ 0 ], p_ctx );
+    }
+    if ( filename == "stdout" )
+    {
+      fputs( dump_str.c_str(), stdout );
+    }
+    else if ( filename == "stderr" )
+    {
+      fputs( dump_str.c_str(), stderr );
+    }
+    else
+    {
+      std::FILE* stream = std::fopen( filename.c_str(), "a" );
+      if ( stream != 0 )
+      {
+        fputs( dump_str.c_str(), stream );
+        std::fclose( stream );
+      }
+    }
+    element e;
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  ÏÌg[X
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  æ1}NÀøÅwèµ½ÏÌàeðg[X·éB
+   *  æ2}NÀøðwèµ½êA»Ì¶ñ®«Åwèµ½t@CÉg[XàeðÇL·éB
+   *  t@C¼ÆµÄA"stdout"ðwèµ½êÍWoÍA"stderr"ðwèµ½êÍWG[ÉoÍ·éB
+   *  t@C¼ðÈªµ½êÍ"stderr"ðwèµ½àÌÆµÄU¤B
+   */
+  var_t bf_trace( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    std::size_t arity = arg_list.size();
+
+    if ( arity < 1 )
+    {
+      error( line, _( "too few arguments for `%1%\'" ), "TRACE" );
+    }
+    else if ( arity > 2 )
+    {
+      error( line, _( "too many arguments for `%1%\'" ), "TRACE" );
+    }
+
+    var_t value( arg_list[ 0 ] );
+
+    std::string trace_str = "{ ";
+    for ( var_t::const_iterator iter( value.begin() ), last( value.end() );
+          iter != last;
+          ++iter )
+    {
+      trace_str += "\"" + iter->s + "\"(";
+      if ( iter->i ) // l®«ª êÎ...
+      {
+        trace_str += boost::lexical_cast< std::string >( *iter->i ) + " as integer";
+      }
+      else if ( !iter->v.empty() )
+      {
+        trace_str += "\"" + boost::lexical_cast< std::string >( iter->v ) + "\" as string";
+      }
+      trace_str += "), ";
+    }
+    trace_str += " }\n";
+
+    std::string filename( "stderr" );
+    if ( arity == 2 )
+    {
+      filename = get_s( arg_list[ 1 ], p_ctx );
+    }
+    if ( filename == "stdout" )
+    {
+      fputs( trace_str.c_str(), stdout );
+    }
+    else if ( filename == "stderr" )
+    {
+      fputs( trace_str.c_str(), stderr );
+    }
+    else
+    {
+      std::FILE* stream = std::fopen( filename.c_str(), "a" );
+      if ( stream != 0 )
+      {
+        fputs( trace_str.c_str(), stream );
+        std::fclose( stream );
+      }
+    }
+
+    element e;
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  ¶ñÌGXP[v
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   */
+  var_t bf_escstr( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 1, "ESCSTR" ) )
+    {
+      std::string str( get_s( arg_list[ 0 ], p_ctx ) );
+      e.s = quote_string( str );
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  ¶ñÌGXP[vð
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   */
+  var_t bf_unescstr( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 1, "UNESCSTR" ) )
+    {
+      std::string str( get_s( arg_list[ 0 ], p_ctx ) );
+      e.s = expand_quote( str );
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  ÖÌÄÑoµ
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   */
+  var_t bf_call( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    return macro_processor::call_user_function( line, arg_list, p_ctx );
+  }
+
+  namespace
+  {
+    struct bf_functor : std::binary_function< element const&, element const&, bool >
+    {
+    public:
+      bf_functor( text_line const& line, std::string const& func_name, context* p_ctx )
+        : line_( line ), func_name_( func_name ), p_ctx_( p_ctx )
+      {
+      }
+      bool operator()( element const& lhs, element const& rhs )
+      {
+        std::vector< var_t > arg_list;
+        arg_list.reserve( 3 );
+
+        element e;
+        e.s = func_name_;
+        arg_list.push_back( var_t( 1, e ) );
+        arg_list.push_back( var_t( 1, lhs ) );
+        arg_list.push_back( var_t( 1, rhs ) );
+        int arg1 = *lhs.i, arg2 = *rhs.i;
+
+        var_t r = bf_call( line_, arg_list, p_ctx_ );
+        bool result = 0;
+        if ( !r.empty() )
+        {
+          int retval = *r.front().i;
+          result = ( *r.front().i < 0 );
+        }
+        return result;
+      }
+    private:
+      std::string func_name_;
+      context* p_ctx_;
+      text_line line_;
+    };
+  }
+
+  /*!
+   *  \brief  \[g
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   */
+  var_t bf_lsort( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    if ( macro_processor::check_arity( line, arg_list.size(), 2, "LSORT" ) )
+    {
+      var_t temp( arg_list[ 0 ] );
+      std::string compare( arg_list[ 1 ].front().s );
+      std::stable_sort( temp.begin(), temp.end(), bf_functor( line, compare, p_ctx ) );
+      return temp;
+    }
+    element e;
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  Ö©Ç¤©Ì»Ê
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   */
+  var_t bf_isfunction( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    if ( macro_processor::check_arity( line, arg_list.size(), 1, "ISFUNCTION" ) )
+    {
+      std::string func_name( get_s( arg_list[ 0 ], p_ctx ) );
+      if ( p_ctx->func_map.find( func_name ) != p_ctx->func_map.end() )
+      {
+        e.i = 1;
+      }
+      else
+      {
+        e.i = 0;
+      }
+    }
+    return var_t( 1, e );
+  }
+
+  /*!
+   *  \brief  ½àµÈ¢gÝÝÖ
+   *  \param[in]  line      sÔ
+   *  \param[in]  arg_list  }NÀøXg
+   *  \param[in]  p_ctx     }NReLXg
+   *  \retval     }NÔpl
+   *  ±ÌgÝÝÖÍ½àsíÈ¢BÜ½A}NÀøÌ`FbNàsíÈ¢B
+   *  NOOPÖÍíÉ "" ðÔ·B
+   *  \note       ólðÔ³È¢ÌÍA$NOOP()$Ìæ¤Èg¢ûðµ½Æ«Åàs³ÈQÆªN±çÈ¢æ¤É·é½ßB
+   */
+  var_t bf_noop( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    element e;
+    return var_t( 1, e );
+  }
+
+  macro_processor::func_t const macro_processor::builtin_function_table[] =
+  {
+    { "LENGTH", bf_length },
+    { "EQ", bf_eq },
+    { "ALT", bf_alt },
+    { "SORT", bf_sort },
+    { "ENVIRON", bf_environ },
+    { "VALUE", bf_value },
+    { "CONCAT", bf_concat },
+    { "APPEND", bf_append },
+    { "AT", bf_at },
+    { "GETTEXT", bf_gettext },
+    { "_", bf_gettext },  // GETTEXTÌVmj
+    { "FORMAT", bf_format },
+    { "FIND", bf_find },
+    { "RANGE", bf_range },
+    { "DUMP", bf_dump },
+    { "TRACE", bf_trace },
+    { "ESCSTR", bf_escstr },
+    { "UNESCSTR", bf_unescstr },
+    { "CALL", bf_call },
+    { "LSORT", bf_lsort },
+    { "ISFUNCTION", bf_isfunction },
+    { "NOOP", bf_noop },
+    { "", 0 },
+  };
+
+}
Index: /cfg_oil/trunk/toppers/c_chlit_parser.cpp
===================================================================
--- /cfg_oil/trunk/toppers/c_chlit_parser.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_chlit_parser.cpp	(revision 8)
@@ -0,0 +1,62 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa  
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/c_chlit_parser.cpp
+ */
+#include "toppers/c_parser.hpp"
+
+namespace toppers
+{
+
+  //! C¾ê`®Ì¶èp[T[iASCIIj
+  boost::spirit::functor_parser< detail::c_chlit_parse_functor< ascii > > const ascii_ch_p;
+
+  //! C¾ê`®Ì¶èp[T[iShift JISj
+  boost::spirit::functor_parser< detail::c_chlit_parse_functor< shift_jis > > const shift_jis_ch_p;
+
+  //! C¾ê`®Ì¶èp[T[iEUC-JPj
+  boost::spirit::functor_parser< detail::c_chlit_parse_functor< euc_jp > > const euc_jp_ch_p;
+
+  //! C¾ê`®Ì¶èp[T[iUTF-8j
+  boost::spirit::functor_parser< detail::c_chlit_parse_functor< utf8 > > const utf8_ch_p;
+
+}
Index: /cfg_oil/trunk/toppers/c_expr.hpp
===================================================================
--- /cfg_oil/trunk/toppers/c_expr.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_expr.hpp	(revision 8)
@@ -0,0 +1,429 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/c_expr.hpp
+ *  \brief  C¾êÌ®Ì\¶ðÍÉÖ·éé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  struct c_expr_parser_base< Derived >;
+ *  struct c_expr_parser;
+ *  struct c_const_expr_parser;
+ *  \endcode
+ */
+#ifndef TOPPERS_C_EXPR_HPP_
+#define TOPPERS_C_EXPR_HPP_
+
+#include "toppers/c_parser.hpp"
+#include <boost/cstdint.hpp>
+
+namespace toppers
+{
+
+  /*!
+   *  \struct c_expr_parser_base c_expr.hpp "toppers/c_expr.hpp"
+   *  \brief  C¾êÌ®ð\¶ðÍ·é½ßÌîêNX
+   *
+   *  ÀÛÉgp·éÛÍA c_expr_parser_base ¨æÑ c_expr_parser_base::definition
+   *  NXðh¶·éKvª èÜ·B c_expr_parser_base::definition Ìh¶NXÅÍA
+   *  start oÖðè`µÄA\¶ÌKvÈ[ðæèo·æ¤ÉµÄ­¾³¢B
+   *  ±¤·é±ÆÅAè®Ì¶@Aê®Ì¶@Æ¢Á½æ¤ÉAC¾êÌ¶@ÌTu
+   *  ZbgðeÕÉìèo·±ÆªÅ«Ü·B
+   *
+   *  \code
+   *  // ê®ðæèo·á
+   *  struct c_primary_expression : c_expr_parser_base< c_primary_expression >
+   *  {
+   *    template < class Scanner >
+   *    struct definition : c_expr_parser_base< c_primary_expression >::definition
+   *    {
+   *      rule_t const& start() const { return primary_expression; }
+   *    };
+   *  };
+   *  \endcode
+   */
+  template < class Derived >
+    struct c_expr_parser_base : boost::spirit::grammar< Derived >
+  {
+  public:
+    /*!
+     *  \struct definition c_expr.hpp "toppers/c_expr.hpp"
+     *  \brief  ¶@è`
+     */
+    template < class Scanner >
+      struct definition
+    {
+      typedef boost::spirit::rule< Scanner > rule_t;
+      rule_t  primary_expression,   
+              expression,
+              constant_expression,
+              conditional_expression,
+              assignment_expression,
+              assignment_operator,
+              postfix_expression,
+              unary_expression,
+              unary_operator,
+              cast_expression,
+              multiplicative_expression,
+              additive_expression,
+              shift_expression,
+              relational_expression,
+              equality_expression,
+              AND_expression,
+              exclusive_OR_expression,
+              inclusive_OR_expression,
+              logical_AND_expression,
+              logical_OR_expression,
+              string_literal,
+              constant,
+              floating_constant,
+              decimal_floating_constant,
+              hexadecimal_floating_constant,
+              integer_constant,
+              character_constant,
+              declaration_specifiers,
+              type_name,
+              specifier_qualifier_list,
+              storage_class_specifier,
+              type_specifier,
+              type_qualifier,
+              declarator,
+              direct_declarator,
+              struct_or_union_specifier,
+              struct_declaration,
+              struct_declarator,
+              enum_specifier,
+              enumerator,
+              abstract_declarator,
+              pointer,
+              parameter_type_list,
+              parameter_list,
+              parameter_declaration,
+              direct_abstract_declarator;
+
+      c_ident_parser_t identifier;
+      c_strlit_parser_t c_strlit_p;
+      c_chlit_parser_t c_chlit_p;
+
+      /*!
+       *  \brief  RXgN^
+       *  \param  self  ¶@NXi c_expr_parser_base< Derived > NX©çÌp³jÖÌQÆ
+       */
+      definition( Derived const& self )
+        : identifier( c_ident_parser( self.ucn_, self.c_plus_plus_ ) ),
+          c_strlit_p( c_strlit_parser( self.codeset_ ) ),
+          c_chlit_p( c_chlit_parser( self.codeset_ ) )
+      {
+        using namespace boost::spirit;
+        static functor_parser< detail::c_integer_constant_parse_functor< boost::uintmax_t > > const c_int_const_p;
+        static functor_parser< detail::c_integer_suffix_parse_functor > const c_int_suffix_p;
+
+        primary_expression =  // ¡e¢Î
+            identifier
+          | constant
+          | string_literal
+          | ( '(' >> expression >> ')' );
+        expression =
+            assignment_expression % ',';
+        constant_expression = 
+            conditional_expression;
+        conditional_expression =
+            logical_OR_expression >> *( '\?' >> expression >> ':' >> logical_OR_expression );
+        assignment_expression =
+           *( unary_expression >> assignment_operator ) >> conditional_expression;
+        assignment_operator =
+            ch_p( '=' ) | "*=" | "/=" | "%=" | "+=" | "?=" | "<<=" | ">>=" | "&=" | "^=" | "|=";
+        postfix_expression =
+            primary_expression >>
+          *(
+                ( '[' >> expression >> ']' )
+              | ( '(' >> list_p( assignment_expression, ',' ) >> ')' )
+              | ( '.' >> identifier )
+              | ( "->" >> identifier )
+              | "++"
+              | "--"
+            );
+        unary_expression =
+           *( str_p( "++" ) || "--" ) >>
+            (
+                ( "sizeof" >> unary_expression )
+              | ( str_p( "sizeof" ) >> '(' >> type_name >> ')' )
+              | postfix_expression
+              | ( unary_operator >> cast_expression )
+            );
+        unary_operator =
+            chset<>( "&*~!+-" );
+        cast_expression =
+            *( '(' >> type_name >> ')' ) >> unary_expression
+          | +( '(' >> ( type_name | identifier ) >> ')' );  // \¶ðÍÉ¸s·ésïÎô
+        multiplicative_expression =
+            cast_expression >>
+           *(
+                ( '*' >> cast_expression )
+              | ( '/' >> cast_expression )
+              | ( '%' >> cast_expression )
+            );
+        additive_expression =
+            multiplicative_expression >>
+           *(
+                ( '+' >> multiplicative_expression )
+              | ( '-' >> multiplicative_expression )
+            );
+        shift_expression =
+            additive_expression >>
+           *(
+                ( "<<" >> additive_expression )
+              | ( ">>" >> additive_expression )
+            );
+        relational_expression =
+            shift_expression >>
+           *(
+                ( '<' >> shift_expression )
+              | ( '>' >> shift_expression )
+              | ( "<=" >> shift_expression )
+              | ( ">=" >> shift_expression )
+            );
+        equality_expression =
+            relational_expression >>
+           *(
+                ( "==" >> relational_expression )
+              | ( "!=" >> relational_expression )
+            );
+        AND_expression =
+            equality_expression >> *( '&' >> equality_expression );
+        exclusive_OR_expression =
+            AND_expression >> *( '^' >> AND_expression );
+        inclusive_OR_expression =
+            exclusive_OR_expression >> *( '|' >> exclusive_OR_expression );
+        logical_AND_expression =
+            inclusive_OR_expression >> *( "&&" >> inclusive_OR_expression );
+        logical_OR_expression =
+            logical_AND_expression >> *( "||" >> logical_AND_expression );
+        string_literal =
+            c_strlit_p
+          | lexeme_d[ 'L' >> c_strlit_p ];
+        constant =
+            floating_constant
+          | integer_constant
+          | identifier  // ñè
+          | character_constant;
+        floating_constant =
+            decimal_floating_constant
+          | hexadecimal_floating_constant;
+        decimal_floating_constant =
+            lexeme_d
+            [
+              as_lower_d
+              [
+                ( ( *digit_p >> '.' >> +digit_p ) | ( +digit_p >> '.' ) ) >>
+                'e' >> !chset<>( "+-" ) >> +digit_p >>
+                !chset<>( "fl" )
+              ]
+            ];
+        hexadecimal_floating_constant =
+            lexeme_d
+            [
+              as_lower_d
+              [
+                "0x" >>
+                ( ( *xdigit_p >> '.' >> +xdigit_p ) | ( +xdigit_p >> '.' ) ) >>
+                'p' >> !chset<>( "+-" ) >> +digit_p >>
+                !chset<>( "fl" )
+              ]
+            ];
+        integer_constant =
+            lexeme_d[ c_int_const_p >> !c_int_suffix_p ];
+        character_constant =
+            c_chlit_p
+          | lexeme_d[ 'L' >> c_chlit_p ];
+        declaration_specifiers =
+           +( storage_class_specifier | type_specifier | type_qualifier );
+        type_name =
+            specifier_qualifier_list >> !abstract_declarator;
+        specifier_qualifier_list =
+           +( type_specifier | type_qualifier );
+        storage_class_specifier =
+            str_p( "auto" )
+          | "register"
+          | "static"
+          | "extern"
+          | "typedef";
+        type_specifier =
+            str_p( "void" ) | "char" | "short" | "int" | "long" | "float" | "double"
+          | "signed" | "unsigned"
+          | identifier
+          | struct_or_union_specifier
+          | enum_specifier;
+        type_qualifier =
+            str_p( "const" ) | "volatile" | "restrict";
+        declarator =
+            !pointer >> direct_declarator;
+        direct_declarator = 
+            ( identifier | ( '(' >> declarator >> ')' ) )
+            >>
+          *(
+                ( '[' >> !constant_expression >> ']' )
+              | ( '(' >> parameter_type_list >> ')' )
+              | ( '(' >> !( identifier % ',' ) >> ')' )
+            );
+        struct_or_union_specifier =
+            lexeme_d[ ( str_p( "struct" ) | "union" ) >> +space_p >> identifier ]
+          | ( lexeme_d[ ( str_p( "struct" ) | "union" ) >> +space_p >> !identifier ] >> '{' >> +struct_declaration >> '}' );
+        struct_declaration =
+            specifier_qualifier_list >> !list_p( struct_declarator, ',' ) >> ';';
+            // lisp_p( struct_declarator, ',' )ðÈªÂ\ÆµÄ¢éÌÍA
+            // struct_declarator Ì identifier ð specifier_qualifier_list ª
+            // typedef ¼ÆÔá¤±Æðñð·é½ß
+        struct_declarator =
+            ( !declarator >> ':' >> constant_expression ) // rbgtB[h
+          | declarator;
+        enum_specifier =
+            ( lexeme_d[ "enum" >> +space_p >> !identifier ] >> '{' >> list_p( enumerator, ',', ',' ) >> '}' )   // C99ÅÍöÌJ}ª ÁÄàæ¢
+          | lexeme_d[ "enum" >> +space_p >> identifier ];
+        enumerator =
+            identifier >> !( '=' >> constant_expression );
+        abstract_declarator =
+            ( !pointer >> direct_abstract_declarator )
+          | pointer;
+        pointer =
+           +( '*' >> *type_qualifier );
+        parameter_type_list =
+            parameter_list >> !( ch_p( ',' ) >> "..." );  // ÂÏÂø
+        parameter_list =
+            parameter_declaration % ',';
+        parameter_declaration = 
+            ( declaration_specifiers >> declarator )
+          | ( declaration_specifiers >> !abstract_declarator );
+        direct_abstract_declarator =
+            (
+             !( '(' >> abstract_declarator >> ')' ) >>
+             +(
+                  ( '[' >> !constant_expression >> ']' )
+                | ( '(' >> !parameter_type_list >> ')' ) 
+              )
+            )
+          | ( '(' >> abstract_declarator >> ')' );
+      }
+    };
+    bool ucn_;
+    codeset_t codeset_;
+    bool c_plus_plus_;
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  ucn         Û¶¼ÉÎ·éêÍ true ðwè·é
+     *  \param  codeset     ¶R[h
+     *  \param  c_plus_plus C++ ÉÎ·éêÍ true ðwè·é
+     */
+    explicit c_expr_parser_base( bool ucn = false, codeset_t codeset = ascii, bool c_plus_plus = false )
+      : ucn_( ucn ), codeset_( codeset ), c_plus_plus_( c_plus_plus )
+    {
+    }
+  };
+
+  /*!
+   *  \class  c_expr_parser c_expr.hpp "toppers/c_expr.hpp" 
+   *  \brief  C¾êÌ®Ì\¶ðÍNX
+   */
+  struct c_expr_parser : c_expr_parser_base< c_expr_parser >
+  {
+    typedef c_expr_parser_base< c_expr_parser > base_t;
+
+    /*!
+     *  \struct definition c_expr.hpp "toppers/c_expr.hpp"
+     *  \brief  ¶@è`
+     */
+    template < class Scanner >
+    struct definition : base_t::definition< Scanner >
+    {
+      typedef typename base_t::definition< Scanner >::rule_t rule_t;
+
+      definition( c_expr_parser const& self ) : base_t::definition< Scanner >( self ) {}
+      rule_t const& start() const { return base_t::definition< Scanner >::expression; };
+    };
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  ucn     Û¶¼ÉÎ·éêÍ true ðwè·é
+     *  \param  codeset ¶R[h
+     */
+    explicit c_expr_parser( bool ucn = false, codeset_t codeset = ascii )
+      : c_expr_parser_base< c_expr_parser >( ucn, codeset )
+    {
+    }
+  };
+
+  /*!
+   *  \class  c_const_expr_parser c_expr.hpp "toppers/c_expr.hpp"
+   *  \brief  C¾êÌè®Ì\¶ðÍNX
+   */
+  struct c_const_expr_parser : c_expr_parser_base< c_const_expr_parser >
+  {
+    typedef c_expr_parser_base< c_const_expr_parser > base_t;
+
+    /*!
+     *  \struct definition c_expr.hpp "toppers/c_expr.hpp"
+     *  \brief  ¶@è`
+     */
+    template < class Scanner >
+    struct definition : base_t::definition< Scanner >
+    {
+      typedef typename base_t::definition< Scanner >::rule_t rule_t;
+
+      definition( c_const_expr_parser const& self ) : base_t::definition< Scanner >( self ) {}
+      rule_t const& start() const { return base_t::definition< Scanner >::constant_expression; };
+    };
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  ucn     Û¶¼ÉÎ·éêÍ true ðwè·é
+     *  \param  codeset ¶R[h
+     */
+    explicit c_const_expr_parser( bool ucn = false, codeset_t codeset = ascii )
+      : c_expr_parser_base< c_const_expr_parser >( ucn, codeset )
+    {
+    }
+  };
+
+}
+
+#endif  // ! TOPPERS_C_EXPR_HPP_
Index: /cfg_oil/trunk/toppers/c_ident_parser.cpp
===================================================================
--- /cfg_oil/trunk/toppers/c_ident_parser.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_ident_parser.cpp	(revision 8)
@@ -0,0 +1,59 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/c_ident_parser.cpp
+ */
+#include "toppers/c_parser.hpp"
+
+namespace toppers
+{
+
+  //! C90`®Ì¯Êqp[T[
+  boost::spirit::functor_parser< detail::c_identifier_parse_functor > const c_ident_p;
+
+  //! C99`®Ì¯Êqp[T[
+  boost::spirit::functor_parser< detail::c_identifier_parse_functor > const c99_ident_p( detail::c_identifier_parse_functor( true ) );
+
+  //! C++`®Ì¯Êqp[T[
+  boost::spirit::functor_parser< detail::c_identifier_parse_functor > const c_plus_plus_ident_p( detail::c_identifier_parse_functor( true, true ) );
+
+}
Index: /cfg_oil/trunk/toppers/c_int_parser.cpp
===================================================================
--- /cfg_oil/trunk/toppers/c_int_parser.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_int_parser.cpp	(revision 8)
@@ -0,0 +1,56 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa  
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/c_int_parser.cpp
+ */
+#include "toppers/c_parser.hpp"
+
+namespace toppers
+{
+
+  //! C¾ê`®Ìint^èp[T
+  boost::spirit::functor_parser< detail::c_integer_parse_functor< int > > const c_int_p;
+
+  //! C¾ê`®Ìunsigned int^èp[T
+  boost::spirit::functor_parser< detail::c_integer_parse_functor< unsigned int > > const c_uint_p;
+
+}
Index: /cfg_oil/trunk/toppers/c_keywords.cpp
===================================================================
--- /cfg_oil/trunk/toppers/c_keywords.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_keywords.cpp	(revision 8)
@@ -0,0 +1,65 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2007 by TAKAGI Nobuhisa  
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/c_keyword.cpp
+ */
+
+namespace toppers
+{
+
+  namespace detail
+  {
+
+    extern char const* const c_keywords[];
+
+    char const* const c_keywords[] =
+    {
+      "_Bool", "_Complex", "_Imaginary", "auto", "break", "case", "char", "const",
+      "continue", "default", "do", "double", "else", "enum", "extern", "float",
+      "for", "goto", "if", "inline", "int", "long" "register", "restrict", "return",
+      "short", "sizeof", "static", "struct", "switch", "typedef", "union", "unsigned",
+      "void", "volatile", "while", 0,
+    };
+
+  }
+  
+}
Index: /cfg_oil/trunk/toppers/c_parser.hpp
===================================================================
--- /cfg_oil/trunk/toppers/c_parser.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_parser.hpp	(revision 8)
@@ -0,0 +1,559 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/c_parser.hpp
+ *  \brief  êÊIÈp[T[Ìé¾è`
+ */
+#ifndef TOPPERS_PARSER_HPP_
+#define TOPPERS_PARSER_HPP_
+
+#include "toppers/codeset.hpp"
+#include <boost/spirit/core.hpp>
+#include <boost/spirit/actor.hpp>
+#include <boost/spirit/utility.hpp>
+#include <boost/spirit/dynamic.hpp>
+
+namespace toppers
+{
+
+  namespace detail
+  {
+
+    struct c_integer_suffix_parse_functor
+    {
+      typedef boost::spirit::nil_t result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& ) const
+      {
+        using namespace boost::spirit;
+        int length =
+                  as_lower_d
+                  [
+                      ch_p( 'u' ) >> !( str_p( "ll" ) | 'l' | "i8" | "i16" | "i32" | "i64" )
+                    | ( str_p( "ll" ) | 'l' | "i8" | "i16" | "i32" | "i64" ) >> !ch_p( 'u' )
+                  ].parse( scan ).length();
+        return length;
+      }
+    };
+
+    template < typename T >
+    struct c_integer_constant_parse_functor
+    {
+      typedef T result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        using namespace boost::spirit;
+        result_t x = T( 0 );
+        int length =
+                  (
+                    if_p( '0' ) // 16iÜ½Í8i
+                    [
+                      !(
+                          ( ch_p( 'x' ) | 'X' ) >> uint_parser< T, 16 >()[ assign_a( x ) ]
+                        | uint_parser< T, 8 >()[ assign_a( x ) ]
+                      )
+                    ]
+                    .else_p // 10i
+                    [
+                      uint_parser< T, 10 >()[ assign_a( x ) ]
+                    ]
+                  ).parse( scan ).length();
+        result = x;
+        return length;
+      }
+    };
+
+    template < typename T >
+    struct c_integer_parse_functor
+    {
+      typedef T result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        using namespace boost::spirit;
+        static functor_parser< c_integer_constant_parse_functor< T > > const c_int_const_p;
+        static functor_parser< c_integer_suffix_parse_functor > const c_int_suffix_p;
+        bool negative = false;
+        result_t x;
+        int length =
+                  (
+                    !sign_p[ assign_a( negative ) ] >> lexeme_d[ c_int_const_p[ assign_a( x ) ] >> !c_int_suffix_p ]
+                  ).parse( scan ).length();
+        result = ( negative ? -x : x );
+        return length;
+      }
+    };
+
+    template < int CodeSet = -1 > struct mbchar_parse_functor;
+
+    template <>
+    struct mbchar_parse_functor< ascii >
+    {
+      typedef boost::spirit::nil_t result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& ) const
+      {
+        return boost::spirit::range_p( '\x01', '\x7f' ).parse( scan ).length();
+      }
+    };
+
+    template <>
+    struct mbchar_parse_functor< shift_jis >
+    {
+      typedef boost::spirit::nil_t result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& ) const
+      {
+        using namespace boost::spirit;
+        int length =
+                (
+                    range_p( '\x01', '\x7f' ) // ¼ppL
+                  | range_p( '\xa1', '\xdf' ) // ¼pJ^Ji
+                  | ( chset<>( "\x81-\x9f\xe0-\xef" ) >> chset<>( "\x40-\x7e\x80-\xfc" ) )  // Sp
+                ).parse( scan ).length();
+        return length;
+      }
+    };
+
+    template <>
+    struct mbchar_parse_functor< euc_jp >
+    {
+      typedef boost::spirit::nil_t result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& ) const
+      {
+        using namespace boost::spirit;
+        int length =
+                (
+                    range_p( '\x01', '\x7f' ) // ¼ppL
+                  | ( ch_p( '\x8e' ) >> range_p( '\xa1', '\xdf' ) )   // ¼pJ^Ji
+                  | ( !ch_p( '\x8f' ) >> range_p( '\xa1', '\xf0' ) >> range_p( '\xa1', '\xf0' ) ) // Sp
+                ).parse( scan ).length();
+        return length;
+      }
+    };
+
+    template <>
+    struct mbchar_parse_functor< utf8 >
+    {
+      typedef boost::spirit::nil_t result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& ) const
+      {
+        using namespace boost::spirit;
+        int length =
+                (
+                    range_p( '\x01', '\x7f' ) // 1oCg
+                  | ( range_p( '\xc0', '\xdf' ) >> range_p( '\x80', '\xbf' ) )  // 2oCg
+                  | ( range_p( '\xe0', '\xef' ) >> repeat_p( 2 )[ range_p( '\x80', '\xbf' ) ] ) // 3oCg
+                  | ( range_p( '\xf0', '\xf7' ) >> repeat_p( 3 )[ range_p( '\x80', '\xbf' ) ] ) // 4oCg
+                  | ( range_p( '\xf8', '\xfb' ) >> repeat_p( 4 )[ range_p( '\x80', '\xbf' ) ] ) // 5oCg
+                  | ( range_p( '\xfc', '\xfd' ) >> repeat_p( 5 )[ range_p( '\x80', '\xbf' ) ] ) // 6oCg
+                ).parse( scan ).length();
+        return length;
+      }
+    };
+
+    template <>
+    struct mbchar_parse_functor< -1 >
+    {
+      typedef boost::spirit::nil_t result_t;
+      explicit mbchar_parse_functor( codeset_t codeset = ascii ) : codeset_( codeset ) {}
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        int length;
+        switch ( codeset_ )
+        {
+        case ascii:
+          {
+            static mbchar_parse_functor< ascii > f;
+            length = f( scan, result );
+          }
+          break;
+        case shift_jis:
+          {
+            static mbchar_parse_functor< shift_jis > f;
+            length = f( scan, result );
+          }
+          break;
+        case euc_jp:
+          {
+            static mbchar_parse_functor< euc_jp > f;
+            length = f( scan, result );
+          }
+          break;
+        case utf8:
+          {
+            static mbchar_parse_functor< utf8 > f;
+            length = f( scan, result );
+          }
+          break;
+        default:
+          length = -1;
+          break;
+        }
+        return length;
+      }
+      codeset_t codeset_;
+    };
+
+    struct ucn_parse_functor
+    {
+      typedef long result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        using namespace boost::spirit;
+        result_t x;
+        int length =
+                (
+                  lexeme_d
+                  [
+                      ch_p( '\\' ) >>
+                      (
+                          ( 'U' >> int_parser< long, 16, 8, 8 >()[ assign_a( x ) ] )  // \Uhhhhhhhh`®
+                        | ( 'u' >> int_parser< long, 16, 4, 4 >()[ assign_a( x ) ] )  // \uhhhh`®
+                      )
+                  ]
+                ).parse( scan ).length();
+        if ( ( x < 0xa0 && !( x == 0x24 || x == 0x40 || x == 0x60 ) )
+          || ( 0xd800 <= x && x <= 0xdfff ) 
+          || 0x10ffff < x ) // Û¶¼Ég¦È¢liJIS X3010:2003 6.4.3j
+        {
+          x = -1;
+        }
+        result = x;
+        return length;
+      }
+    };
+
+    template < int CodeSet = -1 > struct c_strlit_parse_functor;
+
+    template < int CodeSet >
+    struct c_strlit_parse_functor
+    {
+      typedef boost::spirit::nil_t result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        using namespace boost::spirit;
+        static functor_parser< detail::mbchar_parse_functor< CodeSet > > const mbchar_p;
+        static functor_parser< detail::ucn_parse_functor > const ucn_p;
+        int length =
+                (
+                  confix_p( '\"', *( "\\\"" | mbchar_p - '\\' | ucn_p | c_escape_ch_p ), '\"' )
+                ).parse( scan ).length();
+        return length;
+      }
+    };
+
+    template <>
+    struct c_strlit_parse_functor< -1 >
+    {
+      typedef boost::spirit::nil_t result_t;
+      explicit c_strlit_parse_functor( codeset_t codeset = ascii ) : codeset_( codeset ) {}
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        using namespace boost::spirit;
+        mbchar_parse_functor<> const functor( codeset_ );
+        functor_parser< detail::mbchar_parse_functor<> > const mbchar_p( functor );
+        static functor_parser< detail::ucn_parse_functor > const ucn_p;
+        int length =
+                (
+                  confix_p( '\"', *( "\\\"" | ( mbchar_p - ch_p( '\\' ) ) | ucn_p | c_escape_ch_p ), '\"' )
+                ).parse( scan ).length();
+        return length;
+      }
+      codeset_t codeset_;
+    };
+
+    template < int CodeSet = -1 > struct c_chlit_parse_functor;
+
+    template < int CodeSet >
+    struct c_chlit_parse_functor
+    {
+      typedef boost::spirit::nil_t result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        using namespace boost::spirit;
+        static functor_parser< detail::mbchar_parse_functor< CodeSet > > const mbchar_p;
+        static functor_parser< detail::ucn_parse_functor > const ucn_p;
+        int length =
+                (
+                  confix_p( '\'', +( "\\\'" | mbchar_p - '\\' | ucn_p | c_escape_ch_p ), '\'' )
+                ).parse( scan ).length();
+        return length;
+      }
+    };
+
+    template <>
+    struct c_chlit_parse_functor< -1 >
+    {
+      typedef boost::spirit::nil_t result_t;
+      explicit c_chlit_parse_functor( codeset_t codeset = ascii ) : codeset_( codeset ) {}
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        using namespace boost::spirit;
+        mbchar_parse_functor<> const functor( codeset_ );
+        functor_parser< detail::mbchar_parse_functor<> > const mbchar_p( functor );
+        static functor_parser< detail::ucn_parse_functor > const ucn_p;
+        int length =
+                (
+                  confix_p( '\'', +( "\\\'" | mbchar_p - '\\' | ucn_p | c_escape_ch_p ), '\'' )
+                ).parse( scan ).length();
+        return length;
+      }
+      codeset_t codeset_;
+    };
+
+    extern char const* const c_keywords[];
+    extern char const* const c_plus_plus_keywords[];
+
+    struct c_identifier_parse_functor
+    {
+      typedef boost::spirit::nil_t result_t;
+      template < class Scanner >
+      int operator()( Scanner scan, result_t& result ) const
+      {
+        using namespace boost::spirit;
+        static functor_parser< detail::ucn_parse_functor > const ucn_p;
+        int length;
+        typename Scanner::iterator_t const first( scan.first );
+
+        if ( ucn_ )
+        {
+          length =
+                (
+                  lexeme_d
+                  [
+                    ( alpha_p | '_' | ucn_p ) >>
+                   *( alnum_p | '_' | ucn_p )
+                  ]
+                ).parse( scan ).length();
+        }
+        else
+        {
+          length =
+                (
+                  lexeme_d
+                  [
+                     ( alpha_p | '_' ) >>
+                    *( alnum_p | '_' )
+                  ]
+                ).parse( scan ).length();
+        }
+        std::string token( first, scan.first );
+
+        for ( int i = 0; c_keywords[i] != 0; i++ )
+        {
+          if ( token == c_keywords[i] )
+          {
+            length = -1;
+            break;
+          }
+        }
+        if ( c_plus_plus_ )
+        {
+          for ( int i = 0; c_plus_plus_keywords[i] != 0; i++ )
+          {
+            if ( token == c_plus_plus_keywords[i] )
+            {
+              length = -1;
+              break;
+            }
+          }
+        }
+        return length;
+      }
+      explicit c_identifier_parse_functor( bool ucn = false, bool c_plus_plus = false )
+        : ucn_( ucn ), c_plus_plus_( c_plus_plus )
+      {
+      }
+
+      bool ucn_;
+      bool c_plus_plus_;
+    };
+
+  }
+
+  /*!
+   *  \brief  C¾ê`®Ì®èp[T[
+   *
+   *  boost::spirit::int_parserÆÌá¢ÍAÚª«É¶Ä8iâ16iÆµÄðß
+   *  ·é_Å·BÜ½^ðÁè·é½ßÌÚö«àó¯üêÜ·B
+   */
+  template < typename T >
+  inline boost::spirit::functor_parser< detail::c_integer_parse_functor< T > > const c_int_parser()
+  {
+    return boost::spirit::functor_parser< detail::c_integer_parse_functor< T > >();
+  }
+
+  extern boost::spirit::functor_parser< detail::c_integer_parse_functor< int > > const c_int_p;
+  extern boost::spirit::functor_parser< detail::c_integer_parse_functor< unsigned int > > const c_uint_p;
+
+  /*!
+   *  \brief  }`oCg¶p[T[
+   *
+   *  ev[gø CodeSet Åwèµ½¶R[hððÍµÜ·B
+   *  ascii ÈOðwèµ½êÅàAASCIIÌÍÍi0x7fÈºjÉàvµÜ·B
+   *  0x00 Í¶ñÌI[ÆæÊÅ«È¢½ßAvÎÛÉÍÈèÜ¹ñB
+   */
+  template < int CodeSet >
+  inline boost::spirit::functor_parser< detail::mbchar_parse_functor< CodeSet > > const mbchar_parser()
+  {
+    return boost::spirit::functor_parser< detail::mbchar_parse_functor< CodeSet > >();
+  }
+  inline boost::spirit::functor_parser< detail::mbchar_parse_functor<> > const mbchar_parser( codeset_t codeset )
+  {
+    return boost::spirit::functor_parser< detail::mbchar_parse_functor<> >( detail::mbchar_parse_functor<>( codeset ) );
+  }
+
+  extern boost::spirit::functor_parser< detail::mbchar_parse_functor< ascii > > const ascii_p;
+  extern boost::spirit::functor_parser< detail::mbchar_parse_functor< shift_jis > > const shift_jis_p;
+  extern boost::spirit::functor_parser< detail::mbchar_parse_functor< euc_jp > > const euc_jp_p;
+  extern boost::spirit::functor_parser< detail::mbchar_parse_functor< utf8 > > const utf8_p;
+
+  /*!
+   *  \brief  Û¶¼p[T[
+   *
+   *  \\uÜ½Í\\UÅnÜéÛ¶¼iUniversal Character NamejððÍµÜ·B
+   *  \\uhhhhÜ½Í\\UhhhhhhhhihÍ16ijÉvµÜ·BÈ¨A±êçÌ`®É
+   *  vµÄ¢éêÅàAêÌlÍÛ¶¼ÆµÄgpÅ«Ü¹ñB
+   */
+  inline boost::spirit::functor_parser< detail::ucn_parse_functor > const ucn_parser()
+  {
+    return boost::spirit::functor_parser< detail::ucn_parse_functor >();
+  }
+
+  extern boost::spirit::functor_parser< detail::ucn_parse_functor > const ucn_p;
+
+  /*!
+   *  \brief  C¾ê`®Ì¶ñèp[T[
+   *
+   *  ñdøpÅÍÜê½C¾ê`®Ì¶ñððÍµÜ·B
+   *  ¶ñÌ¶R[hÍ CodeSet Åwèµ½àÌÉÈèÜ·B
+   */
+  template < int CodeSet >
+  inline boost::spirit::functor_parser< detail::c_strlit_parse_functor< CodeSet > > const c_strlit_parser()
+  {
+    return boost::spirit::functor_parser< detail::c_strlit_parse_functor< CodeSet > >();
+  }
+
+  typedef boost::spirit::functor_parser< detail::c_strlit_parse_functor<> > c_strlit_parser_t;
+
+  /*!
+   *  \brief  C¾ê`®Ì¶ñèp[T[
+   *  \param  codeset ¶ñÉgp³êÄ¢é¶R[h
+   *
+   *  ñdøpÅÍÜê½C¾ê`®Ì¶ñððÍµÜ·B
+   */
+  inline boost::spirit::functor_parser< detail::c_strlit_parse_functor<> > const c_strlit_parser( codeset_t codeset )
+  {
+    return boost::spirit::functor_parser< detail::c_strlit_parse_functor<> >( detail::c_strlit_parse_functor<>( codeset ) );
+  }
+
+  extern boost::spirit::functor_parser< detail::c_strlit_parse_functor< ascii > > const ascii_str_p;
+  extern boost::spirit::functor_parser< detail::c_strlit_parse_functor< shift_jis > > const shift_jis_str_p;
+  extern boost::spirit::functor_parser< detail::c_strlit_parse_functor< euc_jp > > const euc_jp_str_p;
+  extern boost::spirit::functor_parser< detail::c_strlit_parse_functor< utf8 > > const utf8_str_p;
+
+  /*!
+   *  \brief  C¾ê`®Ì¶èp[T[
+   *
+   *  PøpÅÍÜê½C¾ê`®Ì¶èððÍµÜ·B
+   *  ¶R[hÍ CodeSet Åwèµ½àÌÉÈèÜ·B
+   */
+  template < int CodeSet >
+  inline boost::spirit::functor_parser< detail::c_chlit_parse_functor< CodeSet > > const c_chlit_parser()
+  {
+    return boost::spirit::functor_parser< detail::c_chlit_parse_functor< CodeSet > >();
+  }
+
+  typedef boost::spirit::functor_parser< detail::c_chlit_parse_functor<> > c_chlit_parser_t;
+
+  /*!
+   *  \brief  C¾ê`®Ì¶èp[T[
+   *  \param  codeset ¶R[h
+   *
+   *  PøpÅÍÜê½C¾ê`®Ì¶èððÍµÜ·B
+   */
+  inline boost::spirit::functor_parser< detail::c_chlit_parse_functor<> > const c_chlit_parser( codeset_t codeset )
+  {
+    return boost::spirit::functor_parser< detail::c_chlit_parse_functor<> >( detail::c_chlit_parse_functor<>( codeset ) );
+  }
+
+  extern boost::spirit::functor_parser< detail::c_chlit_parse_functor< ascii > > const ascii_ch_p;
+  extern boost::spirit::functor_parser< detail::c_chlit_parse_functor< shift_jis > > const shift_jis_ch_p;
+  extern boost::spirit::functor_parser< detail::c_chlit_parse_functor< euc_jp > > const euc_jp_ch_p;
+  extern boost::spirit::functor_parser< detail::c_chlit_parse_functor< utf8 > > const utf8_ch_p;
+
+  typedef boost::spirit::functor_parser< detail::c_identifier_parse_functor > c_ident_parser_t;
+
+  /*!
+   *  \brief  C¾ê`®Ì¯Êqp[T[
+   *  \param  ucn         Û¶ðe·éêÍ true ðwè
+   *  \param  c_plus_plus C++Ì\ñêðÖ~·éêÍ true ðwè
+   *
+   *  C¾êÌ¯ÊqÆµÄgpÅ«é¶ñÌðÍðs¢Ü·B
+   *  ¯ÊqÍºüÜ½Íp¶ÅnÜèAºüÜ½Ípª±­Ìª´¥Å·ªA
+   *  C99È~ÅÍÛ¶¼àgpÅ«é½ßAø ucn É true ðwè·é±ÆÅA
+   *  Û¶¼ÎªÂ\ÉÈèÜ·B
+   *
+   *  \note |óÀE¨æÑ\ñ¯ÊqÌ»ÊÍsÁÄ¢Ü¹ñB
+   */
+  inline boost::spirit::functor_parser< detail::c_identifier_parse_functor > const c_ident_parser( bool ucn = false, bool c_plus_plus = false )
+  {
+    return boost::spirit::functor_parser< detail::c_identifier_parse_functor >( detail::c_identifier_parse_functor( ucn, c_plus_plus ) );
+  }
+
+  extern boost::spirit::functor_parser< detail::c_identifier_parse_functor > const c_ident_p;
+  extern boost::spirit::functor_parser< detail::c_identifier_parse_functor > const c99_ident_p;
+  extern boost::spirit::functor_parser< detail::c_identifier_parse_functor > const c_plus_plus_ident_p;
+
+}
+
+#endif  // ! TOPPERS_PARSER_HPP_
Index: /cfg_oil/trunk/toppers/c_plus_plus_keywords.cpp
===================================================================
--- /cfg_oil/trunk/toppers/c_plus_plus_keywords.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_plus_plus_keywords.cpp	(revision 8)
@@ -0,0 +1,64 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/c_plus_plus_keywords.cpp
+ */
+
+namespace toppers
+{
+  namespace detail
+  {
+
+    extern char const* const c_plus_plus_keywords[];
+
+    char const* const c_plus_plus_keywords[] =
+    {
+      "and", "and_eq", "asm", "bitand", "bitor", "bool", "catch", "class", "compl",
+      "const_cast", "delete", "dynamic_cast", "explicit", "false", "friend", "namespace",
+      "new", "not", "not_eq", "operator", "or", "or_eq", "private", "protected",
+      "public", "reinterpret_cast", "static_cast", "this", "throw", "true", "try",
+      "typeid", "using", "virtual", "wchar_t", "xor", "xor_eq",
+      0
+    };
+
+  }
+}
Index: /cfg_oil/trunk/toppers/c_pp_line.hpp
===================================================================
--- /cfg_oil/trunk/toppers/c_pp_line.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_pp_line.hpp	(revision 8)
@@ -0,0 +1,193 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa  
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/c_pp_line.hpp
+ *  \brief  \#linewßÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_C_PP_LINE_HPP_
+#define TOPPERS_C_PP_LINE_HPP_
+
+#include "toppers/text_line.hpp"
+#include "toppers/c_parser.hpp"
+#include "toppers/workaround.hpp"
+#include <vector>
+#include <functional>
+
+namespace toppers
+{
+
+  namespace detail
+  {
+
+    //! \#line wßÌ\¶ðÍ
+    struct c_pp_line_parser : boost::spirit::grammar< c_pp_line_parser >
+    {
+      template < class Scanner >
+      struct definition
+      {
+        typedef boost::spirit::rule< Scanner > rule_t;
+        rule_t r;
+        definition( c_pp_line_parser const& self )
+        {
+          using namespace boost::spirit;
+          r = (
+                '#' >> lexeme_d[ str_p( "line" ) >> space_p >> uint_p[ assign_a( self.line_ ) ] ] >>
+                c_strlit_parser( self.codeset_ )[ assign_a( self.file_ ) ]
+              )
+            | (
+                '#' >>
+                uint_p[ assign_a( self.line_ ) ] >>
+                c_strlit_parser( self.codeset_ )[ assign_a( self.file_ ) ] >>
+                *anychar_p
+              );
+        }
+        rule_t const& start() const { return r; }
+      };
+
+      c_pp_line_parser( long& line, std::string& file, codeset_t codeset = ascii )
+        : line_( line ), file_( file ), codeset_( codeset )
+      {
+      }
+
+      long& line_;
+      std::string& file_;
+      codeset_t codeset_;
+    };
+
+    //! \#pragma wßÌ\¶ðÍ
+    struct c_pp_pragma_parser : boost::spirit::grammar< c_pp_pragma_parser >
+    {
+      template < class Scanner >
+      struct definition
+      {
+        typedef boost::spirit::rule< Scanner > rule_t;
+        rule_t r;
+        definition( c_pp_pragma_parser const& self )
+        {
+          using namespace boost::spirit;
+          r = '#' >> lexeme_d[ str_p( "pragma" ) >> space_p >> ( +anychar_p )[ assign_a( self.parameter_ ) ] ];
+        }
+        rule_t const& start() const { return r; }
+      };
+
+      c_pp_pragma_parser( std::string& parameter ) : parameter_( parameter )
+      {
+      }
+      std::string& parameter_;
+    };
+
+  }
+
+  /*!
+   *  \class  c_pp_line c_pp_line.hpp "toppers/c_pp_line.hpp"
+   *  \brief  \#linewßð³¹é½ßÌt@N^NX
+   *
+   *  ±ÌNXÍ basic_text NXÆgÝí¹ÄgpµÜ·B
+   */
+  template < class Container >
+  class c_pp_line : public std::binary_function< Container, line_buf, void >
+  {
+  public:
+    typedef Container conatiner;
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  codeset ¶R[hwè
+     */
+    explicit c_pp_line( codeset_t codeset = ascii )
+      : codeset_( codeset ), pragmas_( new std::vector< line_buf > )
+    {
+    }
+    /*!
+     *  \brief  ÊZq
+     *  \param  cont  line_buf ðvfÆ·éRei
+     *  \param  buf   1sobt@
+     */
+    void operator()( conatiner& cont, line_buf& buf )
+    {
+      using namespace boost::spirit;
+      long line;
+      std::string file;
+      detail::c_pp_line_parser c_pp_line_p( line, file, codeset_ );
+
+      if ( parse( buf.buf.begin(), buf.buf.end(), c_pp_line_p, space_p ).full ) // #linewßÌ
+      {
+        buf.line.line = line;
+        assert( file.size() >= 2 );
+        buf.line.file = file.substr( 1, file.size()-2 );
+      }
+      else
+      {
+        std::string param;
+        detail::c_pp_pragma_parser c_pp_pragma_p( param );
+
+        if ( parse( buf.buf.begin(), buf.buf.end(), c_pp_pragma_p, space_p ).full ) // #pragmawßÌ
+        {
+          line_buf t( buf );
+          t.buf = param;
+          pragmas_->push_back( t );
+        }
+        else
+        {
+          std::string::size_type pos = buf.buf.find_first_not_of( " \t" );
+          if ( pos == std::string::npos || buf.buf[pos] != '#' )
+          {
+            cont.push_back( buf );
+          }
+          ++buf.line.line;
+        }
+      }
+      buf.buf.clear();
+    }
+    /*!
+     *  \brief  \#pragmawßXgÌæ¾
+     *  \return \#pragmawßXgðÔ·
+     */
+    std::vector< line_buf > const& pragmas() const { return *pragmas_; }
+  private:
+    codeset_t codeset_;
+    std::tr1::shared_ptr< std::vector< line_buf > > pragmas_;
+  };
+
+}
+
+#endif  // ! TOPPERS_C_PP_LINE_HPP_
Index: /cfg_oil/trunk/toppers/c_strlit_parser.cpp
===================================================================
--- /cfg_oil/trunk/toppers/c_strlit_parser.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/c_strlit_parser.cpp	(revision 8)
@@ -0,0 +1,62 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa  
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/c_strlit_parser.cpp
+ */
+#include "toppers/c_parser.hpp"
+
+namespace toppers
+{
+
+  //! C¾ê`®Ì¶ñèp[T[iASCIIj
+  boost::spirit::functor_parser< detail::c_strlit_parse_functor< ascii > > const ascii_str_p;
+
+  //! C¾ê`®Ì¶ñèp[T[iShiftJISj
+  boost::spirit::functor_parser< detail::c_strlit_parse_functor< shift_jis > > const shift_jis_str_p;
+
+  //! C¾ê`®Ì¶ñèp[T[iEUC-JPj
+  boost::spirit::functor_parser< detail::c_strlit_parse_functor< euc_jp > > const euc_jp_str_p;
+
+  //! C¾ê`®Ì¶ñèp[T[iUTF-8j
+  boost::spirit::functor_parser< detail::c_strlit_parse_functor< utf8 > > const utf8_str_p;
+
+}
Index: /cfg_oil/trunk/toppers/codeset.hpp
===================================================================
--- /cfg_oil/trunk/toppers/codeset.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/codeset.hpp	(revision 8)
@@ -0,0 +1,89 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/codeset.hpp
+ *  \brief  ¶R[híÊÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_CODESET_HPP_
+#define TOPPERS_CODESET_HPP_
+
+#include "toppers/config.hpp"
+
+namespace toppers
+{
+
+  /*!
+   *  \enum   codeset_t
+   *  \brief  ¶R[híÊ
+   *
+   *  »óÅÍú{êÌÝðl¶µÄ¢Ü·B
+   */
+  enum codeset_t
+  {
+    ascii,
+    shift_jis,
+    euc_jp,
+    utf8
+  };
+
+  template < codeset_t Codeset >
+    inline bool is_lead( char c )
+  {
+    return static_cast< unsigned char >( c ) & 0x80;
+  }
+
+  template <>
+    inline bool is_lead< shift_jis >( char c )
+  {
+    int ch = static_cast< unsigned char >( c );
+    return ( 0x81 <= ch && ch <= 0x9f ) || ( 0xe0 <= ch && ch <= 0xef );
+  }
+
+  template <>
+    inline bool is_lead< utf8 >( char c )
+  {
+    return ( static_cast< unsigned char >( c ) & 0xc0 ) != 0;
+  }
+
+}
+
+#endif  // ! TOPPERS_CODESET_HPP_
Index: /cfg_oil/trunk/toppers/config.hpp
===================================================================
--- /cfg_oil/trunk/toppers/config.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/config.hpp	(revision 8)
@@ -0,0 +1,88 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2004 by Witz Corporation, JAPAN    
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/config.hpp
+ *  \brief  nÉË¶·éÝè
+ */
+#ifndef	TOPPERS_CONFIG_HPP_
+#define	TOPPERS_CONFIG_HPP_
+
+#ifdef _MSC_VER
+
+# define for			if(0);else for
+
+# pragma warning( disable: 4127 )
+# pragma warning( disable: 4239 )
+# pragma warning( disable: 4505 )
+# pragma warning( disable: 4511 )
+# pragma warning( disable: 4512 )
+# pragma warning( disable: 4630 )
+# pragma warning( disable: 4701 )
+# pragma warning( disable: 4786 )
+# pragma warning( disable: 4819 )
+# pragma warning( disable: 4996 )
+
+#define _SCL_SECURE_NO_WARNINGS   1
+
+#endif	// _MSC_VER
+
+#ifdef __BORLANDC__
+
+#pragma warn -8026
+#pragma warn -8027
+
+#endif  // __BORLANDC__
+
+#ifdef __GNUC__
+
+# define TOPPERS_HAS_ICONV	1
+
+#endif	// __GNUC__
+
+#if defined(unix) || defined(__unix) || defined(__unix__)
+
+# define TOPPERS_HAS_ICONV	1
+
+#endif	// UNIX
+
+#endif	// ! TOPPERS_CONFIG_HPP_
Index: /cfg_oil/trunk/toppers/cpp.cpp
===================================================================
--- /cfg_oil/trunk/toppers/cpp.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/cpp.cpp	(revision 8)
@@ -0,0 +1,201 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <cctype>
+#include <cstring>
+#include <cstdio>
+#include <stdexcept>
+#include "toppers/cpp.hpp"
+
+namespace toppers
+{
+
+  /*!
+   *  \brief  ñdøpÅÍÜê½¶ñðWJ·éB
+   */
+  std::string expand_quote( std::string const& str )
+  {
+    // boost-1.35.xÈãÎô
+    std::string::size_type n = str.find_first_not_of( " \t\r\n" );
+    std::string quoted( str, n );
+
+    if ( quoted.empty() || quoted[0] != '"' || quoted[quoted.size() - 1] != '"' )
+    {
+      throw std::invalid_argument( "argument is not quoted" );
+    }
+    std::string result;
+    for ( std::string::const_iterator iter( quoted.begin() + 1 ), last( quoted.end() - 1 );
+          iter != last;
+          ++iter )
+    {
+      if ( *iter == '\\' )
+      {
+        if ( ++iter == last )
+        {
+          throw std::invalid_argument( "argument is not quoted" );
+        }
+        char c = *iter;
+        switch ( c )
+        {
+        case 'a':
+          c = '\a';
+          break;
+        case 'b':
+          c = '\b';
+          break;
+        case 'f':
+          c = '\f';
+          break;
+        case 'n':
+          c = '\n';
+          break;
+        case 'r':
+          c = '\r';
+          break;
+        case 't':
+          c = '\t';
+          break;
+        case 'v':
+          c = '\v';
+          break;
+        case 'x':
+          if ( std::isxdigit( static_cast< unsigned char >( *iter ) ) )
+          {
+            c = 0;
+            for ( std::string::const_iterator bound( iter + 2 );
+                  iter != bound && std::isxdigit( static_cast< unsigned char >( *iter ) );
+                  ++iter )
+            {
+              c <<= 4;
+              int t = std::tolower( static_cast< unsigned char >( *iter ) );
+              static char const xdigits[] = "0123456789abcdef";
+              c += std::strchr( xdigits, t ) - xdigits;
+            }
+          }
+          break;
+        default:
+          if ( '0' <= c && c <= '7' ) // '\ooo'
+          {
+            c = 0;
+            for ( std::string::const_iterator bound( iter + 3 );
+                  iter != bound && ( '0' <= *iter && *iter <= '7' );
+                  ++iter )
+            {
+              c = ( c << 3 ) + *iter - '0';
+            }
+          }
+          // Û¶¼i\uhhhh, \Uhhhhhhhhj¢Î
+          // ñ¶\Li<:j¢Î
+          // O¶\Li??/j¢Î
+          break;
+        }
+        result.push_back( c );
+      }
+      else
+      {
+        result.push_back( *iter );
+      }
+    }
+    return result;
+  }
+
+  /*!
+   *  \brief  ¶ñÅñdøpÅÍÞ
+   */
+  std::string quote_string( std::string const& str )
+  {
+    std::string result;
+    result.reserve( str.size() + 2 );
+
+    result.push_back( '"' );  // open
+
+    for ( std::string::const_iterator iter( str.begin() ), last( str.end() );
+          iter != last;
+          ++iter )
+    {
+      switch ( char c = *iter )
+      {
+      case '\'':
+        result += "\\\'";
+        break;
+      case '\"':
+        result += "\\\"";
+        break;
+      case '\0':
+        result += "\\0";
+        break;
+      case '\a':
+        result += "\\a";
+        break;
+      case '\b':
+        result += "\\b";
+        break;
+      case '\f':
+        result += "\\f";
+        break;
+      case '\n':
+        result += "\\n";
+        break;
+      case '\r':
+        result += "\\r";
+        break;
+      case '\t':
+        result += "\\t";
+        break;
+      case '\v':
+        result += "\\v";
+        break;
+      case '\\':
+        // SJIS¢Î
+        result.push_back( c );
+        result.push_back( c );
+        break;
+      default:
+        result.push_back( c );
+        break;
+      }
+    }
+
+    result.push_back( '"' );  // close
+
+    return result;
+  }
+
+}
Index: /cfg_oil/trunk/toppers/cpp.hpp
===================================================================
--- /cfg_oil/trunk/toppers/cpp.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/cpp.hpp	(revision 8)
@@ -0,0 +1,197 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/cpp.hpp
+ *  \brief  CvvZbTãÖ@\ÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_CPP_HPP_
+#define TOPPERS_CPP_HPP_
+
+#include "toppers/codeset.hpp"
+#include <boost/utility.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/exception.hpp>
+
+namespace toppers
+{
+
+  /*!
+   *  \brief  RgÌ
+   *  \param[in]  first     üÍ³ÌæªÊu
+   *  \param[in]  last      üÍ³ÌI[ÊuÌ
+   *  \param[out] result    ÊÌoÍæ
+   *  \param[in]  codeset   ¶R[h
+   *  \return     ®¹ãÌ result Ìl
+   *
+   *  CX^CÌubNRgÆC++X^CÌsRgðæè«Ü·B
+   *  sRgÍAsÌ \\ ª ÁÄàÌsÉÍ±«Ü¹ñB
+   */
+  template < class ForwardIterator, class OutputIterator >
+    OutputIterator remove_comment( ForwardIterator first, ForwardIterator last, OutputIterator result, codeset_t codeset = ascii )
+  {
+    enum { none, line_comment, block_comment, single_quote, double_quote } state = none;
+    char prev = '\0';
+
+    for ( ; first != last; ++first, ++result )
+    {
+      char c = *first;
+      ForwardIterator next_iter = boost::next( first );
+      char next = ( next_iter != last ? *next_iter : '\0' );
+
+      switch ( state )
+      {
+      case line_comment:
+        if ( c == '\n' )
+        {
+          state = none;
+          *result = c;
+        }
+        break;
+      case block_comment:
+        if ( c == '*' && next == '/' )
+        {
+          state = none;
+          ++first;
+        }
+        else if ( c == '\n' )
+        {
+          *result = c;
+        }
+        break;
+      case single_quote:
+        if ( c == '\\'
+          && !( codeset == shift_jis && is_lead< shift_jis >( prev ) )
+          && next == '\'' )   // '`\'` Ìê
+        {
+          *result++ = *first++;
+        }
+        else if ( c == '\'' )
+        {
+          state = none;
+        }
+        *result = *first;
+        break;
+      case double_quote:
+        if ( c == '\\'
+          && !( codeset == shift_jis && is_lead< shift_jis >( prev ) )
+          && next == '\"' )   // "`\"` Ìê
+        {
+          *result++ = *first++;
+        }
+        else if ( c == '\"' )
+        {
+          state = none;
+        }
+        *result = *first;
+        break;
+      default:
+        switch ( c )
+        {
+        case '/':   // RgJnÌo
+          if ( next == '*' )
+          {
+            state = block_comment;
+            ++first;
+          }
+          else if ( next == '/' )
+          {
+            state = line_comment;
+            ++first;
+          }
+          else
+          {
+            *result = *first;
+          }
+          break;
+        case '\'':
+          state = single_quote;
+          *result = c;
+          break;
+        case '\"':
+          state = double_quote;
+          *result = c;
+          break;
+        default:
+          *result = c;
+          break;
+        }
+      }
+      prev = *first;
+    }
+    return result;
+  }
+
+  /*!
+   *  \brief  CN[hpXÌTõ
+   *  \param[in]  first       TõÎÛfBNgñÌæªÊu
+   *  \param[in]  last        TõÎÛfBNgñÌI[ÊuÌ
+   *  \param[in]  headername  TõÎÛÌwb_¼
+   *  \return     TõÉ¬÷·êÎwb_ÖÌÎÜ½ÍtpXðÔ·B¸sµ½êÍó¶ñðÔ·B
+   */
+  template < class InputIterator >
+    std::string search_include_file( InputIterator first, InputIterator last, std::string const& headername )
+  {
+    namespace fs = boost::filesystem;
+    fs::path filename( headername, fs::native );
+
+    if ( fs::exists( filename ) && !fs::is_directory( filename ) )
+    {
+      return headername;
+    }
+    while ( first != last )
+    {
+      fs::path pathname = fs::path( *first, fs::native )/filename;
+      if ( fs::exists( pathname ) && !fs::is_directory( pathname ) )
+      {
+        return pathname.native_file_string();
+      }
+      ++first;
+    }
+    return std::string();
+  }
+
+  std::string expand_quote( std::string const& str );
+  std::string quote_string( std::string const& str );
+
+}
+
+#endif  // ! TOPPERS_CPP_HPP_
Index: /cfg_oil/trunk/toppers/csv.hpp
===================================================================
--- /cfg_oil/trunk/toppers/csv.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/csv.hpp	(revision 8)
@@ -0,0 +1,262 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/csv.hpp
+ *  \brief  CSVt@CüoÍÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_CSV_HPP_
+#define TOPPERS_CSV_HPP_
+
+#include <stdexcept>
+#include <ostream>
+#include <iterator>
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <boost/utility.hpp>
+#include "toppers/misc.hpp"
+
+namespace toppers
+{
+
+  class csv_error : public std::runtime_error
+  {
+  public:
+    explicit csv_error( long line )
+      : std::runtime_error( "CSV parse error" ), line_( line )
+    {
+    }
+    long line() const
+    {
+      return line_;
+    }
+  private:
+    long line_;
+  };
+
+  /*!
+   *  \class  basic_csv csv.hpp "toppers/csv.hpp"
+   *  \brief  CSV t@CÌðÍNX
+   */
+  template < typename CharT, class Traits = std::char_traits< CharT > >
+    class basic_csv
+  {
+  public:
+    typedef std::basic_string< CharT, Traits > string_type;
+    typedef typename std::vector< std::vector< string_type > >::const_iterator const_iterator;
+    typedef typename std::vector< std::vector< string_type > >::const_reference const_reference;
+    typedef typename std::vector< std::vector< string_type > >::value_type value_type;
+    typedef typename std::vector< std::vector< string_type > >::size_type size_type;
+
+    basic_csv();
+    template < class InputIterator >
+      basic_csv( InputIterator first, InputIterator last )
+    {
+      read( first, last );
+    }
+
+    template < class InputIterator >
+      void read( InputIterator first, InputIterator last )
+    {
+      const CharT dquo = widen< CharT >( '\"' );
+      const CharT comma = widen< CharT >( ',' );
+      const CharT lf = widen< CharT >( '\n' );
+      enum
+      {
+        none,
+        non_escaped,
+        escape_opened,
+        escape_closed
+      } state = none;
+      std::vector< std::vector< string_type > > records;
+      std::vector< string_type > record;
+      string_type field;
+      long line = 1;
+
+      record.reserve( 16 );
+      field.reserve( 255 );
+
+      while ( first != last )
+      {
+        CharT ch = *first;
+        if ( ch == dquo )
+        {
+          switch ( state )
+          {
+          case none:
+            state = escape_opened;
+            break;
+          case escape_opened:
+            ++first;
+            ch = *first;
+            if ( ch == dquo ) // "" ¾Á½ÌÅA" ðÇÁ
+            {
+              field.push_back( dquo );
+            }
+            else  // Â¶ "
+            {
+              state = escape_closed;
+            }
+            continue;   // ++first ð±êÈãÀs³¹È¢
+          default:
+            throw csv_error( line );
+            break;
+          }
+        }
+        else  // ch != dquo
+        {
+          if ( state == escape_opened )
+          {
+            field.push_back( ch );
+          }
+          else
+          {
+            if ( ch == comma || ch == lf )
+            {
+              record.push_back( field );
+              field.clear();
+              state = none;
+              if ( ch == lf ) // üsiRFC4180 ÅÍµ§ÉÍ CR-LF È¯êÎÈçÈ¢ªAÆè ¦¸ '\n' Æ·éj
+              {
+                records.push_back( record );
+                record.clear();
+                ++line;
+              }
+            }
+            else
+            {
+              field.push_back( ch );
+//              CharT const* debug_string = field.c_str();
+            }
+          }
+        }
+        ++first;
+      }
+      records_.swap( records );
+    }
+    template < class OutputIterator >
+      void write( OutputIterator result ) const
+    {
+      const CharT dquo = widen< CharT >( '\"' );
+      const CharT comma = widen< CharT >( ',' );
+      const CharT lf = widen< CharT >( '\n' );
+
+      for ( typename std::vector< std::vector< string_type > >::const_iterator r_iter( records_.begin() ), r_last( records_.end() );
+            r_iter != r_last;
+            ++r_iter )
+      {
+        for ( typename std::vector< string_type >::const_iterator f_iter( r_iter->begin() ), f_last( r_iter->end() );
+              f_iter != f_last;
+              ++f_iter )
+        {
+          std::string field;
+          bool need_escape = false;
+
+          for ( typename string_type::const_iterator s_iter( f_iter->begin() ), s_last( f_iter->end() );
+                s_iter != s_last;
+                ++s_iter )
+          {
+            CharT ch = *s_iter;
+            if ( ch == dquo )
+            {
+              field.push_back( dquo );
+              need_escape = true;
+            }
+            else if ( ch == comma || ch == lf )
+            {
+              need_escape = true;
+            }
+            field.push_back( ch );
+          }
+
+          if ( need_escape )
+          {
+            field = dquo + field + dquo;
+          }
+          result = std::copy( field.begin(), field.end(), result );
+          if ( boost::next( f_iter ) != f_last )
+          {
+            *result++ = comma;
+          }
+        }
+        *result++ = lf;
+      }
+    }
+
+    const_iterator begin() const
+    {
+      return records_.begin();
+    }
+    const_iterator end() const
+    {
+      return records_.end();
+    }
+    const_reference at( size_type pos ) const
+    {
+      return records_.at( pos );
+    }
+    const_reference operator[]( size_type pos ) const
+    {
+      return records_[ pos ];
+    }
+    bool empty() const
+    {
+      return records_.empty();
+    }
+    size_type size() const
+    {
+      return records_.size();
+    }
+    void swap( basic_csv& other )
+    {
+      records_.swap( other.records_ );
+    }
+  private:
+    std::vector< std::vector< string_type > > records_;
+  };
+
+  typedef basic_csv< char > csv;
+  typedef basic_csv< wchar_t > wcsv;
+
+}
+
+#endif  // TOPPERS_CSV_HPP_
Index: /cfg_oil/trunk/toppers/debug.hpp
===================================================================
--- /cfg_oil/trunk/toppers/debug.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/debug.hpp	(revision 8)
@@ -0,0 +1,79 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/debug.hpp
+ *  \brief  fobOpCuÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_DEBUG_HPP_
+#define TOPPERS_DEBUG_HPP_
+
+#include "toppers/config.hpp"
+#include <iostream>
+#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( WIN32 )
+#include <windows.h>
+#include <sstream>
+#endif
+
+namespace toppers
+{
+
+  template < typename T >
+  void trace( char const* str, const T& value )
+  {
+#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( WIN32 )
+    std::ostringstream ostr;
+    ostr << str << value << '\n';
+    ::OutputDebugString( ostr.str().c_str() );
+#else
+    std::cerr << str << value << std::endl;
+#endif
+  }
+
+}
+
+#if defined( _DEBUG ) || defined( __DEBUG ) || defined( DEBUG )
+#define TOPPERS_TRACE( str, value )   ::toppers::trace( ( str ), ( value ) )
+#else
+#define TOPPERS_TRACE( str, value )   ( ( void )0 )
+#endif
+
+#endif  // ! TOPPERS_DEBUG_HPP_
Index: /cfg_oil/trunk/toppers/diagnostics.cpp
===================================================================
--- /cfg_oil/trunk/toppers/diagnostics.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/diagnostics.cpp	(revision 8)
@@ -0,0 +1,123 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <cstdio>
+#include <string>
+#include "toppers/diagnostics.hpp"
+#include "toppers/text_line.hpp"
+
+namespace toppers
+{
+  namespace
+  {
+    int error_abort_threshold = 100;
+    int error_count = 0;
+    std::string program_name( "(unknown)" );
+  }
+
+  int get_error_count()
+  {
+    return error_count;
+  }
+
+  int increment_error_count()
+  {
+    return ++error_count;
+  }
+
+  void set_program_name( char const* name )
+  {
+    program_name = name;
+  }
+
+  std::string const& get_program_name()
+  {
+    return program_name;
+  }
+
+  int set_error_abort_threshold( int thresh )
+  {
+    if ( thresh < 1 )
+    {
+      return -1;
+    }
+    int previous = error_abort_threshold;
+    error_abort_threshold = thresh;
+    return previous;
+  }
+
+  void warning( const char* msg )
+  {
+    fprintf( stderr, "%s: %s: %s\n", program_name.c_str(), _( "warning" ), msg );
+  }
+  void warning( text_line const& line, const char* msg )
+  {
+    fprintf( stderr, "%s:%s:%ld: %s: %s\n", program_name.c_str(), line.file.c_str(), line.line, _( "warning" ), msg );
+  }
+  void error( const char* msg )
+  {
+    fprintf( stderr, "%s: %s: %s\n", program_name.c_str(), _( "error" ), msg );
+    ++error_count;
+    if ( error_abort_threshold <= error_count )
+    {
+      throw diagnostics_error( _( "too many errors" ) );
+    }
+  }
+  void error( text_line const& line, const char* msg )
+  {
+    fprintf( stderr, "%s:%s:%ld: %s: %s\n", program_name.c_str(), line.file.c_str(), line.line, _( "error" ), msg );
+    ++error_count;
+    if ( error_abort_threshold <= error_count )
+    {
+      throw diagnostics_error( _( "too many errors" ) );
+    }
+  }
+  void fatal( const char* msg )
+  {
+    fprintf( stderr, "%s: %s: %s\n", program_name.c_str(), _( "error" ), msg );
+    throw diagnostics_error( _( "fatal error" ) );
+  }
+  void fatal( text_line const& line, const char* msg )
+  {
+    fprintf( stderr, "%s:%s:%d: %s: %s\n", program_name.c_str(), line.file.c_str(), line.line, _( "error" ), msg );
+    throw diagnostics_error( _( "fatal error" ) );
+  }
+
+}
Index: /cfg_oil/trunk/toppers/diagnostics.hpp
===================================================================
--- /cfg_oil/trunk/toppers/diagnostics.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/diagnostics.hpp	(revision 8)
@@ -0,0 +1,240 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ *  Copyright (C) 2010 by Meika Sugimoto
+ *
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/diagnostics.hpp
+ *  \brief  ffÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_DIAGNOSTICS_HPP_
+#define TOPPERS_DIAGNOSTICS_HPP_
+
+#include <stdexcept>
+#include "toppers/debug.hpp"
+#include "toppers/gettext.hpp"
+#include <boost/format.hpp>
+
+namespace toppers
+{
+
+  struct text_line;
+
+  class diagnostics_error : public std::runtime_error
+  {
+  public:
+    diagnostics_error( std::string const& msg ) : std::runtime_error( msg ) {}
+  };
+
+  class normal_exit {};
+
+  int get_error_count();
+  int increment_error_count();
+  void set_program_name( char const* name );
+  std::string const& get_program_name();
+  int set_error_abort_threshold( int thresh );
+  void warning( const char* msg );
+  void warning( text_line const& line, const char* msg );
+  void error( const char* msg );
+  void error( text_line const& line, const char* msg );
+  void fatal( const char* msg );
+  void fatal( text_line const& line, const char* msg );
+
+  template < typename T1 >
+    inline void warning( const char* str, T1 const& arg1 )
+  {
+    warning( ( boost::format( str ) % arg1 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2 >
+    inline void warning( const char* str, T1 const& arg1, T2 const& arg2 )
+  {
+    warning( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3 >
+    inline void warning( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
+  {
+    warning( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3, typename T4 >
+    inline void warning( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
+  {
+    warning( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
+  }
+
+  template < typename T1 >
+    inline void warning( text_line const& line, const char* str, T1 const& arg1 )
+  {
+    warning( line, ( boost::format( str ) % arg1 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2 >
+    inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
+  {
+    warning( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3 >
+    inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
+  {
+    warning( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3, typename T4 >
+    inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
+  {
+    warning( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
+  }
+
+  template < typename T1 >
+    inline void error( const char* str, T1 const& arg1 )
+  {
+    error( ( boost::format( str ) % arg1 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2 >
+    inline void error( const char* str, T1 const& arg1, T2 const& arg2 )
+  {
+    error( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3 >
+    inline void error( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
+  {
+    error( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3, typename T4 >
+    inline void error( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
+  {
+    error( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3, typename T4, typename T5 >
+    inline void error( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 , T5 const& arg5 )
+  {
+    error( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 % arg5 ).str().c_str() );
+  }
+  
+  template < typename T1 >
+    inline void error( text_line const& line, const char* str, T1 const& arg1 )
+  {
+    error( line, ( boost::format( str ) % arg1 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2 >
+    inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
+  {
+    error( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3 >
+    inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
+  {
+    error( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3, typename T4 >
+    inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
+  {
+    error( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
+  }
+
+  template < typename T1 >
+    inline void fatal( const char* str, T1 const& arg1 )
+  {
+    fatal( ( boost::format( str ) % arg1 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2 >
+    inline void fatal( const char* str, T1 const& arg1, T2 const& arg2 )
+  {
+    fatal( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3 >
+    inline void fatal( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
+  {
+    fatal( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3, typename T4 >
+    inline void fatal( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
+  {
+    fatal( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
+  }
+
+  template < typename T1 >
+    inline void fatal( text_line const& line, const char* str, T1 const& arg1 )
+  {
+    fatal( line, ( boost::format( str ) % arg1 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2 >
+    inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
+  {
+    fatal( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3 >
+    inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
+  {
+    fatal( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
+  }
+
+  template < typename T1, typename T2, typename T3, typename T4 >
+    inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
+  {
+    fatal( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
+  }
+
+  inline void exit()
+  {
+    throw normal_exit();
+  }
+
+#undef  _
+#define _( str )  ::toppers::gettext( str ).c_str()
+
+}
+
+#endif  // ! TOPPERS_DIAGNOSTICS_HPP_
+
Index: /cfg_oil/trunk/toppers/gettext.cpp
===================================================================
--- /cfg_oil/trunk/toppers/gettext.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/gettext.cpp	(revision 8)
@@ -0,0 +1,225 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <cstdlib>
+#include <stdlib.h>	// CygwinÎô
+#include <cstring>
+#include <clocale>
+#include <string>
+#include <map>
+#include <fstream>
+#include <stdexcept>
+#include "toppers/gettext.hpp"
+#include "toppers/cpp.hpp"
+#include "toppers/global.hpp"
+#include <boost/scoped_array.hpp>
+#include <boost/any.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+
+namespace toppers
+{
+  namespace
+  {
+
+    std::map< std::string, std::string > msgcat;
+
+    void register_msgcat( std::string const& msgid, std::string const& msgstr )
+    {
+      std::string::size_type size = msgstr.size();
+      boost::scoped_array< wchar_t > wbuf( new wchar_t[ size + 1 ] );
+      boost::scoped_array< char > buf( new char[ size + 1 ] );
+      wchar_t* wcs = wbuf.get();
+      wchar_t wc = 0;
+      for ( std::string::const_iterator iter( msgstr.begin() ), last( msgstr.end() ); iter != last; ++iter )
+      {
+        int c = static_cast< unsigned char >( *iter );
+        if ( ( ( c & 0xc0 ) == 0xc0 ) || ( c < 0x80 ) ) // æsoCg
+        {
+          if ( wc != 0 )
+          {
+            *wcs++ = wc;
+            wc = 0;
+          }
+          if ( ( c & 0x80 ) == 0 )
+          {
+            wc = static_cast< wchar_t >( c );
+          }
+          else if ( ( c & 0xe0 ) == 0xc0 )
+          {
+            wc = static_cast< wchar_t >( c & 0x1f );
+          }
+          else if ( ( c & 0xf0 ) == 0xe0 )
+          {
+            wc = static_cast< wchar_t >( c & 0xf );
+          }
+          else
+          {
+            // TQ[gÍ¢Îi±±ÅÎµ½ÆµÄàA¶R[hÏ·Éµ­¶éÂ\«åj
+          }
+        }
+        else    // ã±oCg
+        {
+          wc = static_cast< wchar_t >( ( wc << 6 ) | ( c & 0x3f ) );
+        }
+      }
+      if ( wc != 0 )
+      {
+        *wcs++ = wc;
+      }
+      *wcs = L'\0';
+
+      // « ±ÌÔÍµÄáOª­¶µÈ¢
+      char const* locale = std::setlocale( LC_CTYPE, "" );
+      /* std:: */wcstombs( buf.get(), wbuf.get(), size + 1 );     // Unicode ©çÂ«Ë¶Ì¶R[hÖÏ·
+      std::setlocale( LC_CTYPE, locale );
+      // ª ±ÌÔÍµÄáOª­¶µÈ¢
+
+      msgcat[ msgid ] = std::string( buf.get() );
+    }
+
+    bool msgcat_loaded = false;
+
+  }
+
+  /*!
+   *  \brief      bZ[WJ^OÌ[h
+   *  \param[in]  dir     *.po t@Cª¶Ý·éfBNg
+   *  \retval     true    ¬÷
+   *  \retval     false   ¸s
+   *
+   *  ÀðÈÖ»·é½ßA.pot@CÌLqû@ÉÍÈºÌ§ñª éB
+   *  - msgid, msgstr ÍK¸sÌæªÉLq·éB
+   *  - msgid, msgstr Ì¼ãÉÍAK¸óÞ¶ê¶ÆµA»Ì¼ãÉ¶ñðLq·éB
+   *  - ¶ñÌÝðLq·ésÍK¸ " ÅnßéB
+   *  - .pot@CÍÌ¶R[hÍK¸ UTF-8N Æ·éB
+   */
+  bool load_msgcat( std::string const& dir )
+  {
+    namespace fs = boost::filesystem;
+    char const* env = std::getenv( "TOPPERS_CFG_LANG" );
+//      env = "ja";
+    if ( env == 0 )
+    {
+      return false;
+    }
+    std::string lang( env );
+
+    fs::path cfg_dir( dir, fs::native );
+    fs::path po_file( cfg_dir/fs::path( lang + ".po", fs::native ) );
+    std::ifstream ifs( po_file.native_file_string().c_str() );
+    std::string msgid;
+    std::string msgstr;
+
+    while ( ifs )
+    {
+      std::string str;
+      std::getline( ifs, str );
+
+      // üs¶Ìá¢ðzû
+      std::string::size_type pos = str.find_last_not_of( " \t\r\n" ); // Â¢ÅÉsÌóÞà
+      if ( pos != std::string::npos && pos < str.size() - 1 )
+      {
+        char c = str[pos];
+        str.erase( pos + 1, std::string::npos );
+      }
+
+      if ( str.empty() || str[ 0 ] == '#' || str == "" )
+      {
+        ;   // ósÜ½ÍRgs
+      }
+      else
+      {
+        try
+        {
+          if ( std::strncmp( str.c_str(), "msgid", sizeof( "msgid" )-1 ) == 0 )
+          {
+            str.erase( 0, sizeof( "msgid" )-1+1 );
+            msgid = expand_quote( str );           
+          }
+          else if ( std::strncmp( str.c_str(), "msgstr", sizeof( "msgstr" )-1 ) == 0 )
+          {
+            str.erase( 0, sizeof( "msgstr" )-1+1 );
+            msgstr = expand_quote( str );
+          }
+          else
+          {
+            msgstr += expand_quote( str );
+          }
+          if ( !msgid.empty() && !msgstr.empty() )  // ¼OÌ msgid / msgstr ðo^
+          {
+            register_msgcat( msgid, msgstr );
+            msgid.clear();
+            msgstr.clear();
+          }
+        }
+        catch ( std::invalid_argument& )
+        {
+          return false;
+        }
+      }
+    }
+    msgcat_loaded = true;
+    return true;
+  }
+
+  /*!
+   *  \brief      bZ[WÌ|ó
+   *  \param[in]  message   bZ[WID
+   *  \return     |óãÌbZ[W
+   */
+  std::string const& gettext( std::string const& message )
+  {
+    static bool f = load_msgcat( get_global< std::string >( "cfg-directory" ) );
+    if ( !msgcat_loaded )
+    {
+      return message;
+    }
+
+    std::map< std::string, std::string >::const_iterator iter( msgcat.find( message ) ), last( msgcat.end() );
+    if ( iter != last )
+    {
+      std::string const& result( iter->second );
+      return result;
+    }
+    return message;
+  }
+
+}
Index: /cfg_oil/trunk/toppers/gettext.hpp
===================================================================
--- /cfg_oil/trunk/toppers/gettext.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/gettext.hpp	(revision 8)
@@ -0,0 +1,60 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/gettext.hpp
+ *  \brief  GNU gettext ÌãÖR[h
+ *
+ *  {Å êÎGNU gettextðgp·×«©àmêÈ¢ªAVisual C++ÅGNU gettextðgp·éÉÍA
+ *  CXg[ªÊ|È±Æà èAãÖR[hð©OÅpÓ·é±ÆÉµ½B
+ */
+#ifndef TOPPERS_GETTEXT_HPP_
+#define TOPPERS_GETTEXT_HPP_
+
+#include <string>
+#include "toppers/config.hpp"
+
+namespace toppers
+{
+  bool load_msgcat( std::string const& dir );
+  std::string const& gettext( std::string const& message );
+}
+
+#endif  // ! TOPPERS_GETTEXT_HPP_
Index: /cfg_oil/trunk/toppers/global.cpp
===================================================================
--- /cfg_oil/trunk/toppers/global.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/global.cpp	(revision 8)
@@ -0,0 +1,79 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <new>
+#include <map>
+#include "toppers/global.hpp"
+
+namespace toppers
+{
+
+  /*!
+   *  \brief  O[oIuWFNgÖÌANZbT
+   *  \param[in]  key   IuWFNg¼
+   *  \return     key Åwèµ½IuWFNgÖÌQÆ
+   *
+   *  O[oIuWFNgÖÌANZXðê³Ç·éB
+   *  ±ÌÖðîµÄO[oANZXðs¤±ÆÉæèAÊíÌÃIIuWFNgªÂ®Iú»Ì
+   *  ÉÖ·éâèªðÁ³êéB
+   *  Ü½AàIÉÇµÄ¢éIuWFNgÍAvOI¹ÉfXgN^ªÄÎêé±ÆÍÈ¢B
+   *  iµ§É¢¦Î[NÉ ½éªA¾QÍÆ­ÉÈ¢j
+   */
+  boost::any& global( std::string const& key )
+  {
+    static std::map< std::string, boost::any >* gvm = 0;
+    if ( gvm == 0 )
+    {
+      union max_aligner
+      {
+        long long ll;
+        double d;
+        long double ld;
+        void* pv;
+        void (*pfn)();
+      };
+      const std::size_t size = ( sizeof( std::map< std::string, boost::any > ) + sizeof( max_aligner ) - 1 ) / sizeof( max_aligner );
+      static max_aligner gvm_storage[ size ];
+      gvm = new ( gvm_storage ) std::map< std::string, boost::any >;  // fXgN^ÍÄÎêÈ¢
+    }
+    return ( *gvm )[key];
+  }
+
+}
Index: /cfg_oil/trunk/toppers/global.hpp
===================================================================
--- /cfg_oil/trunk/toppers/global.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/global.hpp	(revision 8)
@@ -0,0 +1,92 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/global.hpp
+ *  \brief  ^O[oIuWFNgÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_GLOBAL_HPP_
+#define TOPPERS_GLOBAL_HPP_
+
+#include <cstddef>
+#include <stdexcept>
+#include <string>
+#include "toppers/config.hpp"
+#include <boost/any.hpp>
+
+namespace toppers
+{
+
+  class global_error : public std::logic_error
+  {
+  public:
+    explicit global_error( std::string const& s )
+      : std::logic_error( "there is not global object `" + s + "`" )
+    {
+    }
+  };
+
+  boost::any& global( std::string const& key );
+
+  template < typename T >
+    T const& get_global( std::string const& key )
+  {
+    try
+    {
+      return boost::any_cast< T const& >( global( key ) );
+    }
+    catch ( boost::bad_any_cast& )
+    {
+      throw global_error( key );
+    }
+    static T t;
+    return t;
+  }
+
+  template < typename T >
+    inline T const& get_global( std::string const& key, T& storage )
+  {
+    storage = get_global< T >( key );
+    return storage;
+  }
+
+}
+
+#endif  // ! TOPPERS_GLOBAL_HPP_
Index: /cfg_oil/trunk/toppers/io.cpp
===================================================================
--- /cfg_oil/trunk/toppers/io.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/io.cpp	(revision 8)
@@ -0,0 +1,85 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <fstream>
+#include <algorithm>
+#include <iterator>
+#include "toppers/io.hpp"
+#include "toppers/diagnostics.hpp"
+#include <boost/format.hpp>
+
+namespace toppers
+{
+
+  void read( std::string const& filename, std::string& buf, std::ios_base::openmode omode )
+  {
+    std::ifstream ifs( filename.c_str(), std::ios_base::in | omode );
+    if ( !ifs.is_open() )
+    {
+      throw io_error( str( boost::format( _( "cannot open file `%1%\'" ) ) % filename ) );
+    }
+    std::string t;
+    char c;
+    while ( ifs.get( c ) )
+    {
+      t.push_back( c );
+    }
+    if ( ifs.bad() )
+    {
+      throw io_error( _( "I/O error" ) );
+    }
+    buf.swap( t );
+  }
+
+  void write( std::string const& filename, std::string const& buf, std::ios_base::openmode omode )
+  {
+    std::ofstream ofs( filename.c_str(), std::ios_base::out | omode );
+    if ( !ofs.is_open() )
+    {
+      throw io_error( str( boost::format( _( "cannot open file `%1%\'" ) ) % filename ) );
+    }
+    std::copy( buf.begin(), buf.end(), std::ostream_iterator< char >( ofs ) );
+    if ( ofs.bad() )
+    {
+      throw io_error( _( "I/O error" ) );
+    }
+  }
+
+}
Index: /cfg_oil/trunk/toppers/io.hpp
===================================================================
--- /cfg_oil/trunk/toppers/io.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/io.hpp	(revision 8)
@@ -0,0 +1,72 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/io.hpp
+ *  \brief  t@CüoÍÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_IO_HPP_
+#define TOPPERS_IO_HPP_
+
+#include <ios>
+#include <string>
+#include <stdexcept>
+#include "toppers/config.hpp"
+
+namespace toppers
+{
+
+  class io_error : public std::runtime_error
+  {
+  public:
+    explicit io_error( std::string const& msg ) : std::runtime_error( msg ) {}
+  };
+
+  void read( std::string const& filename, std::string& buf, std::ios_base::openmode omode = std::ios_base::openmode( 0 ) );
+  void write( std::string const& filename, std::string const& buf, std::ios_base::openmode omode = std::ios_base::openmode( 0 ) );
+
+  inline void append( std::string const& filename, std::string const buf, std::ios_base::openmode omode = std::ios_base::openmode( 0 ) )
+  {
+    write( filename, buf, omode | std::ios_base::app );
+  }
+
+}
+
+#endif  // ! TOPPERS_IO_HPP_
Index: /cfg_oil/trunk/toppers/macro_processor.cpp
===================================================================
--- /cfg_oil/trunk/toppers/macro_processor.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/macro_processor.cpp	(revision 8)
@@ -0,0 +1,1954 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <cstdlib>
+#include <cctype>
+#include <cerrno>
+#include <algorithm>
+#include <functional>
+#include <iterator>
+#include <sstream>
+#include <fstream>
+#include <limits>
+#include "toppers/workaround.hpp"
+#include "toppers/io.hpp"
+#include "toppers/cpp.hpp"
+#include "toppers/global.hpp"
+#include "toppers/macro_processor.hpp"
+#include "toppers/diagnostics.hpp"
+#include "toppers/misc.hpp"
+#include <boost/spirit.hpp>
+#include <boost/spirit/dynamic.hpp>
+#include <boost/spirit/tree/parse_tree.hpp>
+#include <boost/lexical_cast.hpp>
+
+// ñW}NÌè`ð
+#ifdef  max
+#undef  max
+#endif
+#ifdef  min
+#undef  min
+#endif
+
+#define DEBUG_TRACE   0
+
+namespace toppers
+{
+
+  namespace
+  {
+
+    struct expr_error {};
+
+     /*!
+      *  \struct parser macro_processor.cpp "toppers/macro_processor.cpp"
+      *  \brief  }NàÉLq³êé®Ìp[T
+      */
+    struct parser : boost::spirit::grammar< parser >
+    {
+      enum rule_id_t
+      {
+        id_other = 0,
+
+        id_expression, id_assignment_expr, id_logical_or_expr, id_logical_and_expr,
+        id_or_expr, id_xor_expr, id_and_expr, id_equality_expr, id_relational_expr,
+        id_shift_expr, id_additive_expr, id_multiplicative_expr, id_unary_expr,
+        id_postfix_expr, id_primary_expr, id_lvalue_expr, id_identifier, id_constant,
+        id_string_literal, id_ordered_list, id_ordered_sequence, id_ordered_item,
+
+        id_root, id_top,
+        id_function_, id_if_, id_foreach_, id_joineach_, id_error_, id_warning_,
+        id_file_, id_expr_, id_plain,
+
+        id_illegal = -1
+      };
+      enum expected_t
+      {
+        doller_expected, end_expected, close_paren_expected, close_brace_expected,
+        close_bracket_expected
+      };
+
+      /*!
+       *  \struct error_handler static_api_parser.hpp "toppers/oil/static_api_parser.hpp"
+       *  \brief  ÃIAPIÌ\¶ðÍÉ¨¯éG[t@N^
+       */
+      struct error_handler
+      {
+        template < class Scanner, class Error >
+          boost::spirit::error_status<> operator()( Scanner const& scan, Error const& error ) const
+        {
+          typename Error::iterator_t iter( error.where );
+          while ( iter != scan.last && *iter != '\0' && *iter != '\n' )
+          {
+            ++iter;
+          }
+          std::string str;
+          if ( error.where == iter )
+          {
+            str = _( "end of line" );
+          }
+          else
+          {
+            str = '\"' + std::string( error.where, iter ) + '\"';
+          }
+
+          text_line ln;
+          if ( error.where != scan.last )
+          {
+            ln = get_text_line( error.where );
+          }
+          else
+          {
+            // ev[gt@CÌÅIsðßé
+            typename Error::iterator_t prev( scan.first );
+            for ( iter = scan.first; iter != scan.last; ++iter )
+            {
+              prev = iter;
+            }
+            ln = get_text_line( prev );
+          }
+          switch ( error.descriptor )
+          {
+          case doller_expected:
+            toppers::fatal( ln, _( "missing `%1%\' before %2%" ), '$', str );
+            break;
+          case end_expected:
+            toppers::fatal( ln, _( "missing `%1%\' before %2%" ), "$END$", str );
+            break;
+          case close_paren_expected:
+            toppers::fatal( ln, _( "missing `%1%\' before %2%" ), ")", str );
+            break;
+          case close_brace_expected:
+            toppers::fatal( ln, _( "missing `%1%\' before %2%" ), "}", str );
+            break;
+          case close_bracket_expected:
+            toppers::fatal( ln, _( "missing `%1%\' before %2%" ), "]", str );
+            break;
+          }
+          return  boost::spirit::error_status<>( boost::spirit::error_status<>::fail );
+        }
+      };
+
+
+      template < class Scanner >
+        struct definition
+      {
+        typedef boost::spirit::rule< Scanner, boost::spirit::dynamic_parser_tag > rule_t;
+        typedef boost::spirit::guard< expected_t > guard_t;
+        typedef boost::spirit::assertion< expected_t > assertion_t;
+
+        rule_t  expression,
+                assignment_expr,
+                logical_or_expr,
+                logical_and_expr,
+                or_expr,
+                xor_expr,
+                and_expr,
+                equality_expr,
+                relational_expr,
+                shift_expr,
+                additive_expr,
+                multiplicative_expr,
+                unary_expr,
+                postfix_expr,
+                primary_expr,
+                lvalue_expr,
+                identifier,
+                constant,
+                string_literal,
+                ordered_list,
+                ordered_sequence,
+                ordered_item;
+
+        rule_t  root,
+                top,
+                function_,
+                if_,
+                foreach_,
+                joineach_,
+                error_,
+                warning_,
+                file_,
+                expr_,
+                call,
+                plain;
+
+        guard_t guard_function_,
+                guard_if_,
+                guard_foreach_,
+                guard_joineach_,
+                guard_expr,
+                guard_postfix_expr,
+                guard_lvalue_expr,
+                guard_ordered_list;
+
+        assertion_t expect_doller,
+                    expect_end,
+                    expect_close_paren,
+                    expect_close_brace,
+                    expect_close_bracket;
+
+        definition( parser const& self )
+          : expect_doller( doller_expected ),
+            expect_end( end_expected ),
+            expect_close_paren( close_paren_expected ),
+            expect_close_brace( close_brace_expected ),
+            expect_close_bracket( close_bracket_expected )
+        {
+          using namespace boost::spirit;
+
+          set_id();
+
+          expression =
+              logical_or_expr;
+          assignment_expr =
+              lvalue_expr >> '=' >> expression;
+          logical_or_expr =
+              logical_and_expr >> *( "||" >> logical_and_expr );
+          logical_and_expr =
+              or_expr >> *( "&&" >> or_expr );
+          or_expr =
+              xor_expr >> *( '|' >> xor_expr );
+          xor_expr =
+              and_expr >> *( '^' >> and_expr );
+          and_expr =
+              equality_expr >> *( '&' >> equality_expr );
+          equality_expr =
+              relational_expr >> *( ( str_p( "==" ) | "!=" ) >> relational_expr );
+          relational_expr =
+              shift_expr >> *( ( str_p( "<=" ) | ">=" | "<" | ">" ) >> shift_expr );
+          shift_expr =
+              additive_expr >> *( ( str_p( "<<" ) | ">>" ) >> additive_expr );
+          additive_expr =
+              multiplicative_expr >> *( chset<>( "+-" ) >> multiplicative_expr );
+          multiplicative_expr =
+              unary_expr >> *( chset<>( "*/%" ) >> unary_expr );
+          unary_expr =
+              *chset<>( "-+~!@" ) >> postfix_expr;
+          postfix_expr =
+            guard_postfix_expr
+            (
+                ( identifier >> '(' >> *( expression % ',' ) >> expect_close_paren( ch_p( ')' ) ) )
+              | primary_expr
+            )
+            [
+              error_handler()
+            ];
+          primary_expr =
+              lvalue_expr | ordered_list | constant | string_literal
+            | ( '(' >> expression >> ')' );
+          lvalue_expr =
+            guard_lvalue_expr
+            (
+                ( identifier >> '[' >> expression >> expect_close_bracket( ch_p( ']' ) ) )
+              | identifier
+            )
+            [
+              error_handler()
+            ];
+          identifier =
+              leaf_node_d[ lexeme_d[ ( alpha_p | '_' ) >> *( alnum_p | '_' | '.' ) ] ];
+          constant =
+              leaf_node_d
+              [
+                lexeme_d
+                [
+                  if_p( '0' ) // 16iÜ½Í8i
+                  [
+                    !(
+                        ( ( ch_p( 'x' ) | 'X' ) >> ( hex_p | +xdigit_p ) )
+                      | ( oct_p | +chset<>( "0-7" ) )
+                     )
+                  ]
+                  .else_p // 10i
+                  [
+                    ( int_p | +digit_p )
+                  ]
+                ]
+              ];
+          string_literal =
+              leaf_node_d[ lexeme_d[ '\"' >> *( c_escape_ch_p - '\"' ) >> '\"' ] ];
+          ordered_list =
+            guard_ordered_list
+            (
+              '{' >> !( ( ordered_sequence | ordered_item ) >> *( ';' >> ( ordered_sequence | ordered_item ) ) ) >> expect_close_brace( ch_p( '}' ) )
+            )
+            [
+              error_handler()
+            ];
+          ordered_sequence =
+              ( constant >> ',' >> constant >> ',' >> "..." >> ',' >> constant );
+          ordered_item =
+              expression >> *( ',' >> expression );
+
+          root =
+              top >> lexeme_d[ !space_p ];
+          top =
+              *( function_ | if_ | foreach_ | joineach_ | warning_ | error_ | file_ | expr_ | plain );
+          function_ =
+            guard_function_
+            (
+              "$FUNCTION" >> identifier >> expect_doller( ch_p( '$' ) ) >> top >> expect_end( str_p( "$END$" ) )
+            )
+            [
+              error_handler()
+            ];
+          if_ =
+            guard_if_
+            (
+                ( "$IF" >> expression >> expect_doller( ch_p( '$' ) ) >> top >> "$ELSE$" >> top >> expect_end( str_p( "$END$" ) ) )
+              | ( "$IF" >> expression >> expect_doller( ch_p( '$' ) ) >> top >> expect_end( str_p( "$END$" ) ) )
+            )
+            [
+              error_handler()
+            ];
+          foreach_ =
+            guard_foreach_
+            (
+              "$FOREACH" >> identifier >> expression >> expect_doller( ch_p( '$' ) ) >> top >> expect_end( str_p( "$END$" ) )
+            )
+            [
+              error_handler()
+            ];
+          joineach_ =
+            guard_joineach_
+            (
+              "$JOINEACH" >> identifier >> expression >> expression >> expect_doller( ch_p( '$' ) ) >> top >> expect_end( str_p( "$END$" ) )
+            )
+            [
+              error_handler()
+            ];
+          warning_ =
+              "$WARNING$" >> top >> "$END$" >> !eol_p
+            | "$WARNING" >> expression >> '$' >> top >> "$END$";
+          error_ =
+              "$ERROR$" >> top >> "$END$" >> !eol_p
+            | "$ERROR" >> expression >> '$' >> top >> "$END$";
+          file_ =
+              "$FILE" >> string_literal >> '$';
+          expr_ =
+            guard_expr
+            (
+              ( ( '$' >> ( assignment_expr | expression ) >> expect_doller( ch_p( '$' ) ) ) - "$END$" - "$ELSE$" )
+            )
+            [
+              error_handler()
+            ];
+          plain =
+              leaf_node_d[ lexeme_d[ +( anychar_p - '$' ) | "$$" ] ];
+        }
+        rule_t const& start() const { return root; }
+        void set_id()
+        {
+          expression.set_id( id_expression );
+          assignment_expr.set_id( id_assignment_expr );
+          logical_or_expr.set_id( id_logical_or_expr );
+          logical_and_expr.set_id( id_logical_and_expr );
+          or_expr.set_id( id_or_expr );
+          xor_expr.set_id( id_xor_expr );
+          and_expr.set_id( id_and_expr );
+          equality_expr.set_id( id_equality_expr );
+          relational_expr.set_id( id_relational_expr );
+          shift_expr.set_id( id_shift_expr );
+          additive_expr.set_id( id_additive_expr );
+          multiplicative_expr.set_id( id_multiplicative_expr );
+          unary_expr.set_id( id_unary_expr );
+          postfix_expr.set_id( id_postfix_expr );
+          primary_expr.set_id( id_primary_expr );
+          lvalue_expr.set_id( id_lvalue_expr );
+          identifier.set_id( id_identifier );
+          constant.set_id( id_constant );
+          string_literal.set_id( id_string_literal );
+          ordered_list.set_id( id_ordered_list );
+          ordered_sequence.set_id( id_ordered_sequence );
+          ordered_item.set_id( id_ordered_item );
+
+          root.set_id( id_root );
+          top.set_id( id_top );
+          function_.set_id( id_function_ );
+          if_.set_id( id_if_ );
+          foreach_.set_id( id_foreach_ );
+          joineach_.set_id( id_joineach_ );
+          error_.set_id( id_error_ );
+          warning_.set_id( id_warning_ );
+          file_.set_id( id_file_ );
+          expr_.set_id( id_expr_ );
+          plain.set_id( id_plain );
+        }
+      };
+
+      parser()
+      {
+      }
+    };
+
+    typedef macro_processor::element element;
+    typedef macro_processor::var_t var_t;
+    typedef macro_processor::context context;
+
+    //! ÏªÛ·élÌQÆ
+    std::tr1::int64_t get_i( var_t const& var, context const* p_ctx )
+    {
+      if ( var.empty() )
+      {
+        fatal( p_ctx->line, _( "non-value is referred" ) );
+        return 0;
+      }
+      element e = var.front();
+      if ( !e.i )
+      {
+        fatal( p_ctx->line, _( "non-value is referred" ) );
+        return 0;
+      }
+      return e.i.get();
+    }
+    //! ÏªÛ·é¶ñÌQÆ
+    std::string get_s( var_t const& var, context const* p_ctx )
+    {
+      if ( var.empty() )
+      {
+        return "";
+      }
+      std::string result;
+      for ( var_t::const_iterator iter( var.begin() ), last( var.end() ); iter != last; ++iter )
+      {
+        if ( !iter->s.empty() )
+        {
+          result += iter->s;
+        }
+        else if ( !iter->v.empty() )
+        {
+          result += iter->v;
+        }
+        else if ( iter->i )
+        {
+          result += boost::lexical_cast< std::string >( iter->i.get() );
+        }
+        if ( boost::next( iter ) != last )
+        {
+          result += ",";
+        }
+      }
+      return result;
+    }
+
+    typedef boost::spirit::tree_node< boost::spirit::node_iter_data< text::const_iterator > > tree_node_t;
+    bool eval_node( tree_node_t const& node, context* p_ctx );
+
+    //! ãü®
+    bool assignment_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0 1   2
+      // lhs = rhs
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        std::string name( get_s( lhs, p_ctx ) );
+        if ( eval_node( node.children[2], p_ctx ) )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          var_t old_var( p_ctx->var_map[ name ] );
+          p_ctx->var_map[ name ] = rhs;
+          if ( p_ctx->hook_on_assign != 0 )
+          {
+            ( *p_ctx->hook_on_assign )( node.children[0].value.begin().line(), name, old_var, rhs, p_ctx );
+          }
+        }
+      }
+      return true;
+    }
+
+    //! _a®
+    bool logical_or_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0  1   2
+      // lhs || rhs ...
+      bool result = true;
+
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 2; i < n; i += 2 )
+        {
+          std::tr1::int64_t value = 0;
+          try
+          {
+            value = get_i( lhs, p_ctx );
+          }
+          catch ( expr_error& )
+          {
+            error( node.children[0].value.begin().line(), _( "`%1%\' does not have a value" ), get_s( lhs, p_ctx ) );
+            throw;
+          }
+          if ( value )
+          {
+            break;
+          }
+          result = eval_node( node.children[i], p_ctx );
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          element e;
+          std::tr1::int64_t value2 = 0;
+          try
+          {
+            value2 = get_i( rhs, p_ctx );
+          }
+          catch ( expr_error& )
+          {
+            error( node.children[i].value.begin().line(), _( "`%1%\' does not have a value" ), get_s( lhs, p_ctx ) );
+            throw;
+          }
+          e.i = ( value || value2 );
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return result;
+    }
+
+    //! _Ï®
+    bool logical_and_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0  1   2
+      // lhs && rhs ...
+      bool result = true;
+
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 2; i < n; i += 2 )
+        {
+          std::tr1::int64_t value = 0;
+          try
+          {
+            value = get_i( lhs, p_ctx );
+          }
+          catch ( expr_error& )
+          {
+            error( node.children[0].value.begin().line(), _( "`%1%\' does not have a value" ), get_s( lhs, p_ctx ) );
+            throw;
+          }
+          if ( !value )
+          {
+            break;
+          }
+          result = eval_node( node.children[i], p_ctx );
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          element e;
+          std::tr1::int64_t value2 = 0;
+          try
+          {
+            value2 = get_i( rhs, p_ctx );
+          }
+          catch ( expr_error& )
+          {
+            error( node.children[i].value.begin().line(), _( "`%1%\' does not have a value" ), get_s( lhs, p_ctx ) );
+            throw;
+          }
+          e.i = ( value && value2 );
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return result;
+    }
+
+    //! rbga®
+    bool or_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0 1   2
+      // lhs | rhs ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1; ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          element e;
+          e.i = ( get_i( lhs, p_ctx ) | get_i( rhs, p_ctx ) );
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! r¼I_a®
+    bool xor_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0 1   2
+      // lhs ^ rhs ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1; ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          element e;
+          e.i = ( get_i( lhs, p_ctx ) ^ get_i( rhs, p_ctx ) );
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! rbgÏ®
+    bool and_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0 1   2
+      // lhs & rhs ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1; ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          element e;
+          e.i = ( get_i( lhs, p_ctx ) & get_i( rhs, p_ctx ) );
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! ¿®i==A!=j
+    bool equality_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0  1   2
+      // lhs op rhs ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1; ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          std::string op( node.children[i].value.begin(), node.children[i].value.end() );
+          std::tr1::int64_t value;
+          if ( op == "==" )
+          {
+            value = ( get_i( lhs, p_ctx ) == get_i( rhs, p_ctx ) );
+          }
+          else
+          {
+            value = ( get_i( lhs, p_ctx ) != get_i( rhs, p_ctx ) );
+          }
+          element e;
+          e.i = value;
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! ÖW®isj
+    bool relational_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0  1   2
+      // lhs op rhs ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1; ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          std::string op( node.children[i].value.begin(), node.children[i].value.end() );
+          std::tr1::int64_t value;
+          if ( op == "<" )
+          {
+            value = ( get_i( lhs, p_ctx ) < get_i( rhs, p_ctx ) );
+          }
+          else if ( op == "<=" )
+          {
+            value = ( get_i( lhs, p_ctx ) <= get_i( rhs, p_ctx ) );
+          }
+          else if ( op == ">" )
+          {
+            value = ( get_i( lhs, p_ctx ) > get_i( rhs, p_ctx ) );
+          }
+          else
+          {
+            value = ( get_i( lhs, p_ctx ) >= get_i( rhs, p_ctx ) );
+          }
+          element e;
+          e.i = value;
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! Vtg®
+    bool shift_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0  1   2
+      // lhs op rhs ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1; ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          std::string op( node.children[i].value.begin(), node.children[i].value.end() );
+          std::tr1::int64_t value = get_i( lhs, p_ctx );
+          std::tr1::int64_t shift = get_i( rhs, p_ctx );
+          if ( shift < 0 )  // ÌlÅVtgµæ¤Æµ½
+          {
+            error( node.children[0].value.begin().line(), _( "shift with nagative value `%1%\'" ), shift );
+          }
+          if ( shift > 64 )
+          {
+            error( node.children[0].value.begin().line(), _( "shift with too large value `%1%\'" ), shift );
+          }
+          if ( op == "<<" )
+          {
+            if ( value < 0 )
+            { // ÌlÌVtgÍÅ«È¢
+              error( node.children[0].value.begin().line(), _( "negative value `%1%\' is shift" ), value );
+            }
+            else if ( shift != 0 && static_cast< std::tr1::int64_t >( static_cast< std::tr1::uint64_t >( 1 ) << ( 63 - shift ) ) <= value )
+            { // VtgÌÊªÉÈé
+              error( node.children[0].value.begin().line(), _( "shift with too large value `%1%\'" ), shift );
+            }
+            value = value << shift;
+          }
+          else
+          {
+            if ( value < 0 )  // ­§IÉZpVtg³¹é
+            {
+              value = static_cast< std::tr1::int64_t >( ( static_cast< std::tr1::uint64_t >( value ) >> shift ) | ( ~static_cast< std::tr1::uint64_t >( 0 ) << shift ) );
+            }
+            else
+            {
+              value = value >> shift;
+            }
+          }
+          element e;
+          e.i = value;
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! Á¸®
+    bool additive_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0  1   2
+      // lhs op rhs ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1; ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          std::string op( node.children[i].value.begin(), node.children[i].value.end() );
+          std::tr1::int64_t x = get_i( lhs, p_ctx );
+          std::tr1::int64_t y = get_i( rhs, p_ctx );
+          element e;
+          if ( op == "+" )
+          {
+            if ( ( y > 0 && ( std::numeric_limits< std::tr1::int64_t >::max() - y ) < x )
+              || ( y < 0 && ( std::numeric_limits< std::tr1::int64_t >::min() - y ) > x ) )
+            {
+              error( node.children[0].value.begin().line(), _( "overflow at `%1%\'" ), get_s( lhs, p_ctx ) + "+" + get_s( rhs, p_ctx ) );
+              // e.i ÉlÍZbg³êÈ¢
+            }
+            else
+            {
+              e.i = x + y;
+            }
+          }
+          else  // "-"
+          {
+            if ( ( y < 0 && ( std::numeric_limits< std::tr1::int64_t >::max() + y ) < x )
+              || ( y > 0 && ( std::numeric_limits< std::tr1::int64_t >::min() + y ) > x ) )
+            {
+              error( node.children[0].value.begin().line(), _( "overflow at `%1%\'" ), get_s( lhs, p_ctx ) + "-" + get_s( rhs, p_ctx ) );
+              // e.i ÉlÍZbg³êÈ¢
+            }
+            else
+            {
+              e.i = x - y;
+            }
+          }
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! æ®
+    bool multiplicative_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //   0  1   2
+      // lhs op rhs ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ¶ÓÌÝ
+        {
+          return true;
+        }
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1; ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          std::string op( node.children[i].value.begin(), node.children[i].value.end() );
+          std::tr1::int64_t x = get_i( lhs, p_ctx );
+          std::tr1::int64_t y = get_i( rhs, p_ctx );
+          element e;
+          if ( op == "*" )
+          {
+            if ( ( x == 0 ) || ( y == 0 ) )
+            {
+              e.i = 0;
+            }
+            else if ( ( ( x < 0 ) == ( y < 0 ) ) && ( std::numeric_limits< std::tr1::int64_t >::max() / y < x )
+                 || ( ( x < 0 ) != ( y < 0 ) ) && ( std::numeric_limits< std::tr1::int64_t >::min() / y > x ) )
+            {
+              error( node.children[0].value.begin().line(), _( "overflow at `%1%\'" ), get_s( lhs, p_ctx ) + "*" + get_s( rhs, p_ctx ) );
+              // e.i ÉlÍZbg³êÈ¢
+            }
+            else
+            {
+              e.i = x * y;
+            }
+          }
+          else
+          {
+            if ( y == 0 )
+            {
+              error( node.value.begin().line(), _( "devide by zero" ) );
+              // e.i ÉÍlªZbg³êÈ¢
+            }
+            else
+            {
+              std::tr1::int64_t value;
+              // {Í±±ÅêûÌIyhªÌêÌðs¤Kvª éB
+              // »ñÈÏÈnÍÀ¿IÉÈ¢ÌÅúu
+              if ( op == "/" )
+              {
+                value = ( x / y );
+              }
+              else  // "%"
+              {
+                value = ( x % y );
+              }
+              e.i = value;
+            }
+          }
+          lhs[0] = e;
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! P®iãu®APZq ê®j
+    bool unary_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //  0 1..n-2          n-1
+      // op ...... primary_expr
+      if ( eval_node( node.children[ node.children.size() - 1 ], p_ctx ) )
+      {
+        std::size_t const n = node.children.size();
+        if ( n == 1 )  // ê®ÌÝ
+        {
+          return true;
+        }
+        var_t expr( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( long i = static_cast< long >( n ) - 2, t = 0; i >= 0 && eval_node( node.children[i+1], p_ctx ); i-- )
+        {
+          std::string op( node.children[i].value.begin(), node.children[i].value.end() );
+          element e;
+          std::tr1::int64_t value = 0;
+          if ( op != "@" )
+          {
+            try
+            {
+              value = get_i( expr, p_ctx );
+            }
+            catch ( expr_error& )
+            {
+              error( node.children[0].value.begin().line(), _( "`%1%\' is undefined" ), get_s( expr, p_ctx ) );
+              throw;
+            }
+            if ( op == "+" )
+            {
+              e.i = +value;
+            }
+            else if ( op == "-" )
+            {
+              if ( value == std::numeric_limits< std::tr1::int64_t >::min() )
+              {
+                error( node.children[0].value.begin().line(), _( "overflow at `%1%\'" ), "-" + get_s( expr, p_ctx ) );
+                // e.i ÉlÍZbg³êÈ¢
+              }
+              else
+              {
+                e.i = -value;
+              }
+            }
+            else if ( op == "~" )
+            {
+              e.i = ~value;
+            }
+            else if ( op == "!" )
+            {
+              e.i = !value;
+            }
+            value = *e.i;
+          }
+          else  // op == "@" il®« ¨ ¶ñ®«j
+          {
+            if ( expr.front().i )
+            {
+              e.s = boost::lexical_cast< std::string >( *expr.front().i );
+            }
+            else
+            {
+              e.s = expr.front().v;
+            }
+          }
+          expr[ 0 ] = e;  // ZÊðÝÏ·é
+          if ( i == t )
+          {
+            break;
+          }
+        }
+        p_ctx->stack.push( expr );
+      }
+      return true;
+    }
+
+    //! ãu®iÖÄÑoµAê®j
+    bool postfix_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //            0 1    2 3 4..2+2*n-1 2+2*n 2+2*n+1 
+      //   identifier ( arg0 , ..........  argn       )
+      // primary_expr
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        if ( node.children.size() > 1 )   // ÖÌÄÑoµ
+        {
+          var_t ident( p_ctx->stack.top() ); p_ctx->stack.pop();
+          std::string func_name( get_s( ident, p_ctx ) );
+          std::map< std::string, macro_processor::func_t >::const_iterator iter( p_ctx->func_map.find( func_name ) );
+          if ( iter == p_ctx->func_map.end() )  // »ñÈÖÍÈ¢
+          {
+            error( node.children[0].value.begin().line(), _( "function `%1%\' is undefined" ), func_name );
+            p_ctx->stack.push( var_t() );
+          }
+          else  // ÖðÄÑo·
+          {
+            std::vector< var_t > arg_list;
+            for ( std::size_t i = 0, n = node.children.size() - 1; 2 + 2*i < n; i++ )
+            {
+              if ( eval_node( node.children[2 + 2*i], p_ctx ) )
+              {
+                var_t arg( p_ctx->stack.top() ); p_ctx->stack.pop();
+                arg_list.push_back( arg );
+              }
+            }
+            var_t result;
+            if ( iter->second.f != 0 )  // gÝÝÖ
+            {
+              result = ( *iter->second.f )( node.children[0].value.begin().line(), arg_list, p_ctx );
+            }
+            else if ( iter->second.node != 0 )  // [U[è`Ö
+            {
+              // ARGC
+              {
+                element e;
+                e.i = static_cast< std::tr1::int64_t >( arg_list.size() + 1 );
+                p_ctx->var_map[ "ARGC" ] = var_t( 1, e );
+              }
+
+              // ARGV
+              {
+                element e;
+                e.s = func_name;
+                p_ctx->var_map[ "ARGV[0]" ] = var_t( 1, e );
+
+                std::size_t n = arg_list.size() + 1;
+                for ( std::size_t i = 1; i < n; i++ )
+                {
+                  std::string argv_i = boost::str( boost::format( "ARGV[%d]" ) % i );
+                  p_ctx->var_map[ argv_i ] = arg_list[ i - 1 ];
+                }
+
+                std::string argv_n = boost::str( boost::format( "ARGV[%d]" ) % n );
+                p_ctx->var_map[ argv_n ] = var_t();
+              }
+
+              tree_node_t const* func_body_node = reinterpret_cast< tree_node_t const* >( iter->second.node );
+              if ( !eval_node( *func_body_node, p_ctx ) )
+              {
+                // ÄÑoµ¸s
+                p_ctx->stack.push( result );
+                return false;
+              }
+
+              result = p_ctx->var_map[ "RESULT" ];
+            }
+            p_ctx->stack.push( result );
+          }
+        }
+      }
+      return true;
+    }
+
+    //! ê®i¶Ól®A(®)j
+    bool primary_expr( tree_node_t const& node, context* p_ctx )
+    {
+      bool result = true;
+
+      if ( node.children.size() == 1 )
+      {
+        result = eval_node( node.children[0], p_ctx );
+        if ( node.children[0].value.id() == parser::id_lvalue_expr )
+        {
+          var_t ident( p_ctx->stack.top() ); p_ctx->stack.pop();
+          std::string name( get_s( ident, p_ctx ) );
+          var_t value( p_ctx->var_map[ name ] );
+          p_ctx->stack.push( value );
+        }
+      }
+      else
+      {
+        // 0          1 2
+        // ( expression )
+        result = eval_node( node.children[1], p_ctx );
+      }
+      return result;
+    }
+
+    //! ¶Ól®iÏAzñÏj
+    bool lvalue_expr( tree_node_t const& node, context* p_ctx )
+    {
+      //          0 1          2 3
+      // identifier
+      // identifier [ expression ]
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        if ( ( node.children.size() > 1 ) && eval_node( node.children[2], p_ctx ) )
+        {
+          var_t expr( p_ctx->stack.top() ); p_ctx->stack.pop();
+          var_t ident( p_ctx->stack.top() ); p_ctx->stack.pop();
+          element e;
+          std::string subscript;
+          try
+          {
+            std::tr1::int64_t i = get_i( expr, p_ctx );
+            subscript = boost::lexical_cast< std::string >( i );
+          }
+          catch ( expr_error& )
+          {
+            subscript = get_s( expr, p_ctx );
+            error( node.children[0].value.begin().line(), _( "`%1%\' does not have a value" ), subscript );
+            throw;
+          }
+          e.s = ( boost::format( "%s[%s]" ) % get_s( ident, p_ctx ) % subscript ).str();
+          p_ctx->stack.push( var_t( 1, e ) );
+        }
+      }
+      return true;
+    }
+
+    //! ¯Êq
+    bool identifier( tree_node_t const& node, context* p_ctx )
+    {
+      element e;
+      std::string ident( node.children[0].value.begin(), node.children[0].value.end() );
+      std::string::size_type n = ident.find_first_not_of( " \t\r\n" );
+      e.s = ident.c_str() + n;
+      p_ctx->stack.push( var_t( 1, e ) );
+      return true;
+    }
+
+    //! ®è
+    bool constant( tree_node_t const& node, context* p_ctx )
+    {
+      element e;
+      e.s.assign( node.children[0].value.begin(), node.children[0].value.end() );
+      std::istringstream iss( e.s );
+      iss.unsetf( std::ios_base::basefield );
+      std::tr1::int64_t value;
+      iss >> value;
+      if ( iss.bad() )
+      {
+        error( node.children[0].value.begin().line(), _( "overflow at `%1%\'" ), e.s );
+      }
+      e.i = value;
+      p_ctx->stack.push( var_t( 1, e ) );
+      return true;
+    }
+
+    //! ¶ñ
+    bool string_literal( tree_node_t const& node, context* p_ctx )
+    {
+      // 0 1..n-2 n-1
+      // " ......   "
+      element e;
+      // ±±Å\¶G[áOÉÈé±ÆÍ è¾È¢Bi\¶ðÍãÈÌÅj
+      e.s = expand_quote( std::string( node.children[0].value.begin(), node.children[0].value.end() ) );
+      p_ctx->stack.push( var_t( 1, e ) );
+      return true;
+    }
+
+    //! t«Xg
+    bool ordered_list( tree_node_t const& node, context* p_ctx )
+    {
+      // 0                1 2     n-1
+      // { ordered_sequence ; ...   }
+      // {     ordered_item ; ...   }
+      if ( node.children.size() < 3 )
+      {
+        p_ctx->stack.push( var_t() );
+      }
+      else if ( eval_node( node.children[1], p_ctx ) )
+      {
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1, n = node.children.size(); ( i+2 < n ) && eval_node( node.children[i+2], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          std::copy( rhs.begin(), rhs.end(), std::back_inserter( lhs ) );
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! t«Xgi·ñj
+    bool ordered_sequence( tree_node_t const& node, context* p_ctx )
+    {
+      //   0 1   2 3   4 5   6
+      // int , int , ... , int
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        var_t first( p_ctx->stack.top() ); p_ctx->stack.pop();
+        if ( eval_node( node.children[2], p_ctx ) )
+        {
+          var_t second( p_ctx->stack.top() ); p_ctx->stack.pop();
+          if ( eval_node( node.children[6], p_ctx ) )
+          {
+            var_t last( p_ctx->stack.top() ); p_ctx->stack.pop();
+            std::tr1::int64_t a0 = get_i( first, p_ctx );
+            std::tr1::int64_t a1 = get_i( second, p_ctx );
+            std::tr1::int64_t an = get_i( last, p_ctx );
+            std::tr1::int64_t d = a1 - a0;
+            if ( ( an - a0 ) % d != 0 )
+            {
+              error( node.children[0].value.begin().line(), _( "illegal arithmetic sequence" ) );
+            }
+            else
+            {
+              for ( std::tr1::int64_t i = a1, t = an + d; i != t; i += d )
+              {
+                element e;
+                e.i = i;
+                first.push_back( e );
+              }
+              first[1].s = second[0].s;
+              first.back().s = last[0].s;
+            }
+            p_ctx->stack.push( first );
+          }
+        }
+      }
+      return true;
+    }
+
+    //! t«XgiñLj
+    bool ordered_item( tree_node_t const& node, context* p_ctx )
+    {
+      //   0 1   2
+      // int , int ...
+      if ( eval_node( node.children[0], p_ctx ) )
+      {
+        var_t lhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+        for ( std::size_t i = 1, n = node.children.size(); ( i < n ) && eval_node( node.children[i+1], p_ctx ); i += 2 )
+        {
+          var_t rhs( p_ctx->stack.top() ); p_ctx->stack.pop();
+          lhs.push_back( rhs[0] );
+        }
+        p_ctx->stack.push( lhs );
+      }
+      return true;
+    }
+
+    //! gbvx
+    bool top( tree_node_t const& node, context* p_ctx )
+    {
+      bool result = true;
+
+      for ( std::size_t i = 0, n = node.children.size(); i < n; i++ )
+      {
+        for ( text::const_iterator iter( node.children[i].value.begin() ), last( node.children[i].value.end() );
+              iter != last;
+              ++iter )
+        {
+          char c = *iter;
+          if ( !std::isspace( static_cast< unsigned char >( c ) ) )
+          {
+            break;
+          }
+          if ( c != '\n' )
+          {
+            p_ctx->target_file << c;
+          }
+        }
+        result &= eval_node( node.children[i], p_ctx );
+      }
+      return result;
+    }
+
+    //! $FUNCTION½ß
+    bool function_( tree_node_t const& node, context* p_ctx )
+    {
+      bool result = true;
+
+      if ( node.children.empty() )
+      {
+        fatal( node.value.begin().line(), "no body of %1%", "'FUNCTION'" );
+      }
+
+      if ( p_ctx->in_function )
+      {
+        fatal( node.value.begin().line(), "function cannot be nested" );
+      }
+      p_ctx->in_function = true;
+
+      //         0          1 2   3    4
+      // $FUNCTION identifier $ top $END$
+      if ( eval_node( node.children[1], p_ctx ) )   // identifier
+      {
+        var_t ident( p_ctx->stack.top() ); p_ctx->stack.pop();
+        macro_processor::func_t func;
+        func.name = get_s( ident, p_ctx );
+        func.node = &node.children[3];
+        func.f = 0; // gÝÝÖÅÍÈ¢ÌÅ
+        p_ctx->func_map[ func.name ] = func;
+      }
+      else
+      {
+        result = false;
+      }
+      p_ctx->in_function = false;
+      return result;
+    }
+
+    //! $IF½ß
+    bool if_( tree_node_t const& node, context* p_ctx )
+    {
+      bool result = true;
+
+      if ( node.children.empty() )
+      {
+        fatal( node.value.begin().line(), "no body of %1%", "'IF' or 'ELSE'" );
+      }
+
+      //   0          1 2   3      4   5     6
+      // $IF expression $ top  $END$
+      // $IF expression $ top $ELSE$ top $END$
+      if ( eval_node( node.children[1], p_ctx ) )   // expression
+      {
+        var_t expr( p_ctx->stack.top() ); p_ctx->stack.pop();
+        bool cond = false;
+        try
+        {
+          cond = !!get_i( expr, p_ctx );
+        }
+        catch ( expr_error& )
+        {
+          error( node.children[0].value.begin().line(), _( "`%1%\' does not have a value" ), get_s( expr, p_ctx ) );
+          throw;
+        }
+        if ( cond )           // $IF expr$
+        {
+          result &= eval_node( node.children[3], p_ctx );   // top
+        }
+        else if ( node.children.size() == 7 ) // $ELSE$
+        {
+          result &= eval_node( node.children[5], p_ctx );   // top
+        }
+      }
+      return result;
+    }
+
+    //! FOREACH½ß
+    bool foreach_( tree_node_t const& node, context* p_ctx )
+    {
+      bool result = true;
+
+      if ( node.children.empty() )
+      {
+        fatal( node.value.begin().line(), "no body of %1%", "'FOREACH'" );
+      }
+
+      //        0          1          2 3   4     5
+      // $FOREACH identifier order_list $ top $END$
+      if ( eval_node( node.children[1], p_ctx ) )   // identifier
+      {
+        var_t ident( p_ctx->stack.top() ); p_ctx->stack.pop();
+        if ( eval_node( node.children[2], p_ctx ) ) // order_list
+        {
+          var_t order_list( p_ctx->stack.top() ); p_ctx->stack.pop();
+          if ( !order_list.empty() && order_list[0].i )
+          {
+            for ( var_t::const_iterator iter( order_list.begin() ), last( order_list.end() ); iter != last; ++iter )
+            {
+              p_ctx->var_map[ get_s( ident, p_ctx ) ] = var_t( 1, *iter );
+              result &= eval_node( node.children[4], p_ctx ); // top
+            }
+          }
+        }
+      }
+      return result;
+    }
+
+    //! $JOINEACH½ß
+    bool joineach_( tree_node_t const& node, context* p_ctx )
+    {
+      bool result = true;
+
+      if ( node.children.empty() )
+      {
+        fatal( node.value.begin().line(), "no body of %1%", "'JOINEACH'" );
+      }
+
+      //         0          1          2         3 4   5     6
+      // $JOINEACH identifier order_list delimitor $ top $END$
+      if ( eval_node( node.children[1], p_ctx ) )       // identifier
+      {
+        var_t ident( p_ctx->stack.top() ); p_ctx->stack.pop();
+        if ( eval_node( node.children[2], p_ctx ) )     // order_list
+        {
+          var_t order_list( p_ctx->stack.top() ); p_ctx->stack.pop();
+          if ( !order_list.empty() && order_list[0].i )
+          {
+            if ( eval_node( node.children[3], p_ctx ) ) // delimitor
+            {
+              var_t delimitor( p_ctx->stack.top() ); p_ctx->stack.pop();
+              for ( var_t::const_iterator iter( order_list.begin() ), last( order_list.end() ); iter != last; ++iter )
+              {
+                p_ctx->var_map[ get_s( ident, p_ctx ) ] = var_t( 1, *iter );
+                result &= eval_node( node.children[5], p_ctx ); // top
+                if ( boost::next( iter ) != last )
+                {
+                  p_ctx->target_file << get_s( delimitor, p_ctx );
+                }
+              }
+            }
+          }
+        }
+      }
+      return result;
+    }
+
+    //! $ERROR½ß
+    bool error_( tree_node_t const& node, context* p_ctx )
+    { 
+      //         0    1     2   3     4
+      //   $ERROR$  top $END$
+      // $WARNING$  top $END$
+      //    $ERROR expr     $ top $END$
+      //  $WARNING expr     $ top $END$
+
+      if ( node.children.empty() )
+      {
+        fatal( node.value.begin().line(), "no body of %1%", "'ERROR' or 'WARNING'" );
+      }
+
+      output_file of = p_ctx->target_file;
+      p_ctx->target_file = output_file( "stderr", std::ios_base::out ); // oÍæðêIÉWG[oÍÉØèÖ¦éB
+
+      bool is_error = ( static_cast< parser::rule_id_t >( node.value.id().to_long() ) == parser::id_error_ );
+
+      p_ctx->target_file << get_program_name() << ':';
+
+      bool has_expr = ( node.children.size() > 3 );
+
+      if ( has_expr && eval_node( node.children[1], p_ctx ) ) // expr
+      {
+        var_t expr( p_ctx->stack.top() ); p_ctx->stack.pop();
+        if ( !expr.empty() )
+        {
+          if ( !expr.front().s.empty() )
+          {
+            p_ctx->target_file << expr.front().s << ':';
+          }
+          if ( expr.front().i )
+          {
+            p_ctx->target_file << expr.front().i.get() << ':';
+          }
+        }
+      }
+
+      p_ctx->target_file << ( is_error ? " error: " : " warning: " );
+
+      bool result = eval_node( node.children[has_expr ? 3 : 1], p_ctx ); // top
+      p_ctx->target_file << '\n';
+      p_ctx->target_file = of;
+
+      if ( is_error )
+      {
+        increment_error_count();  // errorÖðgíÈ¢ÌÅA¾¦IÉG[JEgðì·éB
+      }
+      return result;
+    }
+
+    //! $WARNING½ß
+    bool warning_( tree_node_t const& node, context* p_ctx )
+    {
+      return error_( node, p_ctx );
+    }
+
+    //! $FILE½ß
+    bool file_( tree_node_t const& node, context* p_ctx )
+    {
+      //     0              1 2
+      // $FILE string-literal $
+      if ( eval_node( node.children[1], p_ctx ) ) // string-literal
+      {
+        var_t filename( p_ctx->stack.top() ); p_ctx->stack.pop();
+        p_ctx->target_file << '\n';
+        p_ctx->target_file = output_file( get_s( filename, p_ctx ), std::ios_base::out );
+      }
+      return true;
+    }
+
+    //! ®
+    bool expr_( tree_node_t const& node, context* p_ctx )
+    {
+      // 0          1 2
+      // $ expression $
+      if ( eval_node( node.children[1], p_ctx ) ) // expression
+      {
+        if ( node.children[1].value.id().to_long() == parser::id_expression )
+        {
+          var_t expr( p_ctx->stack.top() ); p_ctx->stack.pop();
+          p_ctx->target_file << get_s( expr, p_ctx );
+        }
+      }
+      return true;
+    }
+
+    // }N½ßÈO
+    bool plain( tree_node_t const& node, context* p_ctx )
+    {
+      std::string buf;
+      buf.reserve( node.children[0].value.end() - node.children[0].value.begin() );
+      for ( text::const_iterator iter( node.children[0].value.begin() ), last( node.children[0].value.end() ); iter != last; ++iter )
+      {
+        if ( *iter == '$' )
+        {
+          ++iter;
+        }
+        switch ( char c = *iter )
+        {
+        case '\r':
+        case '\n':
+          break;
+        default:
+          buf.push_back( c );
+          break;
+        }
+      }
+      p_ctx->target_file << buf;
+      return true;
+    }
+
+    // \¶ØÌem[hÌ]¿
+    bool eval_node( tree_node_t const& node, context* p_ctx )
+    {
+      bool result = true;
+      if ( p_ctx != 0 )
+      {
+        p_ctx->line = node.value.begin().line();
+      }
+
+#if defined( _MSC_VER ) && DEBUG_TRACE
+      ::OutputDebugString( ( boost::format( "%s:%d:%s\n" )
+                        % node.children[0].value.begin().line().file
+                        % node.children[0].value.begin().line().line
+                        % std::string( node.children[0].value.begin(), node.children[0].value.end() )
+                        ).str().c_str() );
+#endif
+
+      switch ( parser::rule_id_t id = static_cast< parser::rule_id_t >( node.value.id().to_long() ) )
+      {
+      case parser::id_expression:
+        result = eval_node( node.children[0], p_ctx );
+        break;
+      case parser::id_assignment_expr:
+        result = assignment_expr( node, p_ctx );
+        break;
+      case parser::id_logical_or_expr:
+        result = logical_or_expr( node, p_ctx );
+        break;
+      case parser::id_logical_and_expr:
+        result = logical_and_expr( node, p_ctx );
+        break;
+      case parser::id_or_expr:
+        result = or_expr( node, p_ctx );
+        break;
+      case parser::id_xor_expr:
+        result = xor_expr( node, p_ctx );
+        break;
+      case parser::id_and_expr:
+        result = and_expr( node, p_ctx );
+        break;
+      case parser::id_equality_expr:
+        result = equality_expr( node, p_ctx );
+        break;
+      case parser::id_relational_expr:
+        result = relational_expr( node, p_ctx );
+        break;
+      case parser::id_shift_expr:
+        result = shift_expr( node, p_ctx );
+        break;
+      case parser::id_additive_expr:
+        result = additive_expr( node, p_ctx );
+        break;
+      case parser::id_multiplicative_expr:
+        result = multiplicative_expr( node, p_ctx );
+        break;
+      case parser::id_unary_expr:
+        result = unary_expr( node, p_ctx );
+        break;
+      case parser::id_postfix_expr:
+        result = postfix_expr( node, p_ctx );
+        break;
+      case parser::id_primary_expr:
+        result = primary_expr( node, p_ctx );
+        break;
+      case parser::id_lvalue_expr:
+        result = lvalue_expr( node, p_ctx );
+        break;
+      case parser::id_identifier:
+        result = identifier( node, p_ctx );
+        break;
+      case parser::id_constant:
+        result = constant( node, p_ctx );
+        break;
+      case parser::id_string_literal:
+        result = string_literal( node, p_ctx );
+        break;
+      case parser::id_ordered_list:
+        result = ordered_list( node, p_ctx );
+        break;
+      case parser::id_ordered_sequence:
+        result = ordered_sequence( node, p_ctx );
+        break;
+      case parser::id_ordered_item:
+        result = ordered_item( node, p_ctx );
+        break;
+      case parser::id_root:
+        result = eval_node( node.children[0], p_ctx );
+        break;
+      case parser::id_top:
+        result = top( node, p_ctx );
+        break;
+      case parser::id_function_:
+        result = function_( node, p_ctx );
+        break;
+      case parser::id_if_:
+        result = if_( node, p_ctx );
+        break;
+      case parser::id_foreach_:
+        result = foreach_( node, p_ctx );
+        break;
+      case parser::id_joineach_:
+        result = joineach_( node, p_ctx );
+        break;
+      case parser::id_error_:
+        result = error_( node, p_ctx );
+        break;
+      case parser::id_warning_:
+        result = warning_( node, p_ctx );
+        break;
+      case parser::id_file_:
+        result = file_( node, p_ctx );
+        break;
+      case parser::id_expr_:
+        result = expr_( node, p_ctx );
+        break;
+      case parser::id_plain:
+        result = plain( node, p_ctx );
+        break;
+      default:
+        result = false;
+        break;
+      }
+      return result;
+    }
+
+    bool eval_text( text::const_iterator first, text::const_iterator last, context* p_ctx )
+    {
+      using namespace boost::spirit;
+      typedef text::const_iterator iterator_t;
+      tree_parse_info< iterator_t, node_iter_data_factory<> > info;
+      info = pt_parse( first, last, parser(), space_p, node_iter_data_factory<>() );
+      if ( info.full && !info.trees.empty() )
+      {
+        bool result;
+        if ( info.length <= 0 )
+        {
+          result = true;
+        }
+        else
+        {
+          result = eval_node( info.trees[0], p_ctx );
+        }
+        return result;
+      }
+      else
+      {
+        fatal( info.stop.line(), _( "syntax error" ) );
+      }
+      return false;
+    }
+
+  }
+
+  std::tr1::int64_t macro_processor::to_integer( var_t const& var, context const* p_ctx )
+  {
+    return get_i( var, p_ctx );
+  }
+
+  std::string macro_processor::to_string( var_t const& var, context const* p_ctx )
+  {
+    return get_s( var, p_ctx );
+  }
+
+  macro_processor::macro_processor( hook_t hook_on_assign )
+    : p_ctx_( new context( hook_on_assign ) )
+  {
+  }
+
+  macro_processor::macro_processor( macro_processor const& other )
+    : p_ctx_( new context( *other.p_ctx_ ) )
+  {
+  }
+
+  macro_processor::macro_processor( text const& in, hook_t hook_on_assign )
+    : p_ctx_( new context( hook_on_assign ) )
+  {
+    evaluate( in );
+  }
+
+  macro_processor::~macro_processor()
+  {
+    delete p_ctx_;
+    p_ctx_ = 0;
+  }
+
+  macro_processor& macro_processor::operator=( macro_processor const& other )
+  {
+    macro_processor t( *this );
+    swap( t );
+    return *this;
+  }
+
+  void macro_processor::swap( macro_processor& other )
+  {
+    std::swap( p_ctx_, other.p_ctx_ );
+  }
+
+  void macro_processor::evaluate( text const& in )
+  {
+    try
+    {
+      for ( func_t const* p_bf = builtin_function_table; !p_bf->name.empty(); p_bf++ )
+      {
+        p_ctx_->func_map[ p_bf->name ] = *p_bf;
+      }
+      if ( !eval_text( in.begin(), in.end(), p_ctx_ ) )
+      {
+        fatal( _( "macro processing error" ) );
+      }
+    }
+    catch ( expr_error& )
+    {
+      fatal( _( "macro processing error" ) );
+    }
+  }
+
+  void macro_processor::set_var( std::string const& name, var_t const& value )
+  {
+#if defined( _MSC_VER ) && /* DEBUG_TRACE */ 1
+    std::string s( "$" + name + " = " + get_s( value, p_ctx_ ) + "$" );
+    if ( !value.empty() && value[0].i )
+    {
+      s += "(" + boost::lexical_cast< std::string >( get_i( value, p_ctx_ ) ) + ")";
+    }
+    s += "\n";
+    ::OutputDebugString( s.c_str() );
+#endif
+    p_ctx_->var_map[ name ] = value;
+  }
+
+  void macro_processor::set_var( std::string const& name, long name2, var_t const& value )
+  {
+    set_var( ( boost::format( "%s[%d]" ) % name % name2 ).str(), value );
+  }
+
+  macro_processor::var_t const& macro_processor::get_var( std::string const& name ) const
+  {
+    return p_ctx_->var_map[ name ];
+  }
+
+  macro_processor::var_t const& macro_processor::get_var( std::string const& name, long name2 ) const
+  {
+    return get_var( ( boost::format( "%s[%d]" ) % name % name2 ).str() );
+  }
+
+  /*!
+    *  \brief  RgÌ
+    *  \param[in]  first   ÎÛV[PXÌæªÊu  
+    *  \param[in]  last    ÎÛV[PXÌI[ÊuÌ
+    *  \param[out] result  ÊÌi[æ
+    *  \return     ®¹ãÌ result Ìl
+    *
+    *  u$ + óÞ¶vÅnÜèAüsÅIíéRgðµÜ·B
+    */
+  void macro_processor::remove_comment( text const& in, text& out )
+  {
+    text::const_iterator first( in.begin() ), last( in.end() );
+    std::back_insert_iterator< text > result( std::back_inserter( out ) );
+    out.set_line( first.line().file, first.line().line );
+
+    for ( text::const_iterator iter; ( iter = std::find( first, last, '\n' ) ) != last ; first = iter + 1 )
+    {
+      std::string buf( first, iter );
+      if ( ( ( buf[0] == '$' ) && ( buf.size() >= 2 ) && std::isspace( static_cast< unsigned char >( buf[1] ) ) ) )
+      {
+        *result = '\n'; 
+      }
+      else
+      {
+        // RgsÈOÍsªÌóÞð·éB
+        first = std::find_if( first, iter, std::not1( std::ptr_fun< char, bool >( &toppers::isspace ) ) );
+        result = std::copy( first, iter + 1, result );
+      }
+    }
+  }
+
+  void macro_processor::expand_include( text const& in, text& out )
+  {
+    typedef text::container::const_iterator const_row_iterator;
+    typedef std::string::size_type size_type;
+    size_type const npos = std::string::npos;
+std::string debug_str;
+
+    if ( in.empty() ) // óÌt@CªüÍ³ê½êÌÎô
+    {
+      return;
+    }
+
+    const_row_iterator first( in.begin().get_row() ), last( in.end().get_row() );
+
+    out.set_line( first->line.file, first->line.line );
+    for ( const_row_iterator iter( first ); iter != last; ++iter )
+    {
+      std::string const& buf = iter->buf;
+
+      for ( size_type i = 0, n = buf.size(); i != n; ++i )
+      {
+        using namespace boost::spirit;
+        char c = buf[i];
+        std::string headername;
+        text::const_iterator iter2( iter, i );
+        if ( iter2 == in.end() )
+        {
+          break;
+        }
+        parse_info< text::const_iterator > info
+          = parse( iter2, in.end(),
+                    ( ch_p( '$' ) >> str_p( "INCLUDE" ) >> *space_p
+                        >> '\"' >> ( +( anychar_p - '\"' ) )[ assign( headername ) ] >> '\"'
+                      >> '$' ) );
+        if ( info.hit )
+        {
+          std::vector< std::string > include_paths = get_global< std::vector< std::string > >( "include-path" );
+          std::string hname = search_include_file( include_paths.begin(), include_paths.end(), headername );
+          if ( hname.empty() )
+          {
+            fatal( iter->line, _( "cannot open file `%1%\'" ), headername );
+          }
+          else
+          {
+            text t;
+            t.set_line( hname, 1 );
+            std::ifstream ifs( hname.c_str() );
+            t.append( ifs );
+
+            preprocess( t, out );
+            iter = info.stop.get_row();
+            i = info.stop.get_col() - 1;
+            out.set_line( iter->line.file, iter->line.line );
+          }
+        }
+        else
+        {
+          out.push_back( c );
+          debug_str.push_back( c );
+          if ( c == '\n' )
+          {
+//            ::OutputDebugString( ( out.get_line().file + ":" + boost::lexical_cast< std::string >( out.get_line().line ) + ":" ).c_str() );
+//            ::OutputDebugString( debug_str.c_str() );
+            debug_str.clear();
+          }
+        }
+      }
+    }
+  }
+
+  void macro_processor::preprocess( text const& in, text& out )
+  {
+    if ( in.empty() )
+    {
+      return;
+    }
+    text temp;
+    macro_processor::remove_comment( in, temp );
+    expand_include( temp, out );
+  }
+
+  void macro_processor::add_builtin_function( func_t const& f )
+  {
+    p_ctx_->func_map[ f.name ] = f;
+  }
+
+  macro_processor::var_t macro_processor::call_user_function( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
+  {
+    if ( arg_list.empty() )
+    {
+      return var_t();
+    }
+
+    func_t func = p_ctx->func_map[ get_s( arg_list.front(), p_ctx ) ]; 
+    if ( func.name.empty() )
+    {
+      fatal( line, "function is not defined" );
+      return var_t();
+    }
+
+    // ARGC
+    {
+      element e;
+      e.i = static_cast< std::tr1::int64_t >( arg_list.size() );
+      p_ctx->var_map[ "ARGC" ] =var_t( 1, e );
+    }
+
+    // ARGV
+    {
+      std::size_t n = arg_list.size();
+      for ( std::size_t i = 0; i < n; i++ )
+      {
+        std::string argv_i = boost::str( boost::format( "ARGV[%d]" ) % i );
+        p_ctx->var_map[ argv_i ] = arg_list[ i ];
+      }
+
+      std::string argv_n = boost::str( boost::format( "ARGV[%d]" ) % n );
+      p_ctx->var_map[ argv_n ] = var_t();
+    }
+
+    tree_node_t const* func_body_node = reinterpret_cast< tree_node_t const* >( func.node );
+    if ( !eval_node( *func_body_node, p_ctx ) )
+    {
+      return var_t();
+    }
+
+    return p_ctx->var_map[ "RESULT" ];
+  }
+
+}
Index: /cfg_oil/trunk/toppers/macro_processor.hpp
===================================================================
--- /cfg_oil/trunk/toppers/macro_processor.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/macro_processor.hpp	(revision 8)
@@ -0,0 +1,160 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/macro_processor.hpp
+ *  \brief  }NÌ½ßÌé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  class macro_processor;
+ *  \endcode
+ */
+#ifndef TOPPERS_MACRO_PROCESSOR_HPP_
+#define TOPPERS_MACRO_PROCESSOR_HPP_
+
+#include <string>
+#include <vector>
+#include <stack>
+#include <map>
+#include "toppers/workaround.hpp"
+#include "toppers/output_file.hpp"
+#include "toppers/text.hpp"
+
+namespace toppers
+{
+
+  class macro_processor
+  {
+  public:
+    struct context;
+
+    /*!
+     *  \struct element macro_processor.hpp "toppers/macro_processor.hpp"
+     *  \brief  }NÅgp·éÏÌl
+     *
+     *  ³mÉÍAÏÌlÍíÉt«XgÆµÄµíêÜ·Belement Ít«XgÌ 1 vfð\µÜ·B
+     */
+    struct element
+    {
+      boost::optional< std::tr1::int64_t > i;
+      std::string v;
+      std::string s;
+    };
+    /*!
+     *  \brief  }NÅgp·éÏð\»·é^
+     */
+    typedef std::vector< element > var_t;
+
+    /*!
+     *  \struct func_t macro_processor.hpp "toppers/macro_processor.hpp"
+     *  \brief  }NàÅµ¤Öð\»·é^
+     *  \note   ³XPÈ\¢ÌÅ Á½½ßAÝ·«Ì½ßAW¬ÌÆÁ«ðÛ³¹Ä¢éB
+     *  \attention  node Ìú»YêÉvÓ
+     */
+    struct func_t
+    {
+      std::string name;   //!< Ö¼
+      var_t ( * f )( text_line const& line, std::vector< var_t > const&, context* );  //!< àe
+      void const* node;
+    };
+
+    typedef void ( * hook_t )( text_line const&, std::string const&, var_t const&, var_t const&, context* );
+
+    struct context
+    {
+      std::stack< var_t > stack;
+      std::map< std::string, var_t > var_map;
+      std::map< std::string, func_t > func_map;
+      bool in_function;
+      output_file target_file;
+      hook_t hook_on_assign;
+      text_line line;
+      explicit context( hook_t hoa = 0 ) : hook_on_assign( hoa ), in_function( false ) {}
+    };
+
+    explicit macro_processor( hook_t hook_on_assign = 0 );
+    macro_processor( macro_processor const& other );
+    explicit macro_processor( text const& in, hook_t hook_on_assign = 0 );
+    ~macro_processor();
+    macro_processor& operator=( macro_processor const& other );
+    void swap( macro_processor& other );
+    void evaluate( text const& in );
+    void set_var( std::string const& name, var_t const& value );
+    void set_var( std::string const& name, long name2, var_t const& value );
+    var_t const& get_var( std::string const& name ) const;
+    var_t const& get_var( std::string const& name, long name2 ) const;
+    void add_builtin_function( func_t const& f );
+
+    static void remove_comment( text const& in, text& out );
+    static void expand_include( text const& in, text& out );
+    static void preprocess( text const& in, text& out );
+    static std::tr1::int64_t to_integer( var_t const& var, context const* p_ctx );
+    static std::string to_string( var_t const& var, context const* p_ctx );
+    static bool check_arity( text_line const& line, std::size_t arity, std::size_t valid, char const* function_name );
+    static var_t call_user_function( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx );
+  private:
+    context* p_ctx_;
+    static func_t const builtin_function_table[];
+  };
+
+  inline bool operator == ( macro_processor::element const& lhs, macro_processor::element const& rhs )
+  {
+    return lhs.i == rhs.i;
+  }
+
+  inline bool operator < ( macro_processor::element const& lhs, macro_processor::element const& rhs )
+  {
+    return lhs.i < rhs.i;
+  }
+
+  struct element_eq
+  {
+    explicit element_eq( std::tr1::int64_t value ) : value_( value ) {}
+    bool operator()( toppers::macro_processor::element const& e ) const
+    {
+      return e.i && ( e.i.get() == value_ );
+    }
+    std::tr1::int64_t value_;
+  };
+
+}
+
+#endif  // ! TOPPERS_MACRO_PROCESSOR_HPP_
Index: /cfg_oil/trunk/toppers/mbchar_parser.cpp
===================================================================
--- /cfg_oil/trunk/toppers/mbchar_parser.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/mbchar_parser.cpp	(revision 8)
@@ -0,0 +1,62 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/mbchar_parser.cpp
+ */
+#include "toppers/c_parser.hpp"
+
+namespace toppers
+{
+
+  //! ASCII¶p[T[
+  boost::spirit::functor_parser< detail::mbchar_parse_functor< ascii > > const ascii_p;
+
+  //! ShiftJIS¶p[T[
+  boost::spirit::functor_parser< detail::mbchar_parse_functor< shift_jis > > const shift_jis_p;
+
+  //! EUC-JP¶p[T[
+  boost::spirit::functor_parser< detail::mbchar_parse_functor< euc_jp > > const euc_jp_p;
+
+  //! UTF-8¶p[T[
+  boost::spirit::functor_parser< detail::mbchar_parse_functor< utf8 > > const utf8_p;
+
+}
Index: /cfg_oil/trunk/toppers/misc.hpp
===================================================================
--- /cfg_oil/trunk/toppers/misc.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/misc.hpp	(revision 8)
@@ -0,0 +1,289 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/misc.hpp
+ *  \brief  G½ÈCuÌ½ßÌé¾è`
+ */
+#ifndef TOPPERS_MISC_HPP_
+#define TOPPERS_MISC_HPP_
+
+#include <stdexcept>
+#include <locale>
+#include <iosfwd>
+#include <string>
+#include <algorithm>
+#include <cctype>
+#include <cwchar>
+#include <cwctype>
+#include <cstdlib>
+#include "toppers/codeset.hpp"
+#include <boost/scoped_array.hpp>
+
+// workaround
+#include <ctype.h>
+#include <wctype.h>
+
+#define TOPPERS_STRINGIFY( s )  TOPPERS_STRINGIFY_( s )
+#define TOPPERS_STRINGIFY_( s ) # s
+
+namespace toppers
+{
+
+  /*!
+   *  \class  conversion_error misc.hpp "toppers/misc.hpp"
+   *  \brief  Ï·G[áONX
+   */
+  class conversion_error : public std::runtime_error
+  {
+  public:
+    /*!
+     *  \brief  RXgN^
+     *  \param  what  áO´ö¶ñ
+     */
+    explicit conversion_error( std::string const& what ) : std::runtime_error( what ) {}
+  };
+
+  /*!
+   *  \brief  VOoCg¶©ç CharT ^i½­Í wchar_t ^j¶ÖÌÏ·
+   *  \param  ch  VOoCg¶
+   *  \return CharT ^¶ðÔ·
+   */
+  template < typename CharT >
+    inline CharT widen( char ch )
+  {
+    return std::use_facet< std::ctype< CharT > >( std::locale() ).widen( ch );
+  }
+
+  template <>
+    inline char widen< char >( char ch )
+  {
+    return ch;
+  }
+
+  template <>
+    inline unsigned char widen< unsigned char >( char ch )
+  {
+    return static_cast< unsigned char >( ch );
+  }
+
+  template <>
+    inline wchar_t widen< wchar_t >( char ch )
+  {
+#if defined( __MINGW32__ )
+    wchar_t wc = wchar_t( -1 );
+    if ( std::mbtowc( &wc, &ch, 1 ) < 0 )
+    {
+      return WEOF;
+    }
+    return wc;
+#elif defined( __CYGWIN__ )
+    return static_cast< wchar_t >( static_cast< unsigned char >( ch ) );
+#else
+    return static_cast< wchar_t >( std::btowc( static_cast< unsigned char >( ch ) ) );
+#endif
+  }
+
+  /*!
+   *  \brief  VOoCg¶ñ©ç CharT ^¶ñÖÌÏ·
+   *  \param  str   VOoCg¶ñ
+   *  \return CharT ^¶ñðÔ·
+   */
+  template < typename CharT >
+    std::basic_string< CharT > const widen( std::string const& str );
+
+  template <>
+    inline std::basic_string< char > const widen( std::string const& str )
+  {
+    return str;
+  }
+
+  template <>
+    inline std::basic_string< wchar_t > const widen( std::string const& str )
+  {
+    boost::scoped_array< wchar_t > t( new wchar_t[str.size()+1] );
+    if ( std::mbstowcs( t.get(), str.c_str(), str.size() ) == size_t( -1 ) )
+    {
+      static conversion_error x( "in function widen" );
+      throw x;
+    }
+    return t.get();
+  }
+
+#undef  tolower
+
+  /*!
+   *  \brief  ¬¶ÖÌÏ·
+   *  \param  ch    Ï·ÎÛÌ¶
+   *  \return ch ªå¶Å êÎÎ·é¬¶ðA»êÈOÍ ch ðÔ·
+   */
+  inline char tolower( char ch )
+  {
+    return static_cast< char >( std::tolower( static_cast< unsigned char >( ch ) ) );
+  }
+
+  /*!
+   *  \brief  ¶ñð¬¶ÉÏ·
+   *  \param  str   Ï·ÎÛÌ¶
+   *  \return str ÉÜÜêéå¶ð¬¶ÉÏ·µ½¶ñðÔ·
+   */
+  inline std::string const tolower( std::string str )
+  {
+    char ( *f )( char ) = &tolower;
+    std::transform( str.begin(), str.end(), str.begin(), f );
+    return str;
+  }
+
+  /*!
+   *  \brief  Ch¶ñð¬¶ÉÏ·
+   *  \param  str   Ï·ÎÛÌ¶
+   *  \return str ÉÜÜêéå¶ð¬¶ÉÏ·µ½Ch¶ñðÔ·
+   */
+  template < class Traits, class Allocator >
+    std::basic_string< wchar_t, Traits, Allocator > const tolower( std::basic_string< wchar_t, Traits, Allocator > str )
+  {
+  	wint_t ( *f )( wint_t ) = &towlower;
+    std::transform( str.begin(), str.end(), str.begin(), f );
+    return str;
+  }
+
+#undef  toupper
+
+  /*!
+   *  \brief  å¶ÖÌÏ·
+   *  \param  ch    Ï·ÎÛÌ¶
+   *  \return ch ª¬¶Å êÎÎ·éå¶ðA»êÈOÍ ch ðÔ·
+   */
+  inline char toupper( char ch )
+  {
+    return static_cast< char >( std::toupper( static_cast< unsigned char >( ch ) ) );
+  }
+
+  /*!
+   *  \brief  ¶ñðå¶ÉÏ·
+   *  \param  str   Ï·ÎÛÌ¶
+   *  \return str ÉÜÜêé¬¶ðå¶ÉÏ·µ½¶ñðÔ·
+   */
+  inline std::string const toupper( std::string str )
+  {
+    char ( *f )( char ) = &toupper;
+    std::transform( str.begin(), str.end(), str.begin(), f );
+    return str;
+  }
+
+  /*!
+   *  \brief  Ch¶ñðå¶ÉÏ·
+   *  \param  str   Ï·ÎÛÌ¶
+   *  \return str ÉÜÜêé¬¶ðå¶ÉÏ·µ½Ch¶ñðÔ·
+   */
+  template < class Traits, class Allocator >
+    std::basic_string< wchar_t, Traits, Allocator > const toupper( std::basic_string< wchar_t, Traits, Allocator > str )
+  {
+  	wint_t ( *f )( wint_t ) = &towupper;
+    std::transform( str.begin(), str.end(), str.begin(), f );
+    return str;
+  }
+
+#undef  isspace
+
+  /*!
+   *  \brief  óÞÌ»Ê
+   *  
+   */
+  inline bool isspace( char ch )
+  {
+    return std::isspace( static_cast< unsigned char >( ch ) ) != 0;
+  }
+
+  /*!
+   *  \brief  wè¶ÅæØçê½XgoÍ
+   *  \param  first   oÍ·éæªvfÊu
+   *  \param  last    oÍ·éI[vfÊu+1
+   *  \param  ostr    oÍXg[
+   *  \param  pred    evfðó¯æèoÍlðÔ·qê
+   *  \param  delim   æØ¶
+   *
+   *  ±ÌÖÍæÔ [first, last) Ìevfð pred ÉnµÄ¾çêélð delim
+   *  ÅæØÁÄ ostr ÉoÍµÜ·B\n
+   *  I[ÌvfÌãÉÍ delim ÍoÍ³ê¸AvfÆvfÌÔÉÌÝ delim ª
+   *  oÍ³êÜ·B
+   */
+  template < class InputIterator, typename CharT, class Traits, class Pred >
+    void output_list( InputIterator first, InputIterator last, std::basic_ostream< CharT, Traits >& ostr, Pred pred, CharT const* delim = 0 )
+  {
+    if ( delim == 0 )
+    {
+      static CharT const null_delim[] = { 0 };
+      delim = null_delim;
+    }
+
+    for ( bool f = false; first != last; ++first )
+    {
+      if ( f )
+      {
+        ostr << delim;
+      }
+      ostr << pred( *first );
+      f = true;
+    }
+  }
+
+  template < typename CharT, class Traits, class Allocator >
+    std::basic_string< CharT, Traits, Allocator > trim( std::basic_string< CharT, Traits, Allocator > const& str, std::basic_string< CharT, Traits, Allocator > const& ws )
+  {
+    if ( str.empty() || ws.empty() )
+    {
+      return str;
+    }
+    typename std::basic_string< CharT, Traits, Allocator >::size_type first = str.find_first_not_of( ws, 0 );
+    for ( typename std::basic_string< CharT, Traits, Allocator >::size_type i = str.size() - 1; i >= 0; i-- )
+    {
+      if ( ws.find( str[ i ] ) == ws.npos )
+      {
+        return str.substr( first, i );
+      }
+    }
+    return str.substr( first );
+  }
+
+}
+
+#endif  // ! TOPPERS_MISC_HPP_
Index: /cfg_oil/trunk/toppers/nm_symbol.cpp
===================================================================
--- /cfg_oil/trunk/toppers/nm_symbol.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/nm_symbol.cpp	(revision 8)
@@ -0,0 +1,108 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/nm_symbol.cpp
+ */
+#include "toppers/nm_symbol.hpp"
+#include <istream>
+#include <sstream>
+#include <cctype>
+
+namespace toppers
+{
+
+  /*!
+   *  \brief  V{e[uÌ[h
+   *  \param  istr  üÍXg[
+   */
+  void nm_symbol::load( std::istream& istr )
+  {
+    while ( istr )
+    {
+      std::string buf;
+      std::getline( istr, buf );
+      std::istringstream isstr( buf );
+
+      unsigned long address = 0;
+      char type;
+      std::string symbol;
+      if ( !std::isspace( static_cast< unsigned char >( buf[0] ) ) )
+      {
+        isstr >> std::hex >> address;
+      }
+      isstr >> type >> symbol;
+
+      if ( !symbol.empty() )
+      {
+        entry e;
+        e.address = address;
+        e.type = static_cast< unsigned char >( type );
+        symbol_map_[symbol] = e;
+      }
+    }
+  }
+
+  /*!
+   *  \brief  V{ÌTõ
+   *  \param  symbol  Tõ·éV{¶ñ
+   *  \return V{ÉÎ·éGgðÔ·
+   */
+  nm_symbol::entry const nm_symbol::find( std::string const& symbol ) const
+  {
+    std::map< std::string, entry >::const_iterator iter( symbol_map_.find( symbol ) );
+    entry e = { 0, -1 };
+    if ( iter != symbol_map_.end() )
+    {
+      e = iter->second;
+    }
+    else
+    {
+      iter = symbol_map_.find( "_" + symbol );  // ¯ÊqÉ'_'ªtÁ³êéêÉÎ
+      if ( iter != symbol_map_.end() )
+      {
+        e = iter->second;
+      }
+    }
+    return e;
+  }
+
+}
Index: /cfg_oil/trunk/toppers/nm_symbol.hpp
===================================================================
--- /cfg_oil/trunk/toppers/nm_symbol.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/nm_symbol.hpp	(revision 8)
@@ -0,0 +1,104 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/nm_symbol.hpp
+ *  \brief  "nm"R}hÅ¾çêéV{e[uðµ¤½ßÌé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  class nm_symbol;
+ *  \endcode
+ */
+#ifndef TOPPERS_NM_SYMBOL_HPP_
+#define TOPPERS_NM_SYMBOL_HPP_
+
+#include "toppers/config.hpp"
+#include <iosfwd>
+#include <string>
+#include <map>
+
+namespace toppers
+{
+
+  /*!
+   *  \class  nm_symbol nm_symbol.hpp "toppers/nm_symbol.hpp"
+   *  \brief  `nm'R}hÅ¾çêéV{e[uðµ¤½ßÌNX
+   *
+   *  \sa nm_symbol::entry
+   */
+  class nm_symbol
+  {
+  public:
+    /*!
+     *  \struct entry nm_symbol.hpp "toppers/nm_symbol.hpp"
+     *  \brief  AhXÆ^Cvîñði[·é\¢Ì
+     *
+     *  `nm'R}hÌoÍÊªA
+     *  \code
+     *  01234567 T foo
+     *  \endcode
+     *  ÆÈÁ½êA0x01234567ª address ÉA'T'ª type Éi[³êÜ·B
+     */
+    struct entry
+    {
+      unsigned long address;
+      int type;
+    };
+
+    /*!
+     *  \brief  ftHgRXgN^
+     */
+    nm_symbol() {}
+    /*!
+     *  \brief  RXgN^
+     *  \param  istr  üÍXg[
+     */
+    explicit nm_symbol( std::istream& istr ) { load( istr ); }
+
+    void load( std::istream& istr );
+    entry const find( std::string const& symbol ) const; 
+  private:
+    std::map< std::string, entry > symbol_map_;
+  };
+
+}
+
+#endif  // ! TOPPERS_NM_SYMBOL_HPP_
Index: /cfg_oil/trunk/toppers/oil/cfg1_out.cpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/cfg1_out.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/cfg1_out.cpp	(revision 8)
@@ -0,0 +1,407 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ *  Copyright (C) 2010 by Meika Sugimoto
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <cstdlib>
+#include <cerrno>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iterator>
+#include <algorithm>
+#include <stack>
+#include "toppers/text.hpp"
+#include "toppers/diagnostics.hpp"
+#include "toppers/c_expr.hpp"
+#include "toppers/global.hpp"
+#include "toppers/macro_processor.hpp"
+#include "toppers/s_record.hpp"
+#include "toppers/nm_symbol.hpp"
+#include "toppers/oil/cfg1_out.hpp"
+#include "toppers/oil/preprocess.hpp"
+#include "toppers/oil/configuration_manager.hpp"
+#include <boost/spirit.hpp>
+#include <boost/filesystem/path.hpp>
+
+using namespace toppers::oil::oil_definition;
+using namespace toppers::configuration_manager;
+
+namespace toppers
+{
+  namespace oil
+  {
+    namespace
+    {
+      struct block_t
+      {
+        std::string type;
+        std::string id;
+        text_line line;
+      };
+    }
+
+    //! cfg_out NXÌÀÚ×
+    struct cfg1_out::implementation
+    {
+    protected:
+      output_file ofile_;
+      oil_def *oil_def_array;
+      std::string cfg1_out_list_;
+      std::string includes_;
+      std::vector< block_t > block_table_;
+
+      std::tr1::shared_ptr< s_record > srec_;
+      std::tr1::shared_ptr< nm_symbol > syms_;
+      bool little_endian_;
+      std::size_t base_;
+      cfg1_def_table const* def_table_;
+	  config_manage oil_configuration;
+
+      implementation( std::string const& filename, std::ios_base::openmode omode, cfg1_def_table const* def_table = 0 )
+		  : ofile_( filename, omode ), little_endian_( true ), base_( 1 ), def_table_( def_table )
+      {
+      }
+      virtual ~implementation()
+      {
+      }
+      virtual void do_load_cfg( std::string const& input_file, codeset_t codeset,  std::vector<std::string> const& obj_info );
+      virtual void do_generate_includes() const
+      {
+      }
+      virtual void do_generate_cfg1_def() const
+      {
+        ofile_ << "const uint32_t TOPPERS_cfg_magic_number = 0x12345678;\n"
+                  "const uint32_t TOPPERS_cfg_sizeof_signed_t = sizeof(signed_t);\n"
+                  "const unsigned_t TOPPERS_cfg_CHAR_BIT = CHAR_BIT;\n"
+                  "const unsigned_t TOPPERS_cfg_CHAR_MAX = CHAR_MAX;\n"
+                  "const unsigned_t TOPPERS_cfg_CHAR_MIN = CHAR_MIN;\n"
+                  "const unsigned_t TOPPERS_cfg_SCHAR_MAX = SCHAR_MAX;\n"
+                  "const unsigned_t TOPPERS_cfg_SHRT_MAX = SHRT_MAX;\n"
+                  "const unsigned_t TOPPERS_cfg_INT_MAX = INT_MAX;\n"
+                  "const unsigned_t TOPPERS_cfg_LONG_MAX = LONG_MAX;\n"
+                  "\n";
+        if ( def_table_ != 0 )
+        {
+          for ( cfg1_def_table::const_iterator iter( def_table_->begin() ), last( def_table_->end() );
+                iter != last;
+                ++iter )
+          {
+            // ®ÌÅÉ # ª êÎA»êÍO®
+            bool is_pp = ( iter->expression[ 0 ] == '#' );
+
+            std::string definition = ( iter->is_signed ? "const signed_t " : "const unsigned_t " );
+            definition += "TOPPERS_cfg_" + iter->name;
+            if ( is_pp )
+            {
+              definition +=
+                          " = \n"
+                          "#if " + iter->expression.substr( 1 ) + "\n"
+                          "1;\n"
+                          "#else\n"
+                          "0;\n"
+                          "#endif\n";
+            }
+            else
+            {
+              definition +=
+                          " = " + iter->expression + ";\n";
+            }
+            ofile_ << definition;
+          }
+        }
+      }
+      virtual void do_assign_params();
+      virtual implementation* do_clone() const
+      {
+        return new implementation( *this );
+      }
+
+      void preprocess( std::string const& input_file, codeset_t codeset, text& txt );
+
+      friend class cfg1_out;
+    };
+
+
+    /*!
+     *  \brief  RXgN^
+     *  \param[in]  filename    cfg1_out.c Ü½Í cfg1_out.srec áµ­Í»êçÌãÖ¼
+     *  \param[in]  def_table   cfg1_out.c ¶¬pÌè`e[u
+     */
+    cfg1_out::cfg1_out( std::string const& filename, cfg1_def_table const* def_table )
+      : pimpl_( new implementation( filename, std::ios_base::out, def_table ) )
+    {
+    }
+
+    /*!
+     *  \brief  Rs[RXgN^
+     *  \param[in]  other   Rs[³
+     */
+    cfg1_out::cfg1_out( cfg1_out const& other )
+      : pimpl_( other.pimpl_->do_clone() )
+    {
+    }
+
+    //! fXgN^
+    cfg1_out::~cfg1_out()
+    {
+      delete pimpl_;
+      pimpl_ = 0;
+    }
+
+    /*!
+     *  \brief  VXeRtBM
+[Vt@CÌ[h
+     *  \param[in]  input_file  üÍt@C¼
+     *  \param[in]  codeset     ¶R[h
+     *  \param[in]  obj_info    IuWFNgîñÌAzzñ
+     */
+    void cfg1_out::load_cfg( std::string const& input_file, codeset_t codeset, 
+    		std::vector<std::string> const* obj_info )
+    {
+      return pimpl_->do_load_cfg( input_file, codeset, *obj_info );
+    }
+
+    //! O
+    void cfg1_out::implementation::preprocess( std::string const& input_file, codeset_t codeset, text& txt )
+    {
+      boost::any print_depend = global( "print-dependencies" );
+      if ( !print_depend.empty() )
+      {
+        std::set< std::string > depend, onces;
+        oil::preprocess( input_file, txt, codeset, &depend, &onces );
+
+        // Ë¶ÖWÌoÍiGNU makeÉKµ½`®j
+        std::string target_file = boost::any_cast< std::string& >( print_depend );
+        std::cout << target_file << ": " << input_file << ' ';
+        std::copy( depend.begin(), depend.end(), std::ostream_iterator< std::string >( std::cout, " " ) );
+        std::cout << std::endl;
+        exit();
+      }
+      else
+      {
+        std::set< std::string > onces;
+        oil::preprocess( input_file, txt, codeset, 0, &onces );
+      }
+    }
+
+    /*!
+     *  \brief  VXeRtBM
+[Vt@CÌ[hÌÀÌ
+     *  \param[in]  input_file  üÍt@C¼
+     *  \param[in]  codeset     ¶R[h
+     *  \param[in]  obj_info    IuWFNgîñÌAzzñ
+     */
+    void cfg1_out::implementation::do_load_cfg( std::string const& input_file, 
+    			codeset_t codeset, std::vector<std::string> const& obj_info )
+    {
+	  
+	  text txt;
+      // VXeRtBM
+[Vt@CÌðÍ
+      std::ostringstream oss, includes_oss;
+
+      preprocess( input_file, codeset, txt );
+	  
+	  // OILîñÌÇÝoµ
+	  if(oil_configuration.read_configuration(&txt , obj_info) == true)
+	  {
+		  oil_def_array = oil_configuration.get_obj_def();
+		  oil_configuration.validate_and_assign_default_configuration();
+	  }
+		
+      // f[^oÖÌ½f
+      std::string cfg1_list_temp( oss.str() );
+      std::string includes_temp( includes_oss.str() );
+
+      cfg1_out_list_.swap( cfg1_list_temp );
+      includes_.swap( includes_temp );
+    }
+
+    /*!
+     *  \brief  cfg1_out.c Ìàe¶¬
+     *  \param[in]  type  zñ cfg1_out[] Ìvf^Bó|C^ÌêÍ uint32_t ÆµÄµíêéB
+     */
+    void cfg1_out::generate( char const* type ) const
+    {
+      if ( type == 0 )
+      {
+        type = "uint32_t";
+      }
+      pimpl_->ofile_ << "/* cfg1_out.c */\n"
+                        "#define TOPPERS_CFG1_OUT  1\n" 
+                        "#include \"osek_kernel.h\"\n"
+                        "#include \"target_cfg1_out.h\"\n";
+      pimpl_->do_generate_includes();
+      pimpl_->ofile_ << pimpl_->includes_ << '\n';
+
+      // int128_tÍÌÓÉ³
+      // int128_tÉµ¦éÆªd­Èè·¬é½ß
+      pimpl_->ofile_ << "\n#ifdef INT64_MAX\n"
+                        "  typedef int64_t signed_t;\n"
+                        "  typedef uint64_t unsigned_t;\n"
+                        "#else\n"
+                        "  typedef int32_t signed_t;\n"
+                        "  typedef uint32_t unsigned_t;\n"
+                        "#endif\n";
+
+      pimpl_->ofile_ << "\n#include <target_cfg1_out.h>\n\n";
+
+      pimpl_->do_generate_cfg1_def();
+      pimpl_->ofile_ << pimpl_->cfg1_out_list_ << '\n';
+    }
+
+    /*!
+     *  \brief  #includewßÌÀÑðæ¾·é
+     *  \return #includewßÌÀÑ
+     *
+     *  ±ÌoÖÍA
+     *  \code
+     *  #include <...>
+     *  #include "..."
+     *  \endcode
+     *  Æ¢Á½#includewßÌÀÑð¶ñÆµÄÔ·B
+     */
+    std::string const& cfg1_out::get_includes() const
+    {
+      return pimpl_->includes_;
+    }
+
+    /*!
+     *  \brief  SR[hÌ[h
+     */
+    void cfg1_out::load_srec()
+    {
+      std::ifstream srec_ifs( ( pimpl_->ofile_.file_name() + ".srec" ).c_str() );
+      if ( !srec_ifs.is_open() )
+      {
+        fatal( _( "cannot open file `%1%\'" ), pimpl_->ofile_.file_name() + ".srec" );
+      }
+      pimpl_->srec_ = std::tr1::shared_ptr< s_record >( new s_record( srec_ifs ) );
+
+      std::ifstream syms_ifs( ( pimpl_->ofile_.file_name() + ".syms" ).c_str() );
+      if ( !syms_ifs.is_open() )
+      {
+        fatal( _( "cannot open file `%1%\'" ), pimpl_->ofile_.file_name() + ".syms" );
+      }
+      pimpl_->syms_ = std::tr1::shared_ptr< nm_symbol >( new nm_symbol( syms_ifs ) );
+
+      nm_symbol::entry nm_entry = pimpl_->syms_->find( "TOPPERS_cfg_magic_number" );
+      if ( nm_entry.type < 0 )
+      {
+        fatal( _( "magic number is not found in `%1%\'" ), ( pimpl_->ofile_.file_name() + ".srec/.syms" ) );
+      }
+      unsigned long magic[ 4 ];
+      magic[ 0 ] = ( *pimpl_->srec_ )[ nm_entry.address + 0 ];
+      magic[ 1 ] = ( *pimpl_->srec_ )[ nm_entry.address + 1 ];
+      magic[ 2 ] = ( *pimpl_->srec_ )[ nm_entry.address + 2 ];
+      magic[ 3 ] = ( *pimpl_->srec_ )[ nm_entry.address + 3 ];
+      unsigned long magic_number = ( magic[ 0 ] << 24 ) | ( magic[ 1 ] << 16 ) | ( magic[ 2 ] << 8 ) | magic[ 3 ];
+      if ( magic_number == 0x12345678 )
+      {
+        pimpl_->little_endian_ = false;
+      }
+      else if ( magic_number == 0x78563412 )
+      {
+        pimpl_->little_endian_ = true;
+      }
+      else
+      {
+        fatal( _( "magic number is not found in `%1%\'" ), ( pimpl_->ofile_.file_name() + ".srec/.syms" ) );
+      }
+      pimpl_->do_assign_params();
+    }
+
+    /*!
+     *  \brief  "cfg1_out.srec" ©çÇÝæÁ½îñÌQÆ
+     */
+    std::tr1::shared_ptr< s_record > cfg1_out::get_srec() const
+    {
+      return pimpl_->srec_;
+    }
+
+    /*!
+     *  \brief  "cfg1_out.syms" ©çÇÝæÁ½îñÌQÆ
+     */
+    std::tr1::shared_ptr< nm_symbol > cfg1_out::get_syms() const
+    {
+      return pimpl_->syms_;
+    }
+
+    cfg1_out::cfg1_def_table const* cfg1_out::get_def_table() const
+    {
+      return pimpl_->def_table_;
+    }
+
+    /*!
+     *  \brief  IuWFNg²ÆÉOILIuWFNgîñðÜÆßé
+     *  \return ÃIAPIîñ
+     *
+     *  ±ÌÖÍA"tsk"â"sem"Æ¢Á½íÊðL[ÆµÄA»ÌíÊÉªÞ³êéÃIAPIîñÌAzzñð¶¬·éB
+     */
+	cfg1_out::cfg_obj_map cfg1_out::merge() const
+    {
+	  cfg_obj_map result;
+	  
+	  result = oil_definition::merge(pimpl_->oil_def_array , result);
+
+	  return result;
+
+    }
+
+    /*!
+     *  \brief  gGfBA©Ç¤©Ì»è
+     *  \retval     true  gGfBA
+     *  \retval     false rbOGfBA
+     *  \attention  load_srec ÄÑoµOÍ³µ¢Êð¾çêÈ¢B
+     */
+    bool cfg1_out::is_little_endian() const
+    {
+      return pimpl_->little_endian_;
+    }
+
+    /*!
+     *  \brief  ÃIAPIÌp[^ÉSR[h©çæ¾µ½lðãü·é
+     */
+    void cfg1_out::implementation::do_assign_params()
+    {
+    }
+
+  }
+}
Index: /cfg_oil/trunk/toppers/oil/cfg1_out.hpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/cfg1_out.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/cfg1_out.hpp	(revision 8)
@@ -0,0 +1,144 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/oil/cfg1_out.hpp
+ *  \brief  cfg1_out.c/.srec t@Cðµ¤½ßÌé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  class cfg1_out;
+ *  \endcode
+ */
+#ifndef TOPPERS_OIL_CFG1_OUT_HPP_
+#define TOPPERS_OIL_CFG1_OUT_HPP_
+
+#include <string>
+#include <vector>
+#include <map>
+#include "toppers/workaround.hpp"
+#include "toppers/codeset.hpp"
+#include "toppers/oil/oil_object.hpp"
+
+namespace toppers
+{
+
+  class macro_processor;
+  class s_record;
+  class nm_symbol;
+
+  namespace oil
+  {
+	  using namespace toppers::oil::oil_definition;
+
+    /*!
+     *  \class  cfg1_out  cfg1_out.hpp  "toppers/oil/cfg1_out.hpp"
+     *  \brief  cfg1_out.c/.srec t@CÇNX
+     */
+    class cfg1_out
+    {
+    public:
+      struct cfg1_def_t
+      {
+        bool is_signed;
+        std::string name;
+        std::string expression;
+      };
+	  typedef std::map< std::string, std::vector< object_definition* > > cfg_obj_map;
+     typedef std::vector< cfg1_def_t > cfg1_def_table;
+
+      explicit cfg1_out( std::string const& filename, cfg1_def_table const* def_table = 0 );
+      cfg1_out( cfg1_out const& other );
+      virtual ~cfg1_out();
+      cfg1_out& operator = ( cfg1_out const& other )
+      {
+        cfg1_out t( other );
+        swap( t );
+        return *this;
+      }
+
+	  void load_cfg( std::string const& input_file, codeset_t codeset, std::vector<std::string> const* obj_info );
+      void generate( char const* type = 0 ) const;
+      std::string const& get_includes() const;
+
+      void load_srec();
+      std::tr1::shared_ptr< s_record > get_srec() const;
+      std::tr1::shared_ptr< nm_symbol > get_syms() const;
+      cfg1_def_table const* get_def_table() const;
+      cfg_obj_map merge(void) const;
+      bool is_little_endian() const;
+
+      void swap( cfg1_out& other )
+      {
+        implementation* t = pimpl_;
+        pimpl_ = other.pimpl_;
+        other.pimpl_ = t;
+      }
+	  void swap(cfg_obj_map& other)
+	  {
+
+	  }
+
+      static std::tr1::int32_t make_signed( std::tr1::uint32_t value )
+      {
+        std::tr1::int32_t result;
+        if ( ( value >> 31 ) != 0 )
+        {
+          result = -static_cast< std::tr1::int32_t >( ( value ^ 0xffffffff ) + 1 ); // 2Ìâ\»Éµ©ÎµÈ¢
+        }
+        else
+        {
+          result = static_cast< std::tr1::int32_t >( value );
+        }
+        return result;
+      }
+
+
+    protected:
+      struct implementation;
+      explicit cfg1_out( implementation* pimpl ) : pimpl_( pimpl ) {}
+    private:
+      implementation* pimpl_;
+    };
+
+  }
+}
+
+#endif  // ! TOPPERS_OIL_CFG1_OUT_HPP_
Index: /cfg_oil/trunk/toppers/oil/configuration_manager.cpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/configuration_manager.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/configuration_manager.cpp	(revision 8)
@@ -0,0 +1,215 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2010 by Meika Sugimoto
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+#include <vector>
+#include <map>
+#include <algorithm>
+#include <functional>
+
+#include "toppers/global.hpp"
+#include "toppers/oil/configuration_manager.hpp"
+
+using namespace std;
+using namespace toppers::oil;
+using namespace toppers::oil::oil_implementation;
+using namespace toppers::oil::oil_definition;
+
+namespace toppers
+{
+	namespace configuration_manager
+	{
+		// APPMODEðT·t@N^
+		bool find_appmode_object(object_definition *p)
+		{
+			if(p->get_object_type() == "APPMODE")
+			{
+				return true;
+			}
+			return false;
+		}
+
+		bool config_manage::read_configuration
+			(toppers::text *txt , std::vector<std::string> const& objlist)
+		{
+			  description = txt;
+
+			  // XgOðìé
+			  description_str = new string();
+			  typedef text::container::const_iterator const_row_iterator;
+			  typedef std::string::size_type size_type;
+			  const_row_iterator first( txt->begin().get_row() ), last( txt->end().get_row() );
+
+			  for ( const_row_iterator iter( first ); iter != last; ++iter )
+			  {
+				  *description_str += iter->buf;
+			  }
+
+			  // p[TÌ¶¬
+			  try
+			  {
+				  parser = new ::oil_parser(description_str , objlist);
+			  }
+			  catch( ... )
+			  {
+				  toppers::fatal("Memory allocation error.");
+			  }
+
+			if(parser->do_parse(&oil_impl , &oil_def) == 0)
+			{
+				std::string kernel_type;
+				// APPMODEªè`³êÄ¢È¢ÍOSDEFAULTAPPMODEð}ü
+				toppers::get_global("kernel" , kernel_type);
+				if((kernel_type == "atk1")
+					&& (oil_def->end() == 
+						(find_if(oil_def->begin() , oil_def->end() , find_appmode_object))))
+				{
+					oil_def->push_back(new object_definition("APPMODE OSDEFAULTAPPMODE"));
+				}
+
+				return true;
+			}
+			else
+			{
+				std::string message;
+				int position;
+				text::const_iterator iter;
+
+				// G[ÊuÌæ¾
+				parser->get_error(&position , &message);
+				// YsÌæ¾
+				iter = description->line_at(position);
+				text::line_type error_occur = iter.line();
+				
+				// ¶@G[Í·®ÉI¹
+				toppers::fatal(iter.line() , "%1%" , message);
+				
+				return false;
+			}
+		}
+
+		bool object_matching(object_definition* obj , oil_object_impl* impl)
+		{
+			return impl->validate_object_configuration(obj , NULL);
+		}
+
+		bool config_manage::validate_and_assign_default_configuration(void)
+		{
+			bool result = true;
+			std::vector<oil_definition::object_definition*>::iterator p;
+			std::vector<oil_implementation::oil_object_impl*>::iterator q , found;
+			
+			// SÄÌIuWFNgè`ðÀÆ®µÄ¢é©`FbNµA
+			// ftHgp[^Ìâ®ðs¤
+			for(p = oil_def->begin() ; p != oil_def->end() ; p++)
+			{
+				std::vector<toppers::oil::object_ref> object_refs;
+				for(q = oil_impl->begin() ; q != oil_impl->end() ; q++)
+				{
+					if((*q)->validate_object_configuration(*p , &object_refs) == true)
+					{
+						break;
+					}
+				}
+				
+				if(q >= oil_impl->end())
+				{
+					// p[^Ì®«`FbN
+					result = false;
+					break;
+				}
+				
+				// t@Xæª³µ¢©Ì`FbN
+				result = validate_object_reference((*p)->get_name() , &object_refs);
+			}
+
+			return result;
+		}
+		bool config_manage::validate_object_reference
+				(std::string obj_name , std::vector<object_ref> *obj_refs)
+		{
+			std::vector<oil_definition::object_definition*>::iterator q;
+			std::vector<object_ref>::iterator p;
+			bool result = true;
+			
+			for(p = obj_refs->begin() ; p != obj_refs->end() ; p++)
+			{
+				std::vector<oil_definition::object_definition*> name_match;
+				// ¼Oª¯¶àÌðTõ
+				for(q = oil_def->begin() ; q != oil_def->end() ; q++)
+				{
+					if((*p).obj_name == (*q)->get_name())
+					{
+						name_match.push_back(*q);
+					}
+				}
+				// ¼OªêvµÈ¯êÎ»Ì_ÅG[
+				if(name_match.empty() == true)
+				{
+					toppers::error("Object %1%'s parameter %2% reference %3% , but not found." ,
+										obj_name , (*p).obj_type , (*p).obj_name);
+					result = false;
+					continue;
+				}
+
+				// QÆæÌ^Cvª¯¶©Tõ
+				for(q = name_match.begin() ; q != name_match.end() ; q++)
+				{
+					if((*p).obj_type == (*q)->get_object_type())
+					{
+						break;
+					}
+				}
+				// ^Cvª¯¶àÌªÈ¯êÎG[
+				if(q == name_match.end())
+				{
+					toppers::error("Object %1%'s parameter %2% reference %3% , but referenced object is not %4%_TYPE" , 
+									obj_name , (*p).obj_type , (*p).obj_name , (*p).obj_type);
+					result = false;
+				}
+			}
+
+			return result;
+		}
+
+	}	/* namespace oil */
+
+}	/* namespace toppers */
+
Index: /cfg_oil/trunk/toppers/oil/configuration_manager.hpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/configuration_manager.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/configuration_manager.hpp	(revision 8)
@@ -0,0 +1,97 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+#ifndef CONFIGURATION_MANAGER_H
+#define CONFIGURATION_MANAGER_H
+
+#include <string>
+#include <iostream>
+
+#include "toppers/oil/oil_parser.hpp"
+#include "toppers/text.hpp"
+#include "toppers/diagnostics.hpp"
+
+using namespace toppers::oil;
+
+namespace toppers
+{
+	namespace configuration_manager
+	{
+
+		class config_manage
+		{
+			public:
+				config_manage(void)
+				{
+				}
+				~config_manage()
+				{
+					delete description_str;
+					delete parser;
+				}
+				bool read_configuration
+					(toppers::text *txt , std::vector<std::string> const& objlist);
+				void dump_configuration(void)
+				{
+					parser->dump_implementation();
+					parser->dump_definition();
+				}
+
+				::oil_def* const get_obj_def(void)
+				{
+					return oil_def;
+				}
+				bool validate_and_assign_default_configuration(void);
+			private:
+				bool validate_object_reference
+						(std::string obj_name , std::vector<object_ref> *obj_refs);
+				toppers::text *description;
+				string *description_str;
+				oil_parser *parser;
+				::oil_def *oil_def;
+				::oil_impl *oil_impl;
+		};
+
+	}	/* namespace configuration_manager */
+
+}	/* namespace toppers */
+
+#endif	/* CONFIGURATION_MANAGER_H */
Index: /cfg_oil/trunk/toppers/oil/factory.cpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/factory.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/factory.cpp	(revision 8)
@@ -0,0 +1,492 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ *  Copyright (C) 2010 by Meika Sugimoto
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <cstring>
+#include <cstdlib>
+#include <fstream>
+#include <boost/lexical_cast.hpp>
+#include <boost/spirit.hpp>
+#include "toppers/misc.hpp"
+#include "toppers/global.hpp"
+#include "toppers/csv.hpp"
+#include "toppers/nm_symbol.hpp"
+#include "toppers/s_record.hpp"
+#include "toppers/diagnostics.hpp"
+#include "toppers/macro_processor.hpp"
+#include "toppers/io.hpp"
+#include "toppers/cpp.hpp"
+#include "toppers/oil/factory.hpp"
+#include "toppers/oil/cfg1_out.hpp"
+
+namespace toppers
+{
+  namespace oil
+  {
+    namespace
+    {
+
+	  object_definition* find_object(string name , cfg1_out::cfg_obj_map const& obj_def_map)
+	  {
+		  std::map< std::string, std::vector<object_definition*>>::const_iterator p;
+		  std::vector<object_definition*>::const_iterator q;
+		
+		  // ¼Oªêv·éIuWFNgðõ
+		  for(p = obj_def_map.begin() ; p != obj_def_map.end() ; p++)
+		  {
+			  for(q = (*p).second.begin() ; q != (*p).second.end() ; q++)
+			  {
+				  if((*q)->get_name() == name)
+				  {
+					  return (*q);
+				  }
+			  }
+		  }		 
+		  return NULL;
+	  }
+
+      // J[lIuWFNg¶¬Eè`pÃIAPIÌep[^ð}NvZbTÌÏÆµÄÝè·éB
+      void set_object_vars( cfg1_out::cfg_obj_map const& obj_def_map, macro_processor& mproc )
+      {
+        typedef macro_processor::element element;
+        typedef macro_processor::var_t var_t;
+        std::map< std::string, var_t > order_list_map , obj_parameter;
+        std::map< std::string, long > id_map;
+
+		using namespace toppers::oil::oil_definition;
+		std::map< std::string, std::vector<object_definition*>>::const_iterator p;
+		std::vector<object_definition*>::const_iterator q;
+		std::vector<object_parameter_def*>::const_iterator r;
+
+        for ( p = obj_def_map.begin() ; p != obj_def_map.end() ; p++)
+        {
+			element e;
+			var_t t;
+			string name;
+			long obj_id;
+			long param_id;
+			
+			// p[^Ìlãü
+			for(q = (*p).second.begin() ; q != (*p).second.end() ; q++)
+			{
+				std::map< std::string, var_t > obj_parameter;
+				std::map< std::string, var_t >::iterator s;
+				obj_id = (*q)->get_id();
+				name = (*p).first;
+				std::map<std::string , long> id_count;
+				std::map<std::string , long>::iterator id_iter;
+
+				// lÌæèoµ
+				e.i = (*q)->get_id();
+				e.s = (*q)->get_name();
+				// o»XgpÌîñì¬
+				order_list_map[ name ].push_back(e);
+				// IuWFNg©gÌlãü
+	            mproc.set_var( toppers::toupper(name), obj_id, var_t( 1, e ) );
+				
+				// IuWFNgoÌlãü
+				for(r = (*q)->get_params()->begin() ; r != (*q)->get_params()->end() ; r++)
+				{
+					name = (*p).first+ string(".") + (*r)->get_parameter_name();
+					e.s = (*r)->get_value();
+
+					if(e.s == string(""))
+					{
+						continue;
+					}
+
+					// oÌIDðõ
+					id_iter = id_count.find(name);
+					if(id_iter == id_count.end())
+					{
+						id_count[name] = 0;
+						param_id = 0;
+					}
+					else
+					{
+						param_id = (*id_iter).second + 1;
+						id_count[name] = (*id_iter).second + 1;
+					}
+
+					if((*r)->get_type() == oil::TYPE_UINT)
+					{
+						string value_str(((*r)->get_value()));
+						try
+						{
+							e.i = boost::lexical_cast<unsigned __int64>((*r)->get_value());
+						}
+						catch( std::exception& exception)
+						{
+							unsigned __int64 temp;
+							// 16iÌêª éÌÅÏ·
+							/// «ê¢¶áÈ¢ÌÅÈñÆ©µ½¢
+							if(value_str.find("0x") == 0)
+							{
+								sscanf_s(value_str.c_str() , "0x%I64x" , &temp);
+								e.i = temp;
+							}
+							else if(value_str.find("0X") == 0)
+							{
+								sscanf_s(value_str.c_str() , "0X%I64x" , &temp);
+								e.i = temp;
+							}
+							else
+							{
+								// LXgÉ¸sµ½ç0ÉµÄ¨­
+								e.i = 0;
+							}
+
+						}
+					}
+					else if((*r)->get_type() == oil::TYPE_INT)
+					{
+						string value_str(((*r)->get_value()));
+						try
+						{
+							e.i = boost::lexical_cast<__int64>(value_str);
+						}
+						catch(std::exception& exception)
+						{
+							__int64 temp;
+							// 16iÌêª éÌÅÏ·
+							/// «ê¢¶áÈ¢ÌÅÈñÆ©µ½¢
+							if(value_str.find("0x") == 0)
+							{
+								sscanf_s(value_str.c_str() , "0x%I64x" , &temp);
+								e.i = temp;
+							}
+							else if(value_str.find("0X") == 0)
+							{
+								sscanf_s(value_str.c_str() , "0X%I64x" , &temp);
+								e.i = temp;
+							}
+							else
+							{
+								// LXgÉ¸sµ½ç0ÉµÄ¨­
+								e.i = 0;
+							}
+						}
+					}
+					else if((*r)->get_type() == oil::TYPE_REF)
+					{
+						object_definition *obj;
+						string refefence_obj_type;
+
+						// IuWFNgIDÌTõ
+						e.i = 0;
+						obj = find_object((*r)->get_value() , obj_def_map);
+						if(obj != NULL)
+						{
+							e.i = obj->get_id();
+						}
+					}
+					else
+					{
+						e.i = 0;
+					}
+					obj_parameter[name].push_back(e);
+				}
+
+				for(s = obj_parameter.begin() ; s != obj_parameter.end() ; s++)
+				{
+					mproc.set_var((*s).first , obj_id , (*s).second );
+				}
+			}
+
+		}
+		// XgÌì¬
+        for ( std::map< std::string, var_t >::const_iterator iter( order_list_map.begin() ), last( order_list_map.end() );
+              iter != last;
+              ++iter )
+        {
+          // o»Xg $OBJ.ORDER_LIST$ -- IDÔÌÀÑ
+          mproc.set_var( toppers::toupper( iter->first + ".order_list" ), iter->second );
+          var_t rorder_list( iter->second );
+
+          // tXg $OBJ.RORDER_LIST$ -- IDÔÌÀÑ
+          std::reverse( rorder_list.begin(), rorder_list.end() );
+          mproc.set_var( toppers::toupper( iter->first + ".rorder_list" ), rorder_list );
+
+          // IDÔXg $OBJ.ID_LIST$ -- IDÔÌÀÑ
+          var_t id_list( iter->second );
+          std::sort( id_list.begin(), id_list.end() );
+          mproc.set_var( toppers::toupper( iter->first + ".id_list" ), id_list );
+        }
+	  }
+
+
+      // vbgtH[ERpCË¶Ìlð}NvZbTÌÏÆµÄÝè·éB
+      void set_platform_vars( cfg1_out const& cfg1out, macro_processor& mproc )
+      {
+        typedef macro_processor::element element;
+        typedef macro_processor::var_t var_t;
+
+        cfg1_out::cfg1_def_table const* def_table = cfg1out.get_def_table();
+        std::size_t sizeof_signed_t;
+
+        static cfg1_out::cfg1_def_t const limit_defs[] =
+        {
+          { false, "TOPPERS_cfg_CHAR_BIT",  "CHAR_BIT" },
+          { false, "TOPPERS_cfg_CHAR_MAX",  "CHAR_MAX" },
+          { true, "TOPPERS_cfg_CHAR_MIN",  "CHAR_MIN" },
+          { false, "TOPPERS_cfg_SCHAR_MAX", "SCHAR_MAX" },  // {Ít«¾ªAÉÈé±ÆÍÈ¢
+          { false, "TOPPERS_cfg_SHRT_MAX",  "SHRT_MAX" },   // {Ít«¾ªAÉÈé±ÆÍÈ¢
+          { false, "TOPPERS_cfg_INT_MAX",   "INT_MAX" },    // {Ít«¾ªAÉÈé±ÆÍÈ¢
+          { false, "TOPPERS_cfg_LONG_MAX",  "LONG_MAX" },   // {Ít«¾ªAÉÈé±ÆÍÈ¢
+        };
+
+        nm_symbol::entry nm_entry = cfg1out.get_syms()->find( "TOPPERS_cfg_sizeof_signed_t" );
+        sizeof_signed_t = static_cast< std::size_t >( cfg1out.get_srec()->get_value( nm_entry.address, 4, cfg1out.is_little_endian() ) );
+
+        for ( std::size_t i = 0; i < sizeof limit_defs / sizeof limit_defs[ 0 ]; ++i )
+        {
+          element e;
+          e.s = limit_defs[ i ].expression;
+          nm_entry = cfg1out.get_syms()->find( limit_defs[ i ].name );
+          std::tr1::int64_t value = cfg1out.get_srec()->get_value( nm_entry.address, sizeof_signed_t, cfg1out.is_little_endian() );
+          if ( sizeof_signed_t < 8 && limit_defs[ i ].is_signed )
+          {
+            value = cfg1_out::make_signed( static_cast< std::tr1::uint32_t >( value ) );
+          }
+          mproc.set_var( e.s, var_t( 1, e ) );
+        }
+
+        for ( cfg1_out::cfg1_def_table::const_iterator iter( def_table->begin() ), last( def_table->end() );
+              iter != last;
+              ++iter )
+        {
+          element e;
+          e.s = iter->expression;
+          nm_entry = cfg1out.get_syms()->find( "TOPPERS_cfg_" + iter->name );
+          if ( nm_entry.type >= 0 )
+          {
+            std::tr1::int64_t value = cfg1out.get_srec()->get_value( nm_entry.address, sizeof_signed_t, cfg1out.is_little_endian() );
+            if ( sizeof_signed_t < 8 && iter->is_signed )
+            {
+              value = cfg1_out::make_signed( static_cast< std::tr1::uint32_t >( value ) );
+            }
+            e.i = value;
+            mproc.set_var( iter->name, var_t( 1, e ) );
+          }
+        }
+
+        // oCgI[_[
+        {
+          bool little_endian = cfg1out.is_little_endian();
+          element e;
+          e.i = little_endian;
+          mproc.set_var( "LITTLE_ENDIAN", var_t( 1, e ) );
+
+          e.i = !little_endian;
+          mproc.set_var( "BIG_ENDIAN", var_t( 1, e ) );
+        }
+      }
+
+    }
+
+    //! RXgN^
+    factory::factory( std::string const& kernel )
+      : kernel_( tolower( kernel ) )
+    {
+    }
+
+    //! fXgN^
+    factory::~factory()
+    {
+    }
+
+    //! T|[gµÄ¢éIuWFNgîñÌæ¾
+	std::vector<std::string> const* factory::get_object_definition_info() const
+    {
+      // CSV©çÃIAPIîñðÇÝæèAo^·é½ßÌ[JNX
+      struct init_t
+      {
+        init_t()
+        {
+          boost::any t = global( "api-table" );
+          if ( !t.empty() )
+          {
+            std::vector< std::string > api_tables( boost::any_cast< std::vector< std::string >& >( t ) );
+            for ( std::vector< std::string >::const_iterator iter( api_tables.begin() ), last( api_tables.end() );
+                  iter != last;
+                  ++iter )
+            {
+              std::string buf;
+              read( iter->c_str(), buf );
+	          csv data( buf.begin(), buf.end() );
+              for ( csv::const_iterator d_iter( data.begin() ), d_last( data.end() );
+                    d_iter != d_last;
+                    ++d_iter )
+              {
+                  unsigned int i;
+                  for(i = 0 ; i < d_iter->size() ; i++)
+                  {
+                      volatile int x = 1;
+                      object_definition_table.push_back((*d_iter)[i].c_str());
+                  }
+              }
+
+            }
+          }
+        }
+
+        ~init_t()
+        {
+
+        
+        }
+
+		std::vector<std::string> object_definition_table;
+      };
+      static init_t init;
+	  std::vector<std::string> const* result = &init.object_definition_table;
+      return result;
+    }
+
+    /*!
+     * \brief   cfg1_out.c ÖÌoÍîñe[uÌ¶¬
+     * \return  ¶¬µ½ cfg1_out::cfg1_def_table IuWFNgÖÌ|C^
+     * \note    ±ÌÖªÔ·|C^Í delete µÄÍÈçÈ¢
+     *
+     * --cfg1-def-table IvVÅwèµ½t@C©çAcfg1_out.c ÖoÍ·éîñðÇÝæèA
+     * cfg1_out::cfg1_def_table IuWFNgð¶¬·éB
+     *
+     * CSV Ì`®ÍÈºÌÊè
+     *
+     *    V{¼,®[,s|signed]
+     *
+     * öÌ s Ü½Í signed ÍÈªÂ\BÈªÍ³µ®ÆÝÈ·Bs Ü½Í signed wèÍ
+     * t«®ÆÝÈ·B\n
+     * u®vÌÅÉ # ª êÎO®ÆÝÈ·B
+     */
+    cfg1_out::cfg1_def_table const* factory::get_cfg1_def_table() const
+    {
+      struct init_t
+      {
+        init_t()
+        {
+          boost::any t = global( "cfg1-def-table" );
+          if ( !t.empty() )
+          {
+            std::vector< std::string > cfg1_def_table = boost::any_cast< std::vector< std::string >& >( t );
+            for ( std::vector< std::string >::const_iterator iter( cfg1_def_table.begin() ), last( cfg1_def_table.end() );
+                  iter != last;
+                  ++iter )
+            {
+              std::string buf;
+              read( iter->c_str(), buf );
+              csv data( buf.begin(), buf.end() );
+              for ( csv::const_iterator d_iter( data.begin() ), d_last( data.end() );
+                    d_iter != d_last;
+                    ++d_iter )
+              {
+                csv::size_type len = d_iter->size();
+                if ( len < 2 )
+                {
+                  toppers::fatal( _( "too little fields in `%1%\'" ), *iter );
+                }
+                cfg1_out::cfg1_def_t def = { 0 };
+                def.name = ( *d_iter )[ 0 ];
+                def.expression = ( *d_iter )[ 1 ];
+                if ( len >= 3 )
+                {
+                  std::string is_signed( ( *d_iter )[ 2 ] );
+                  def.is_signed = ( is_signed == "s" || is_signed == "signed" );
+                }
+                cfg1_def_table_.push_back( def );
+              }
+            }
+          }
+        }
+        cfg1_out::cfg1_def_table cfg1_def_table_;
+      };
+      static init_t init;
+      cfg1_out::cfg1_def_table const* result = &init.cfg1_def_table_;
+      return result;
+    }
+
+    //! IuWFNgÌð·
+    void factory::do_swap( factory& other )
+    {
+      kernel_.swap( other.kernel_ );
+    }
+
+    macro_processor::hook_t factory::do_get_hook_on_assign() const
+    {
+//      return &hook_on_assign;
+      return 0;
+    }
+
+    /*!
+     *  \brief  }NvZbTÌ¶¬
+     *  \param[in]  hook    ÏÉlðãüµ½ÛÌtbN
+     *  \param[in]  cfg1out cfg1_out IuWFNg
+     *  \param[in]  api_map .cfg t@CÉLq³ê½ÃIAPIîñ
+     *  \return     }NvZbTÖÌ|C^
+     */
+    std::auto_ptr< macro_processor > factory::do_create_macro_processor( macro_processor::hook_t hook, cfg1_out const& cfg1out, cfg1_out::cfg_obj_map const& obj_def_map ) const
+    {
+      typedef macro_processor::element element;
+      typedef macro_processor::var_t var_t;
+      std::auto_ptr< macro_processor > mproc( new macro_processor( hook ) );
+      element e;
+
+      e.s = " ";    mproc->set_var( "SPC", var_t( 1, e ) );  // $SPC$
+      e.s = "\t";   mproc->set_var( "TAB", var_t( 1, e ) );  // $TAB$
+      e.s = "\n";   mproc->set_var( "NL",  var_t( 1, e ) );  // $NL$
+
+      // o[Wîñ
+      e.s = toppers::get_global< std::string >( "version" );
+      e.i = toppers::get_global< std::tr1::int64_t >( "timestamp" );
+      mproc->set_var( "CFG_VERSION", var_t( 1, e ) );   // $CFG_VERSION$
+
+      // »Ì¼ÌgÝÝÏÌÝè
+      set_object_vars( obj_def_map, *mproc );
+      set_platform_vars( cfg1out, *mproc );
+      return mproc;
+    }
+
+    std::auto_ptr< cfg1_out > factory::do_create_cfg1_out( std::string const& filename ) const
+    {
+      return std::auto_ptr< oil::cfg1_out >( new cfg1_out( filename, get_cfg1_def_table() ) );
+    }
+
+  }
+}
Index: /cfg_oil/trunk/toppers/oil/factory.hpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/factory.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/factory.hpp	(revision 8)
@@ -0,0 +1,100 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ *  Copyright (C) 2010 by Meika Sugimoto
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/oil/factory.hpp
+ *  \brief  J[lÜ½ÍW
+[É¶½IuWFNg¶¬ÉÖ·éé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  class factory;
+ *  \endcode
+ */
+#ifndef TOPPERS_OIL_FACTORY_HPP_
+#define TOPPERS_OIL_FACTORY_HPP_
+
+#include <memory>
+#include <string>
+#include <vector>
+#include "toppers/macro_processor.hpp"
+#include "toppers/oil/cfg1_out.hpp"
+
+namespace toppers
+{
+  namespace oil
+  {
+    /*!
+     *  \class  factory factory.hpp "toppers/oil/factory.hpp"
+     *  \brief  J[lÜ½ÍW
+[É¶½IuWFNg¶¬NX
+     */
+    class factory
+    {
+    public:
+      explicit factory( std::string const& kernel );
+      virtual ~factory();
+      std::vector<std::string> const* get_object_definition_info() const;
+	  cfg1_out::cfg1_def_table const* get_cfg1_def_table() const;
+      macro_processor::hook_t get_hook_on_assign() const { return do_get_hook_on_assign(); }
+      std::auto_ptr< cfg1_out > create_cfg1_out( std::string const& filename ) const
+      {
+        return do_create_cfg1_out( filename );
+      }
+      std::auto_ptr< macro_processor > create_macro_processor( macro_processor::hook_t hook, cfg1_out const& cfg1out, cfg1_out::cfg_obj_map const& obj_def_map ) const
+      {
+        return do_create_macro_processor( hook, cfg1out, obj_def_map );
+      }
+      void swap( factory& other ) { do_swap( other ); }
+    protected:
+      virtual void do_swap( factory& other );
+      virtual macro_processor::hook_t do_get_hook_on_assign() const;
+      virtual std::auto_ptr< macro_processor > do_create_macro_processor( macro_processor::hook_t hook, cfg1_out const& cfg1out, cfg1_out::cfg_obj_map const& obj_def_map ) const;
+    private:
+      virtual std::auto_ptr< cfg1_out > do_create_cfg1_out( std::string const& filename ) const;
+
+      std::string kernel_;
+    };
+
+  }
+}
+
+#endif  // ! TOPPERS_OIL_FACTORY_HPP_
Index: /cfg_oil/trunk/toppers/oil/oil_object.cpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/oil_object.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/oil_object.cpp	(revision 8)
@@ -0,0 +1,889 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2010 by Meika Sugimoto
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+#include <boost/regex.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/cast.hpp>
+#include <algorithm>
+#include <functional>
+
+#include "toppers/oil/oil_object.hpp"
+#include "toppers/diagnostics.hpp"
+
+namespace toppers
+{
+	namespace oil
+	{
+		// fobOpÖ
+		void dump(boost::smatch *r)
+		{
+			unsigned int i;
+
+			for(i = 0 ; i < r->size() ; i++)
+			{
+				cout << "Match[" << i << "] : " << r->str(i) << endl;
+			}
+		}
+		
+		namespace oil_implementation
+		{
+			int oil_object_impl::add_parameter(string param_name , string parameter_description)
+			{
+				if((parameter_description.find("UINT32") == 0)
+					|| (parameter_description.find("UINT64") == 0))
+				{
+					this->params.push_back(
+						(object_parameter_impl *)(new parameter_uint_impl(param_name , parameter_description)));
+				}
+				else if((parameter_description.find("INT32") == 0)
+						|| (parameter_description.find("INT64") == 0))
+				{
+					this->params.push_back(
+						(object_parameter_impl *)(new parameter_int_impl(param_name , parameter_description)));
+				}
+				else if(parameter_description.find("ENUM") == 0)
+				{
+					this->params.push_back(
+						(object_parameter_impl *)(new parameter_enum_impl(param_name , parameter_description)));
+				}
+				else if(parameter_description.find("BOOLEAN") == 0)
+				{
+					boost::regex bool_with_option("\\[\\s*TRUE");
+					string::const_iterator start = parameter_description.begin();
+					string::const_iterator end = parameter_description.end();
+
+					// [ TRUE , FALSE ]ª éêÍENUMÆ¯¶µ¢AÈ¢êÍSTRINGÆ¯¶µ¢Æ·é
+					if(regex_search(start , end , bool_with_option))
+					{
+						this->params.push_back(
+							(object_parameter_impl *)(new parameter_enum_impl(param_name , parameter_description)));
+					}
+					else
+					{
+						this->params.push_back(
+							(object_parameter_impl *)(new parameter_boolean_impl(param_name , parameter_description)));
+					}
+				}
+				else if(parameter_description.find("STRING") == 0)
+				{
+					this->params.push_back(
+						(object_parameter_impl *)(new parameter_string_impl(param_name , parameter_description)));
+				}
+				else if(parameter_description.find("FLOAT") == 0)
+				{
+					this->params.push_back(
+						(object_parameter_impl *)(new parameter_float_impl(param_name , parameter_description)));
+				}
+				else if(parameter_description.find("_TYPE") != string::npos)
+				{
+					this->params.push_back(
+						(object_parameter_impl *)(new parameter_object_ref_impl(param_name , parameter_description)));
+				}
+				else
+				{
+					//  è¦È¢
+				}
+
+				return 0;
+			}
+
+			oil_object_impl::~oil_object_impl()
+			{
+				std::vector<object_parameter_impl*>::iterator p;
+
+				for(p = params.begin() ; p != params.end() ; p++)
+				{
+					delete (*p);
+				}
+			}
+
+			bool oil_object_impl::validate_object_parameter
+				(oil_definition::object_parameter_def *obj_param , bool *multiple ,
+						std::vector<object_ref> *references)
+			{
+				std::vector<object_parameter_impl*>::iterator match;
+				bool result = false;
+
+				// ¯¶¼OðÂp[^ª é©õ
+				// ¦find_if¾Æ_ELXgÉ¸sµ½
+				for(match = params.begin() ; match != params.end() ; match++)
+				{
+					if((*match)->validate_parameter_name(obj_param->get_parameter_name())
+						== true)
+					{
+						break;
+					}
+				}
+				
+				// p[^Ì®«`FbN
+				if(match != params.end())
+				{
+					parameter_object_ref_impl *ref_param;
+					parameter_enum_impl *enum_param;
+
+					ref_param = dynamic_cast<parameter_object_ref_impl*>(*match);
+					if(ref_param != NULL)
+					{
+						if(ref_param->validate_object_parameter(obj_param , references) == true)
+						{
+							*multiple = (*match)->get_multiple();
+							result = true;
+						}
+					}
+					else 
+					{
+						// enumÌêAqvfÅQÆªoÄ­éÂ\«ª é
+						enum_param = dynamic_cast<parameter_enum_impl*>(*match);
+						if(enum_param != NULL)
+						{
+							if(enum_param->validate_object_parameter(obj_param , references) == true)
+							{
+								*multiple = (*match)->get_multiple();
+								result = true;
+							}
+							else
+							{
+								// G[oÍÍvalidate_object_parameterÅsÁÄ¢é½ßsvD
+								//toppers::error("Object %1%'s parameter %2% can't set %3%." , 
+								//	obj_param->get_parent_name() , obj_param->get_parameter_name() , obj_param->get_value());
+							}
+						}
+						else
+						{
+							if((*match)->validate_object_parameter(obj_param) == true)
+							{
+								*multiple = (*match)->get_multiple();
+								result = true;
+							}
+							else
+							{
+								// G[oÍÍvalidate_object_parameterÅsÁÄ¢é½ßsvD
+								//toppers::error("Object %1%'s parameter %2% can't set %3%." , 
+								//	obj_param->get_parent_name() , obj_param->get_parameter_name() , obj_param->get_value());
+							}
+						}
+					}
+				}
+				else
+				{
+					// G[
+					toppers::error("Object %1% can't define parameter %2%." , 
+						obj_param->get_parent_name() , obj_param->get_parameter_name());
+				}
+
+				return result;
+			}
+
+			// î{p[^Ì`FbN
+			bool object_parameter_impl::validate_object_parameter
+					(oil_definition::object_parameter_def *obj , bool *auto_param)
+			{
+				// ¡è`ÍIuWFNgðÍ¤Åµ©s¦È¢
+				// ftHgè`©Ç¤©àIuWFNgÅµ©s¦È¢
+				set_parameter_type(obj);
+								
+				// AUTO®«Ì`FbN
+				if(obj->get_value() == "AUTO")
+				{
+					if(assign_auto == false)
+					{
+						toppers::error("Object %1% : %2% can't use \"AUTO\"" ,
+							obj->get_parent_name().c_str() , obj->get_parameter_name().c_str());
+						return false;
+					}
+					else
+					{
+						*auto_param = true;
+					}
+				}
+				else
+				{
+					*auto_param = false;
+				}
+
+				return true;
+			}
+			
+			template<typename T>
+			bool validate_number_paremeter
+			(VALUE_LIMIT_TYPE type ,T value , T min , T max , vector<T> *value_list)
+			{
+				bool result = true;
+				
+				if(type == LIMIT_RANGE)
+				{
+					if((value < min) || (value > max))
+					{
+						result = false;
+					}
+				}
+				else if(type == LIMIT_LIST)
+				{
+					std::vector<T>::iterator p;
+
+					// lÌXgÉ¶Ý·é©ðõ
+					p = find(value_list->begin() , value_list->end() , value);
+					if(p >= value_list->end())
+					{
+						result = false;
+					}
+				}
+				else
+				{
+					// `FbNÍKvÈ¢
+				}
+
+				return result;
+			}
+
+			template<typename T>
+			void val2string(std::vector<T> *list , std::string *str)
+			{
+				std::vector<T>::iterator p;
+
+				for(p = list->begin() ; p != list->end() ; p++)
+				{
+					try
+					{
+						*str += boost::lexical_cast<string>(*p) + " , ";
+					}
+					catch( ... )
+					{
+						toppers::error("cast error");
+					}
+				}
+			}
+
+			bool parameter_int_impl::validate_object_parameter
+					(oil_definition::object_parameter_def *obj)
+			{
+				bool result = false , assign_auto;
+				__int64 value;
+				
+				// î{®«Ì`FbN
+				if(object_parameter_impl::validate_object_parameter(obj , &assign_auto)
+					== false)
+				{
+					return false;
+				}
+
+				// AUTOp[^Èç·®É²¯é
+				if(assign_auto == true)
+				{
+					return true;
+				}
+
+				// lÉÏ·
+				if(obj->get_value().find("0x") != string::npos)
+				{
+					(void)sscanf_s(obj->get_value().c_str() , "0x%I64x" , &value);
+				}
+				else if(obj->get_value().find("0X") != string::npos)
+				{
+					(void)sscanf_s(obj->get_value().c_str() , "0X%I64x" , &value);
+				}
+				else
+				{
+					try
+					{
+						value = boost::lexical_cast<__int64>(obj->get_value());
+					}
+					catch(std::exception& exception)
+					{
+						toppers::error("%1%'s %2% is not INT16/INT32." , 
+							obj->get_parent_name() , obj->get_parameter_name());
+
+						return false;
+					}
+				}
+
+				if(validate_number_paremeter
+							(limit_type , value , min , max , &value_list) == false)
+				{
+					if(limit_type == LIMIT_RANGE)
+					{
+						toppers::error("Object %1%'s %2% is \"%3%\" not in range [%4% - %5%]" ,
+							obj->get_parent_name().c_str() , obj->get_parameter_name().c_str() ,
+							obj->get_value() , min , max);
+					}
+					else // if(limit_type == LIMIT_LIST)
+					{
+						std::string str;
+						val2string(&value_list , &str);
+						
+						toppers::error("Object %1%'s %2% is \"%3%\" not in range [%4% - %5%]" ,
+							obj->get_parent_name().c_str() , obj->get_parameter_name().c_str() ,
+							obj->get_value() , min , max);
+					}
+				}
+				else
+				{
+					result = true;
+				}
+
+				return result;
+			}
+
+			void parameter_int_impl::set_parameter_type(oil_definition::object_parameter_def *obj)
+			{
+				obj->set_type(TYPE_INT);
+			}
+
+			bool parameter_uint_impl::validate_object_parameter
+				(oil_definition::object_parameter_def *obj)
+			{
+				bool result = false , assign_auto;
+				unsigned __int64 value;
+				
+				// î{®«Ì`FbN
+				if(object_parameter_impl::validate_object_parameter(obj , &assign_auto)
+					== false)
+				{
+					return false;
+				}
+
+				// AUTOp[^Èç·®É²¯é
+				if(assign_auto == true)
+				{
+					return true;
+				}
+
+				// lÉÏ·
+				if(obj->get_value().find("0x") != string::npos)
+				{
+					(void)sscanf_s(obj->get_value().c_str() , "0x%I64x" , &value);
+				}
+				else if(obj->get_value().find("0X") != string::npos)
+				{
+					(void)sscanf_s(obj->get_value().c_str() , "0X%I64x" , &value);
+				}
+				else
+				{
+					try
+					{
+						value = boost::lexical_cast<unsigned __int64>(obj->get_value());
+					}
+					catch(std::exception& exception)
+					{
+						toppers::error("%1% : %2% is not UINT16/UINT32." , 
+							obj->get_parent_name() , obj->get_parameter_name());
+						return false;
+					}
+				}
+
+				if(validate_number_paremeter
+							(limit_type , value , min , max , &value_list) == false)
+				{
+					if(limit_type ==LIMIT_RANGE)
+					{
+						toppers::error("Object %1%'s %2% : %3% is not in range [%4% - %5%]" ,
+							obj->get_parent_name().c_str() , obj->get_parameter_name().c_str() ,
+							obj->get_value() , min , max);
+					}
+					else // if(limit_type == LIMIT_LIST)
+					{
+						std::string str;
+						val2string(&value_list , &str);
+
+						toppers::error("Object %1%'s %2% : %3% is not in range value list [%4%]" ,
+							obj->get_parent_name().c_str() , obj->get_parameter_name().c_str() ,
+							obj->get_value() , str);
+					}
+				}
+				else
+				{
+					result = true;
+				}
+
+				return result;
+			}
+
+			void parameter_uint_impl::set_parameter_type(oil_definition::object_parameter_def *obj)
+			{
+				obj->set_type(TYPE_UINT);
+			}
+
+			bool parameter_float_impl::validate_object_parameter
+				(oil_definition::object_parameter_def *obj)
+			{
+				bool result = false , assign_auto;
+				double value;
+				
+				// î{®«Ì`FbN
+				if(object_parameter_impl::validate_object_parameter(obj , &assign_auto)
+					== false)
+				{
+					return false;
+				}
+
+				// AUTOp[^Èç·®É²¯é
+				if(assign_auto == true)
+				{
+					return true;
+				}
+
+				// lÉÏ·
+				try
+				{
+					value = boost::lexical_cast<double>(obj->get_value().c_str());
+				}
+				catch(std::exception& exception)
+				{
+					toppers::error("%1% : %2% is not FLOAT." , 
+						obj->get_parent_name() , obj->get_parameter_name());
+
+					return false;
+				}
+
+				if(validate_number_paremeter
+							(limit_type , value , min , max , &value_list) == false)
+				{
+					if(limit_type ==LIMIT_RANGE)
+					{
+						toppers::error("Object %1%'s %2%  : %3% is not in range [%4% - %5%]" ,
+							obj->get_parent_name().c_str() , obj->get_parameter_name().c_str() ,
+							obj->get_value().c_str() , min , max);
+					}
+					else // if(limit_type == LIMIT_LIST)
+					{
+						std::string str;
+						val2string(&value_list , &str);
+
+						toppers::error("Object %1%' %2% : %3% is not in range value list [%4%]" ,
+							obj->get_parent_name().c_str() , obj->get_parameter_name().c_str() ,
+							obj->get_value().c_str() , str.c_str());
+					}
+				}
+				else
+				{
+					result = true;
+				}
+
+				return result;
+			}
+
+			void parameter_float_impl::set_parameter_type(oil_definition::object_parameter_def *obj)
+			{
+				obj->set_type(TYPE_FLOAT);
+			}
+
+			bool parameter_enum_impl::validate_object_parameter
+					(oil_definition::object_parameter_def *obj , std::vector<toppers::oil::object_ref> *object_refs)
+			{
+				std::map<std::string , oil_object_impl*>::iterator p;
+				bool result = true , assign_auto;
+
+				// î{®«Ì`FbN
+				if(object_parameter_impl::validate_object_parameter(obj , &assign_auto)
+					== false)
+				{
+					return false;
+				}
+
+				// AUTOp[^Èç·®É²¯é
+				if(assign_auto == true)
+				{
+					return true;
+				}
+
+				// p[^ªENUMÌXgÉ é©õ(½èj
+				std::vector<oil_definition::object_definition*>::iterator s;
+				std::string str;
+				bool hit = false;
+
+				for(p = sub_params.begin() ; p != sub_params.end(); p++)
+				{
+					// G[pÌXg
+					str += (*p).first + " , ";
+					// p[^¼ªêvµÄ¢È¯êÎæÌÍsíÈ¢
+					if(obj->get_value() == (*p).first)
+					{
+						hit = true;
+					}
+				}
+				// XgÉÈ©Á½êÌ
+				if(hit == false)
+				{
+					toppers::error("Object %1%'s %2% : %3% is not in range [%4%]" ,
+						obj->get_parent_name().c_str() , obj->get_parameter_name().c_str() , 
+						obj->get_value().c_str() , str);
+
+					return false;
+				}
+				
+				// Tup[^ÉÂ¢Äà`FbN
+				for(s = obj->get_subparams()->begin() ; s != obj->get_subparams()->end() ; s++)
+				{
+					for(p = sub_params.begin() ; p != sub_params.end(); p++)
+					{
+						/* ¯¼ÌÝèÌè`ð©Â¯½çÄAÅ¸ */
+						if((*s)->get_parent()->get_value() == (*p).first)
+						{
+							if((*p).second->validate_object_configuration((*s) , object_refs) == true)
+							{
+								result = true;
+							}
+						}
+					}
+					if(result == true)
+					{
+						break;
+					}
+				}
+				// ©Â©çÈ¯êÎG[
+				if((obj->get_subparams()->empty() == false)
+					&& (s == obj->get_subparams()->end()))
+				{
+					result = false;
+				}
+
+				return result;
+			}
+
+			bool parameter_object_ref_impl::validate_object_parameter
+					(oil_definition::object_parameter_def *obj , std::vector<toppers::oil::object_ref> *object_refs)
+			{
+				// î{®«Ì`FbN
+				// t@XæÌ`FbNà±±Ås¤×«¾ªA
+				// t@XæÌIuWFNgíÞðæ¾Å«È¢½ßãÅs¤
+				if(object_parameter_impl::validate_object_parameter(obj , &assign_auto)
+					== false)
+				{
+					return false;
+				}
+
+				// `FbN·é×«t@XÌãü
+				object_ref ref = { reftype_name , obj->get_value() };
+				object_refs->push_back(ref);
+
+				return true;
+			}
+
+			void parameter_string_impl::set_parameter_type
+					(oil_definition::object_parameter_def *obj)
+			{
+				obj->set_type(TYPE_STRING);
+			}
+
+			void parameter_boolean_impl::set_parameter_type
+					(oil_definition::object_parameter_def *obj)
+			{
+				obj->set_type(TYPE_BOOLEAN);
+			}
+		
+			void parameter_enum_impl::set_parameter_type(oil_definition::object_parameter_def *obj)
+			{
+				obj->set_type(TYPE_ENUM);
+			}
+
+			void parameter_object_ref_impl::set_parameter_type(oil_definition::object_parameter_def *obj)
+			{
+				obj->set_type(TYPE_REF);
+			}
+
+			bool oil_object_impl::validate_object_configuration
+					(oil_definition::object_definition * obj_def , std::vector<object_ref> *references)
+			{
+				std::vector<oil_definition::object_parameter_def*>::iterator p;
+				std::vector<oil_definition::object_parameter_def*> *obj_params;
+				std::vector<object_parameter_impl*>::iterator q;
+				std::vector<string> defined_parameter;
+				std::vector<object_parameter_impl*> undefined_parameter;
+				std::vector<string>::iterator found , s;
+				bool result = true;
+				bool multiple;
+
+				// IuWFNg¼ªÁÄ¢é©`FbN
+				if(name != obj_def->get_object_type())
+				{
+					return false;
+				}
+
+				// p[^Ì®«`FbN
+				obj_params = obj_def->get_params();
+				for(p = obj_params->begin() ; p != obj_params->end() ; p++)
+				{
+					if(validate_object_parameter(*p , &multiple , references) == false)
+					{
+						result = false;
+					}
+
+					// ¡è`Â\©Ì`FbN
+					if(((found = find(defined_parameter.begin() , defined_parameter.end() , 
+						(*p)->get_parameter_name())) != defined_parameter.end())
+							&& (multiple == false))
+					{
+						toppers::error("Object %1% : %2% can define once." ,
+							obj_def->get_name().c_str() , (*p)->get_parameter_name().c_str());
+
+						result = false;
+					}
+					else
+					{
+						defined_parameter.push_back((*p)->get_parameter_name());
+					}
+				}
+
+				if(result == true)
+				{
+					//
+					// ftHgp[^Ìâ®
+					//
+
+					// IuWFNgè`ÉLÚ³êÄ¢È¢p[^ÌTõ
+					for(q = params.begin() ; q != params.end() ; q++)
+					{
+						s = find(defined_parameter.begin() , 
+							defined_parameter.end() , (*q)->get_name());
+
+						if(s == defined_parameter.end())
+						{
+							undefined_parameter.push_back((*q));
+						}
+					}
+
+					// Tõµ½p[^ÉÎµÄÌftHgp[^Ìâ®
+					for(q = undefined_parameter.begin() ; q != undefined_parameter.end() ; q++)
+					{
+						string default_value;
+						DEFAULT_TYPE deftype = (*q)->get_default(&default_value);
+
+						if((deftype == HAVE_DEFAULT)
+							|| (deftype == AUTO))
+						{
+							obj_def->add_parameter((*q)->get_name() , default_value);
+						}
+						else if(deftype == NO_DEFAULT)
+						{
+							toppers::error("Object %1% : Parmeter %2% is not defined. %2% doesn't have default value." ,
+								obj_def->get_name().c_str() , (*q)->get_name().c_str());
+
+							result = false;
+						}
+						else	/* deftype == HAVE_NOT_DEFINE */
+						{
+						}
+
+					}
+				}
+
+				return result;
+			}
+
+			bool parameter_string_impl::validate_object_parameter
+					(oil_definition::object_parameter_def *obj)
+			{
+				// ¶®«ÍÁÉ§ñªÈ¢½ßíÉtrue
+				return true;
+			}
+			
+			bool parameter_boolean_impl::validate_object_parameter
+					(oil_definition::object_parameter_def *obj)
+			{
+				// TRUE©FALSEÅÈ¢ÆÈçÈ¢
+				if((obj->get_value() == "TRUE")
+					|| (obj->get_value() == "FALSE"))
+				{
+					return true;
+				}
+
+				toppers::error("Object %1%'s %2% is \"%3%\" , but can not set [TRUE , FALSE , ]." ,
+					obj->get_parent_name() , obj->get_parameter_name() , obj->get_value());
+
+				return false;
+			}
+
+			void oil_object_impl::display_implementation(void)
+			{
+				std::vector<object_parameter_impl*>::iterator p;
+				
+				cout << "=========== Object Name : " << name << "===========" << endl << endl;
+				for(p = params.begin() ; p != params.end() ; p++)
+				{
+					(*p)->display_implementation();
+				}
+				cout << endl << "==================================" << endl;
+				
+			}
+
+			void object_parameter_impl::set_parameter_type
+					(oil_definition::object_parameter_def *obj)
+			{
+				obj->set_type(TYPE_UNKNOWN);
+			}
+		}
+
+		namespace oil_definition
+		{
+			object_definition* find_object(string name)
+			{
+				return NULL;
+			}
+			
+			int object_definition::add_parameter(string param_name , string param_value)
+			{
+				try
+				{
+					object_parameter_def* param_def =
+						new object_parameter_def(param_name , param_value , name);
+					params.push_back(param_def);
+				}
+				catch(...)
+				{
+					// G[
+				}
+
+				return 0;
+			}
+
+			object_definition::~object_definition()
+			{
+				std::vector<object_parameter_def*>::iterator p;
+
+				for(p = params.begin() ; p != params.end() ; p++)
+				{
+					delete (*p);
+				}
+			}
+
+			void object_definition::display_definition(void)
+			{
+				std::vector<object_parameter_def*>::iterator p;
+				
+				for(p = params.begin() ; p != params.end() ; p++)
+				{
+					(*p)->display_definition();
+				}
+				cout << endl << endl;
+			}
+
+			
+		/*!
+		 *  \brief  IuWFNgIDÔÌt¯
+		 *  \param[in]  api_map   \[XÉLq³ê½ÃIAPIðo^µ½Rei
+		 */
+		void assign_id( cfg_obj_map obj_def_map , long fixed_id)
+		{
+		  using namespace toppers;
+		  using namespace toppers::oil::oil_definition;
+
+		  std::map<std::string, std::vector< object_definition* >>::iterator p;
+		  std::vector<object_definition*>::iterator q;
+		  int serial;
+
+		  for(p = obj_def_map.begin() ; p != obj_def_map.end() ; p++)
+		  {
+			  serial = 0;
+			  // IuWFNg²ÆÉIDÄ
+			  for(q = (*p).second.begin() ; q != (*p).second.end() ; q++)
+			  {
+				  if(fixed_id == UINT_MAX)
+				  {
+					(*q)->set_id(serial++);
+				  }
+				  else
+				  {
+					(*q)->set_id(fixed_id);
+				  }
+			  }
+		  }
+
+		}
+
+		cfg_obj_map merge(std::vector<object_definition*> *obj_defs , 
+				cfg_obj_map& out , string prefix , string suffix , long fixed_id)
+		{
+		  std::vector<object_definition*>::iterator p , q;
+		  std::vector<object_definition*> *sub_objects;
+		  std::vector<object_parameter_def*>::iterator r;
+		  std::vector<object_parameter_def*> *subparams;   
+		  
+		  for(p = obj_defs->begin() ; p != obj_defs->end() ; p++)
+		  {
+			  string s(prefix + (*p)->get_object_type() + suffix);
+			  out[ s ].push_back(*p);
+		  }
+
+		  // IDðêxt¯é
+		  assign_id(out , fixed_id);
+
+		  for(p = obj_defs->begin() ; p != obj_defs->end() ; p++)
+		  {
+			  long id;
+			  subparams = (*p)->get_params();
+			  // Tup[^ào^
+			  for(r = subparams->begin() ; r != subparams->end() ; r++)
+			  {
+				  sub_objects = (*r)->get_subparams();
+	   			  id = (*p)->get_id();
+
+				  string s = "." + (*r)->get_value();
+
+				  // Tup[^ÌÂ®«ÍÄAÅo^·é
+				  if(sub_objects->empty() == false)
+				  {
+					  cfg_obj_map temp;
+					  std::string subparam_name = 
+						  (*p)->get_object_type() + ".";
+					  temp = merge(sub_objects , temp , subparam_name , s , id);
+
+					  // ÊðRs[(¿å¤Ç¢¢\bhª³¢)
+					  std::map< std::string, std::vector< object_definition* >>::iterator x;
+					  for(x = temp.begin() ; x != temp.end() ; x++ )
+					  {
+						  std::vector< object_definition* >::iterator y;
+						  for(y = (*x).second.begin() ; y != (*x).second.end() ; y++)
+						  {
+							  out[(*x).first].push_back((*y));
+						  }
+						  //out[(*x).first] = (*x).second;
+						  //out[(*x).first].push_back((*x).second);
+					  }
+				  }
+			  }
+		  }
+
+		  return out;
+		}
+		}
+	}	/* oil */
+
+}
Index: /cfg_oil/trunk/toppers/oil/oil_object.hpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/oil_object.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/oil_object.hpp	(revision 8)
@@ -0,0 +1,956 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2010 by Meika Sugimoto
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+#ifndef OIL_OBJECT_H
+#define OIL_OBJECT_H
+
+#include <string.h>
+#include <vector>
+#include <map>
+#include <algorithm>
+#include <boost/regex.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include "toppers/diagnostics.hpp"
+
+using namespace std;
+
+namespace toppers
+{
+	namespace oil
+	{
+		extern void dump(boost::smatch *r);
+
+		namespace oil_definition
+		{
+			// NXÌOûé¾
+			class object_parameter_def;
+			class object_definition;
+		}
+
+		// p[^^Cv
+		enum PARAMETER_TYPE
+		{
+			TYPE_UINT = 1 ,
+			TYPE_INT ,
+			TYPE_FLOAT ,
+			TYPE_STRING ,
+			TYPE_BOOLEAN ,
+			TYPE_ENUM , 
+			TYPE_REF ,
+			TYPE_UNKNOWN
+		};
+
+		typedef struct
+		{
+			string obj_type;
+			string obj_name;
+		} object_ref;
+
+		namespace oil_implementation
+		{
+
+			// NXÌOûé¾
+			class object_parameter_impl;
+			
+			class oil_object_impl
+			{
+				public:
+					oil_object_impl(string object_name)
+					{
+						name = object_name;
+					}
+					~oil_object_impl();
+					int add_parameter(string param_name , string parameter_descripition);
+					bool validate_object_configuration
+							(oil_definition::object_definition* obj_def , std::vector<object_ref> *references);
+					void display_implementation(void);
+				private:
+					bool oil_object_impl::validate_object_parameter
+						(oil_definition::object_parameter_def *obj_param , bool *multiple ,
+								std::vector<object_ref> *references);
+					string name;
+					std::vector<object_parameter_impl*> params;
+			};
+
+			// l§ÀÌíÞ
+			enum VALUE_LIMIT_TYPE
+			{
+				LIMIT_RANGE = 1 ,
+				LIMIT_LIST ,
+				LIMIT_NONE
+			};
+			// ftHglÌíÞ
+			enum DEFAULT_TYPE
+			{
+				NO_DEFAULT = 1 ,
+				AUTO ,
+				HAVE_DEFAULT ,
+				HAVE_NOT_DEFINE
+			};
+
+			class object_parameter_impl
+			{
+				public:
+					object_parameter_impl(string param_name)
+					{
+						name = param_name;
+					}
+					object_parameter_impl(string param_name , string parameter_description)
+					{
+						name = param_name;
+
+						// AUTO®«ÌðÍ
+						if(parameter_description.find("WITH_AUTO") != string::npos)
+						{
+							assign_auto = true;
+						}
+						else
+						{
+							assign_auto = false;
+						}
+
+						/// ENUMÌÆ«Éâè è
+						// ¡è`L³ÌðÍ
+						boost::regex brace("\\[\\s*\\]\\s*(=.+)?;");
+						if(boost::regex_search(parameter_description , brace))
+						{
+							multiple = true;
+						}
+						else
+						{
+							multiple = false;
+						}
+						
+						// ftHglÌðÍ
+						boost::regex default_value("=\\s+(\\S+)\\s*;");
+						boost::smatch result;
+						string::const_iterator start = parameter_description.begin();
+						string::const_iterator end = parameter_description.end();
+						if(boost::regex_search(start , end , result , default_value))
+						{
+							default_description = result.str(1);
+							if(default_description == "AUTO")
+							{
+								default_type = AUTO;
+							}
+							else if(default_description == "NO_DEFAULT")
+							{
+								default_type = NO_DEFAULT;
+							}
+							else
+							{
+								default_type = HAVE_DEFAULT;
+							}
+						}
+						else
+						{
+							default_type = HAVE_NOT_DEFINE;
+							default_description.erase(0);
+						}
+					}
+
+					string get_name(void)
+					{
+						return name;
+					}
+
+					DEFAULT_TYPE get_default(string *str)
+					{
+						if((default_type == HAVE_DEFAULT)
+							|| (default_type == AUTO))
+						{
+							*str = default_description;
+						}
+
+						return default_type;
+					}
+
+					virtual void display_implementation(void)
+					{
+						cout << "Parameter Name : " << name << endl;
+						cout << "Multilple : " << ((multiple == true)? "Yes" : "No") << endl;
+						cout << "Auto Assignment : " << ((assign_auto == true)? "Yes" : "No") << endl;
+						cout << "Default Value : ";
+						if(default_type == NO_DEFAULT)
+						{
+							cout << "NO_DEFAULT";
+						}
+						else if(default_type == AUTO)
+						{
+							cout << "AUTO";
+						}
+						else
+						{
+							cout << "HAVE_DEFAULT";
+						}
+						cout << endl;
+					}
+
+					virtual bool validate_parameter_name(string param_name)
+					{
+						if(name == param_name)
+						{
+							return true;
+						}
+						else
+						{
+							return false;
+						}
+					}
+
+					bool validate_object_parameter
+							(oil_definition::object_parameter_def *obj , bool *auto_param);
+					virtual bool object_parameter_impl::validate_object_parameter
+							(oil_definition::object_parameter_def *obj)
+					{
+						return false;
+					}
+					virtual void set_parameter_type(oil_definition::object_parameter_def *obj);
+
+					bool get_multiple(void)
+					{
+						return multiple;
+					}
+				protected:
+					inline const char* return_format(double x , int type)
+					{
+						return "%lf";
+					}
+
+					inline const char* return_format(__int64 x , int type)
+					{
+						if(type == 0)
+						{
+							return "%I64x";
+						}
+						else
+						{
+							return "%I64d";
+						}
+					}
+
+					inline const char* return_format(unsigned __int64 x , int type)
+					{
+						if(type == 0)
+						{
+							return "%I64x";
+						}
+						else
+						{
+							return "%I64u";
+						}
+					}
+
+					template <typename T>
+					T str2val(const char *str , T dummy)
+					{
+						T temp;
+						T zero = 0 , one = 1;
+						if((str[0] == '0') && ((str[1] == 'x') || (str[1] == 'X')))
+						{
+							sscanf_s(&str[2] , return_format(zero , 0) , &temp);
+						}
+						else
+						{
+							sscanf_s(&str[0] , return_format(zero , 1) , &temp);
+						}
+						return temp;
+					}
+
+					template <typename T>
+					void split_number_list(const char *str , std::vector<T> *list)
+					{
+						const char *p = str;
+						char val[32];
+						int i;
+						T zero = 0;
+					
+						// XgððÍ
+						do
+						{
+							i = 0;
+							// Xy[XðÆÎ·
+							while(*p == ' ')
+							{
+								p++;
+							}
+							// lªÌðÍ
+							while(*p != ' ' && (*p != '\0'))
+							{
+								val[i++] = *p++;
+							}
+							// ãëÌXy[XÆJ}àÆÎ·
+							while((*p == ' ') || (*p == ','))
+							{
+								p++;
+							}
+							// lÌðÍÆXgÖÌ}ü
+							val[i] = '\0';
+							list->push_back((T)str2val(val , zero));
+						}while(*p != '\0');
+					}
+
+					template <class T , typename Y>
+					void dump_limit_value(T* obj)
+					{
+						if(obj->limit_type == LIMIT_RANGE)
+						{
+							cout << "Min value : " << obj->min << endl;
+							cout << "Max value : " << obj->max << endl;
+						}
+						else if(obj->limit_type == LIMIT_LIST)
+						{
+							std::vector<Y>::iterator p;
+
+							cout << "Limit value : ";
+							for(p = obj->value_list.begin() ; p != obj->value_list.end() ; p++)
+							{
+								cout << *p << ",";
+							}
+							cout << endl;
+						}
+						else
+						{
+							cout << "Limit value : None" << endl;
+						}
+
+						if(obj->default_type == HAVE_DEFAULT)
+						{
+							cout << "Default value : " << obj->default_value << endl;
+						}
+						cout << endl;
+					}
+					
+					int id;
+					string name;
+					bool multiple;
+					string default_description;
+					bool assign_auto;
+					DEFAULT_TYPE default_type;
+			};
+			
+			// INT^iINT32,INT64)
+			class parameter_int_impl : public object_parameter_impl
+			{
+				friend class object_parameter_impl;
+
+				public:
+					parameter_int_impl(string param_name , string parameter_description)
+						: object_parameter_impl(param_name , parameter_description)
+					{
+						// §ÀlÌp[X
+						boost::regex limit_list("\\[\\s*((\\w)+(\\s*,\\s*\\w+)*)\\s*\\]");
+						boost::regex limit_range("\\[\\s*(\\w+)\\s*\\.\\.\\s*(\\w+)\\s*\\]");
+						string::const_iterator start = parameter_description.begin();
+						string::const_iterator end = parameter_description.end();
+						boost::smatch result;
+						
+						// Xg`®©Ì`FbN
+						if(boost::regex_search(start , end , result , limit_list))
+						{
+							limit_type = LIMIT_LIST;
+							string str = result.str(1);
+							split_number_list(str.c_str() , &value_list);
+						}
+						// W`®©Ì`FbN
+						else if(boost::regex_search(start , end , result , limit_range))
+						{
+							limit_type = LIMIT_RANGE;
+							string str;
+
+							// Å¬l
+							str = result.str(1);
+							min = str2val(str.c_str() , (__int64)0);
+							// Åål
+							str = result.str(2);
+							max = str2val(str.c_str() , (__int64)0);
+						}
+						else
+						{
+							min = 0;
+							if(parameter_description.find("INT32") != string::npos)
+							{
+								max = INT_MAX;
+							}
+							else
+							{
+								max = _I64_MAX;
+							}
+							limit_type = LIMIT_RANGE;
+						}
+
+						// ftHglÌZo
+						if(default_type == HAVE_DEFAULT)
+						{
+							default_value = str2val(default_description.c_str() , (__int64)0);
+						}
+					}
+					virtual void display_implementation(void)
+					{
+						cout << "Parameter types : INT" << endl;
+						object_parameter_impl::display_implementation();
+						dump_limit_value<parameter_int_impl , __int64>(this);
+					}
+					bool validate_object_parameter(oil_definition::object_parameter_def *obj);
+					void set_parameter_type(oil_definition::object_parameter_def *obj);
+				protected:
+					VALUE_LIMIT_TYPE limit_type;
+					std::vector<__int64> value_list;
+					__int64 default_value;
+					__int64 max;
+					__int64 min;
+			};
+
+			// UINT^iUINT32,UINT64)
+			class parameter_uint_impl : public object_parameter_impl
+			{
+				friend class object_parameter_impl;
+
+				public:
+					parameter_uint_impl(string param_name , string parameter_description)
+						: object_parameter_impl(param_name , parameter_description)
+					{
+						// §ÀlÌp[X
+						boost::regex limit_list("\\[\\s*((\\w)+(\\s*,\\s*\\w+)*)\\s*\\]");
+						boost::regex limit_range("\\[\\s*(\\w+)\\s*\\.\\.\\s*(\\w+)\\s*\\]");
+						string::const_iterator start = parameter_description.begin();
+						string::const_iterator end = parameter_description.end();
+						boost::smatch result;
+						
+						// Xg`®©Ì`FbN
+						if(boost::regex_search(start , end , result , limit_list))
+						{
+							limit_type = LIMIT_LIST;
+							string str = result.str(1);
+							split_number_list(str.c_str() , &value_list);
+						}
+						// W`®©Ì`FbN
+						else if(boost::regex_search(start , end , result , limit_range))
+						{
+							limit_type = LIMIT_RANGE;
+							string str;
+
+							// Å¬l
+							str = result.str(1);
+							min = str2val(str.c_str() , (unsigned __int64)0);
+							// Åål
+							str = result.str(2);
+							max = str2val(str.c_str() , (unsigned __int64)0);
+						}
+						else
+						{
+							min = 0;
+							if(parameter_description.find("UINT32") != string::npos)
+							{
+								max = UINT_MAX;
+							}
+							else
+							{
+								max = _UI64_MAX;
+							}
+							limit_type = LIMIT_RANGE;
+						}
+						// ftHglÌZo
+						if(default_type == HAVE_DEFAULT)
+						{
+							default_value = str2val(default_description.c_str() , (unsigned __int64)0);
+						}				
+					}
+
+					virtual void display_implementation(void)
+					{
+						cout << "Parameter types : UINT" << endl;
+						object_parameter_impl::display_implementation();
+						dump_limit_value<parameter_uint_impl , unsigned __int64>(this);
+					}
+					bool validate_object_parameter(oil_definition::object_parameter_def *obj);
+					void set_parameter_type(oil_definition::object_parameter_def *obj);
+				protected:
+					VALUE_LIMIT_TYPE limit_type;
+					std::vector<unsigned __int64> value_list;
+					unsigned __int64 max;
+					unsigned __int64 min;
+					unsigned __int64 default_value;
+			};
+			
+			// FLOAT^iFLOAT)
+			class parameter_float_impl : public object_parameter_impl
+			{
+				friend class object_parameter_impl;
+
+				public:
+					parameter_float_impl(string param_name , string parameter_description)
+							: object_parameter_impl(param_name , parameter_description)
+					{
+						// §ÀlÌp[X
+						boost::regex limit_list("\\[\\s*((\\w(\\.\\w+)?)+(\\s*,\\s*\\w+(\\.\\w+)?)*)\\s*\\]");
+						boost::regex limit_range("\\[\\s*(\\w+(\\.\\w+)?)\\s*\\.\\.\\s*(\\w+(\\.\\w+)?)\\s*\\]");
+						string::const_iterator start = parameter_description.begin();
+						string::const_iterator end = parameter_description.end();
+						boost::smatch result;
+						
+						// Xg`®©Ì`FbN
+						if(boost::regex_search(start , end , result , limit_list))
+						{
+							limit_type = LIMIT_LIST;
+							string str = result.str(1);
+							split_number_list(str.c_str() , &value_list);
+						}
+						// W`®©Ì`FbN
+						else if(boost::regex_search(start , end , result , limit_range))
+						{
+							limit_type = LIMIT_RANGE;
+							string str;
+
+							// Å¬l
+							str = result.str(1);
+							min = str2val(str.c_str() , (double)0);
+							// Åål
+							str = result.str(3);
+							max = str2val(str.c_str() , (double)0);
+						}
+						else
+						{
+							limit_type = LIMIT_NONE;
+						}
+						// ftHglÌZo
+						if(default_type == HAVE_DEFAULT)
+						{
+							default_value = str2val(default_description.c_str() , (double)0);
+						}			
+					}
+					virtual void display_implementation(void)
+					{
+						cout << "Parameter types : FLOAT" << endl;
+						object_parameter_impl::display_implementation();
+						dump_limit_value<parameter_float_impl , double>(this);
+					}
+					bool validate_object_parameter(oil_definition::object_parameter_def *obj);
+					void set_parameter_type(oil_definition::object_parameter_def *obj);
+				protected:
+					VALUE_LIMIT_TYPE limit_type;
+					std::vector<double> value_list;
+					double max;
+					double min;
+					double default_value;
+			};
+			
+			// STRING^
+			class parameter_string_impl : public object_parameter_impl
+			{
+				public:
+					parameter_string_impl(string param_name , string parameter_description)
+							: object_parameter_impl(param_name , parameter_description)
+					{
+						// ftHglÌãü
+						if(default_type == HAVE_DEFAULT)
+						{
+							default_value = default_description;
+						}			
+					}
+
+					virtual void display_implementation(void)
+					{
+						cout << "Parameter types : STRING" << endl;
+						object_parameter_impl::display_implementation();
+						if(default_type == HAVE_DEFAULT)
+						{
+							cout << "Default value : " << default_value << endl;
+						}		
+					}
+					virtual bool validate_object_parameter
+							(oil_definition::object_parameter_def *obj);
+					virtual void set_parameter_type(oil_definition::object_parameter_def *obj);
+				protected:
+					string default_value;
+			};
+
+			// BOOLEAN^
+			class parameter_boolean_impl : public parameter_string_impl
+			{
+				public:
+					parameter_boolean_impl(string param_name , string parameter_description)
+						: parameter_string_impl(param_name , parameter_description)
+					{
+					}
+					virtual bool validate_object_parameter
+							(oil_definition::object_parameter_def *obj);
+					virtual void set_parameter_type(oil_definition::object_parameter_def *obj);
+			};
+
+			// ENUM^
+			class parameter_enum_impl : public object_parameter_impl
+			{
+				public:
+					parameter_enum_impl(string param_name , string parameter_description)
+							: object_parameter_impl(param_name , parameter_description)
+					{
+						boost::regex enum_description("(\\w+\\s+[^;]+);(\\s*(.+)\\s)*");
+						boost::regex enum_parse("(\\w+\\s+\\[)?\\s*((\\w+)\\s*(\\{([^\\{\\}]*)\\})?)(\\s*,\\s*(.+))*");
+						boost::regex subparam_name("([^\\[\\]\\s]+)\\s+((WITH_AUTO)?\\s+(\\[.+\\])?)?([^\\[\\]\\s]+)");
+						boost::regex space("\\s*");
+						string::const_iterator start = parameter_description.begin();
+						string::const_iterator end = parameter_description.end();
+						boost::smatch result;
+						toppers::oil::oil_implementation::oil_object_impl *sub_impl;
+						string name;
+
+						// 1Â¸Âp[^ðØèª¯Ä
+						while(boost::regex_search(start , end , result , enum_parse))
+						{
+							string temp = result.str(5);
+							string::const_iterator start2 = temp.begin();
+							string::const_iterator end2 = temp.end();
+							boost::smatch result2;
+
+							try
+							{
+								/// try catch
+								sub_impl = new oil_object_impl(param_name);
+								name = result.str(3);
+								// p[^ÌØèª¯
+								while(boost::regex_search(start2 , end2 , result2 , enum_description))
+								{
+									string temp2 = result2.str(1);
+									string::const_iterator start3 = temp2.begin();
+									string::const_iterator end3 = temp2.end();
+									boost::smatch result3;
+									// p[^¼Ìo
+									(void)boost::regex_search(start3 , end3 , result3 , subparam_name);
+									
+									sub_impl->add_parameter(result3.str(5) , result2.str(1) + ";");
+									// p[^ªÈ­ÈÁ½ç[vð²¯é
+									if(boost::regex_match(result2.str(3) , space))
+									{
+										break;
+									}
+									temp.erase(0 , temp.find(result2.str(3)));
+									end2 = temp.end();
+								}
+
+								// ReiÖÌo^
+								sub_params.insert(pair<string , oil_object_impl*>(name , sub_impl));
+
+								// p[^ªÈ­ÈÁ½ç[vð²¯é
+								if(boost::regex_match(result.str(7) , space))
+								{
+									break;
+								}
+								parameter_description.erase(0 , parameter_description.find(result.str(7)));
+								end = parameter_description.end();
+							}
+							catch( ... )
+							{
+								toppers::fatal("Memory allocation error.");
+							}
+						}
+					}
+
+					~parameter_enum_impl()
+					{
+						std::map<std::string , oil_object_impl*>::iterator p;
+
+						for(p = sub_params.begin() ; p != sub_params.end() ; p++)
+						{
+							delete (*p).second;
+						}
+					}
+
+					virtual void display_implementation(void)
+					{
+						std::map<std::string , oil_object_impl*>::iterator p;
+
+						cout << "Parameter types : ENUM" << endl;
+						object_parameter_impl::display_implementation();
+
+						cout << "-------------- Sub parameters --------------" << endl;
+						for(p = sub_params.begin() ; p != sub_params.end() ; p++)
+						{
+							cout << "Sub param name : " << (*p).first << endl;
+							(*p).second->display_implementation();
+						}
+						cout << "--------------------------------------------" << endl;
+
+					}
+
+					bool validate_object_parameter(oil_definition::object_parameter_def *obj , 
+									std::vector<toppers::oil::object_ref> *object_refs);
+					void set_parameter_type
+						(oil_definition::object_parameter_def *obj);
+				protected:
+					std::map<std::string , oil_object_impl*> sub_params;
+			};
+
+			// QÆ^
+			class parameter_object_ref_impl : public object_parameter_impl
+			{
+				public:
+					parameter_object_ref_impl(string param_name , string parameter_description)
+							: object_parameter_impl(param_name , parameter_description)
+					{
+						// QÆ·éIuWFNg¼Ìo
+						boost::regex ref_type("(\\w+)_TYPE");
+						string::const_iterator start = parameter_description.begin();
+						string::const_iterator end = parameter_description.end();
+						boost::smatch result;
+
+						if(boost::regex_search(start , end , result , ref_type))
+						{
+							reftype_name = result.str(1);
+						}
+						/// ftHglÌÇÝÝ
+					}
+					virtual void display_implementation(void)
+					{
+						cout << "Parameter types : OBJECT REF" << endl;
+						object_parameter_impl::display_implementation();
+						cout << "Reference Type : " << reftype_name << endl << endl;
+					}
+
+					bool validate_object_parameter
+							(oil_definition::object_parameter_def *obj , std::vector<toppers::oil::object_ref> *object_refs);
+					void set_parameter_type(oil_definition::object_parameter_def *obj);
+				protected:
+					string reftype_name;
+			};
+		}
+
+		namespace oil_definition
+		{
+			// IuWFNgè`ÌNX
+			class object_definition
+			{
+				public:
+					object_definition(string object_name_type , object_parameter_def* parent = NULL)
+					{
+						boost::regex object_declaration("(\\w+)\\s+([\\w\\.]+)");
+						string::const_iterator start = object_name_type.begin();
+						string::const_iterator end = object_name_type.end();
+						boost::smatch result;
+
+						// Ñt¯çêÄ¢ép[^ÖÌ|C^ði[
+						parent_parameter = parent;
+						// ^CvÆl[ðp[XµÄi[
+						if(boost::regex_match(start , end , result , object_declaration))
+						{
+							object_type = result.str(1);
+							name = result.str(2);
+						}
+						else
+						{
+							/*  è¦È¢ */
+						}
+					}
+
+					~object_definition();
+
+					int add_parameter(string param_name , string param_value);
+
+					string get_object_type(void)
+					{
+						return object_type;
+					}
+
+					std::vector<object_parameter_def*>* get_params(void)
+					{
+						return &params;
+					}
+					void display_definition(void);
+					void set_id(int obj_id)
+					{
+						id = obj_id;
+					}
+					int get_id(void)
+					{
+						return id;
+					}
+					std::string get_name(void)
+					{
+						return name;
+					}
+					object_parameter_def* get_parent(void)
+					{
+						return parent_parameter;
+					}
+
+				private:
+					int id;
+					string name;
+					string object_type;
+					std::vector<object_parameter_def*> params;
+					object_parameter_def* parent_parameter;
+			};
+
+			// IuWFNgè`p[^Ìî{NX
+			class object_parameter_def
+			{
+				public:
+					object_parameter_def(string def_name , string def_value , string parent)
+					{
+						boost::regex have_subparam("(\\w+)\\s*\\{\\s*(([^\\{\\}])+)\\s*\\}");
+						string::const_iterator start = def_value.begin();
+						string::const_iterator end = def_value.end();
+						boost::smatch result;
+
+						name = def_name;
+						parent_name = parent;
+
+						// Tup[^ª éêÍ³çÉªð
+						if(boost::regex_search(start , end , result , have_subparam))
+						{
+							string type_name;
+							object_definition *subparam;
+
+							value = result.str(1);
+
+							type_name = result.str(1) + " SUBPARAM";
+
+							// Tup[^ði[·éIuWFNgð¶¬
+							try
+							{
+								subparam = new object_definition(name + " " + name , this);
+							}
+							catch( std::bad_alloc )
+							{
+								toppers::fatal("Memory allocation error.");
+							}
+
+							boost::regex subparam_regex("((\\w+)\\s*=\\s*([\\w\"]+\\s*(\\{\\s*[^\\{\\}]\\s*\\})?));(.+)");
+							boost::regex space("\\s*");
+							string temp = result.str(2);
+							string::const_iterator start2 = temp.begin();
+							string::const_iterator end2 = temp.end();
+							boost::smatch result2;
+
+							while(boost::regex_search(start2 , end2  , result2 , subparam_regex))
+							{
+								subparam->add_parameter(result2.str(2) , result2.str(3));
+
+								// ªðµIíÁ½ç²¯é
+								if(boost::regex_match(result2.str(5) , space))
+								{
+									break;
+								}
+								temp.erase(0 , temp.find(result2.str(5)));
+								end2 = temp.end();
+							}
+							// ReiÉÇÁ
+							subparams.push_back(subparam);
+						}
+						else
+						{
+							value = def_value;
+						}
+					}
+
+					~object_parameter_def()
+					{
+						std::vector<object_definition*>::iterator p;
+
+						for(p = subparams.begin() ; p != subparams.end() ; p++)
+						{
+							delete (*p);
+						}
+					}
+
+					string get_parameter_name(void)
+					{
+						return name;
+					}
+
+					string get_value(void)
+					{
+						return value;
+					}
+
+					string get_parent_name(void)
+					{
+						return parent_name;
+					}
+
+					std::vector<object_definition*>* get_subparams(void)
+					{
+						return &subparams;
+					}
+
+					void display_definition(void)
+					{
+						std::vector<object_definition*>::iterator p;
+
+						cout <<  "\tName : " << name << " Value : " << value << endl;
+						for(p = subparams.begin(); p != subparams.end(); p++)
+						{
+							cout << "\t";
+							(*p)->display_definition();
+						}
+					}
+					void set_type(PARAMETER_TYPE param_type)
+					{
+						type = param_type;
+					}
+					PARAMETER_TYPE get_type(void)
+					{
+						return type;
+					}
+
+				protected:
+					string name;
+					string value;
+					string parent_name;
+					PARAMETER_TYPE type;
+					std::vector<object_definition*> subparams;
+			};
+
+			typedef std::map< std::string, std::vector< object_definition* > > cfg_obj_map;
+			cfg_obj_map merge(std::vector<object_definition*> *obj_defs ,
+				cfg_obj_map& out , string prefix = string("") ,  
+				string suffix = string("")  , long fixed_id = UINT_MAX);
+			void assign_id(cfg_obj_map obj_defs  , long fixed_id = UINT_MAX);
+
+		}	/* oil_definition */
+
+
+	}	/* oil */
+}
+
+
+#endif	/* OIL_OBJECT_H */
Index: /cfg_oil/trunk/toppers/oil/oil_parse.cpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/oil_parse.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/oil_parse.cpp	(revision 8)
@@ -0,0 +1,229 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2010 by Meika Sugimoto
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+#include <string>
+#include <iostream>
+
+#include "toppers/oil/oil_parser.hpp"
+#include "toppers/diagnostics.hpp"
+
+using namespace std;
+using namespace boost::spirit;
+using namespace toppers::oil;
+using namespace toppers::oil::oil_implementation;
+using namespace toppers::oil::oil_definition;
+
+
+int oil_parser::do_parse(oil_impl **impl , oil_def **def)
+{
+	oil_grammer grammer(this);
+	parse_info<> info;
+	
+	info = parse(description->c_str() , grammer , space_p);
+	if(info.hit)
+	{
+		*impl = &impl_list;
+		*def = &def_list;
+		return 0;
+	}
+	else
+	{
+		return -1;
+	}
+}
+
+void eval_tree(tree_match<char const *>::tree_iterator const &iter, int nest) {
+	int size; // m[hÌqÌÂ
+	
+	size = iter->children.size(); // m[hÌqÌÂðæèo·
+	for(int i=0; i<nest; i++)
+	{
+		cout << "  "; // Xy[XQÂªCfg
+	}
+	cout << "Node = '" << string(iter->value.begin(), iter->value.end()) << "'";
+	if (size > 0)
+	{
+		cout << " Child Size = " << size << endl; // qÌÂð\¦
+	} else
+	{
+		cout << endl;                             // qª³¯êÎÂ\¦µÈ¢
+	}
+	for(int j=0; j<size; j++)
+	{
+		eval_tree(iter->children.begin()+j, nest+1); // qÌÂªÄAÄÑoµ
+	}
+}
+
+int oil_parser::start_objimpl_analysis(std::string object_name)
+{
+	int result = 0;
+
+	try
+	{
+		// \¬ÌIuWFNgÀðÛ¶
+		current_impl = new oil_object_impl(object_name);
+	}
+	catch( ... )
+	{
+		result = -1;
+	}
+	
+	return result;
+}
+
+int oil_parser::set_nextparam_name(std::string name)
+{
+	if(param_addable == true)
+	{
+		next_param_name = name;
+	}
+
+	return 0;
+}
+
+int oil_parser::add_parameter_objimpl(std::string parameter)
+{
+	// p[^ðÍAÇÁ
+	if(param_addable)
+	{
+		current_impl->add_parameter(next_param_name , parameter);
+	}
+
+	return 0;
+}
+
+int oil_parser::start_objdef_analysis(std::string object_name_type)
+{
+	int result = 0;
+
+	try
+	{
+		// \¬ÌIuWFNgÀðÛ¶
+		current_def = new object_definition(object_name_type);
+	}
+	catch( ... )
+	{
+		result = -1;
+	}
+	return result;
+}
+
+int oil_parser::end_objimpl_analysis(void)
+{
+	// \¬®¹Ao^
+	impl_list.push_back(current_impl);
+	
+	return 0;
+}
+
+void oil_parser::enable_addparam(bool enabled)
+{
+	param_addable = enabled;
+}
+
+int oil_parser::end_objdef_analysis(void)
+{
+	static std::vector<std::string> defined_object_name;
+	std::string obj_name = current_def->get_name();
+
+	// ùÉ¯¶IuWFNgªÈ¢©`FbN
+	if(find(defined_object_name.begin() , defined_object_name.end() , obj_name)
+			== defined_object_name.end())
+	{
+		// \¬®¹Ao^
+		def_list.push_back(current_def);
+		// IuWFNg¼ðÇÁCo^ÏÝÉ·é
+		defined_object_name.push_back(obj_name);
+	}
+	else
+	{
+		// ¯¼ÌIuWFNg¼ª¶Ý·é½ßCG[
+		toppers::error("Object %1% redefined." , obj_name);
+	}
+	
+	return 0;
+}
+
+int oil_parser::add_attr_value(string str)
+{
+	attr_description = str;
+
+	if(param_addable == true)
+	{
+		current_def->add_parameter(next_param_name , attr_description);
+	}
+
+	return 0;
+}
+
+void oil_parser::set_error(int position , std::string message)
+{
+	error_position = position;
+	error_message = message;
+}
+
+void oil_parser::get_error(int *position , std::string *message)
+{
+	*position = error_position;
+	*message = error_message;
+}
+
+void oil_parser::dump_implementation(void)
+{
+	std::vector<oil_object_impl*>::iterator p;
+
+	for(p = impl_list.begin(); p != impl_list.end() ; p++)
+	{
+		(*p)->display_implementation();
+	}
+}
+
+void oil_parser::dump_definition(void)
+{
+	std::vector<object_definition*>::iterator p;
+	
+	cout << "************** Object Defition **************" << endl;
+	for(p = def_list.begin(); p != def_list.end() ; p++)
+	{
+		(*p)->display_definition();
+	}
+	cout << "************** Object Defition End **************" << endl;
+}
Index: /cfg_oil/trunk/toppers/oil/oil_parser.hpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/oil_parser.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/oil_parser.hpp	(revision 8)
@@ -0,0 +1,559 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+
+#ifndef OIL_PARSER_H
+#define OIL_PARSER_H
+
+#include <boost/spirit/core.hpp>
+#include <boost/spirit/error_handling.hpp>
+#include <boost/spirit/tree/ast.hpp>
+#include <boost/spirit/utility/functor_parser.hpp>
+#include <boost/spirit/utility/regex.hpp>
+#include <vector>
+#include <map>
+#include <algorithm>
+
+#include "toppers/text.hpp"
+#include "toppers/oil/oil_object.hpp"
+
+
+
+using namespace boost::spirit;
+
+namespace toppers
+{
+	namespace oil
+	{
+		typedef std::vector<toppers::oil::oil_implementation::oil_object_impl*> oil_impl;
+		typedef std::vector<toppers::oil::oil_definition::object_definition*> oil_def;
+		
+		class oil_parser
+		{
+			public:
+				oil_parser(std::string* txt , std::vector<std::string> const& objlist)
+				{
+					description = txt;
+					param_addable = true;
+					m_object_list = objlist;
+				}
+				~oil_parser()
+				{
+					std::vector<toppers::oil::oil_implementation::oil_object_impl*>::iterator p;
+
+					for(p = impl_list.begin() ; p != impl_list.end() ; p++)
+					{
+						delete *p;
+					}
+
+					std::vector<toppers::oil::oil_definition::object_definition*>::iterator q;
+
+					for(q = def_list.begin() ; q != def_list.end() ; q++)
+					{
+						delete *q;
+					}
+				}
+				int do_parse(oil_impl **impl , oil_def **def);
+				int start_objimpl_analysis(std::string object_name);
+				int start_objdef_analysis(std::string object_name_type);
+				int add_parameter_objimpl(std::string parameter);
+				int set_nextparam_name(std::string name);
+				int add_attr_value(std::string str);
+				int end_objimpl_analysis(void);
+				int end_objdef_analysis(void);
+				void enable_addparam(bool enabled);
+				void dump_implementation(void);
+				void dump_definition(void);
+				void set_error(int position , std::string message);
+				void get_error(int *position , std::string *message);
+
+				std::string* get_description(void)
+				{
+					return description;
+				}
+				std::vector<std::string> m_object_list;
+			protected:
+				std::string *description;
+				oil_impl impl_list;
+				oil_def def_list;
+			private:
+				toppers::oil::oil_implementation::oil_object_impl* current_impl;
+				std::string next_param_name;
+				std::string attr_description;
+				bool param_addable;
+				toppers::oil::oil_definition::object_definition* current_def;
+				std::string error_message;
+				int error_position;
+		};
+
+		// ¶@G[íÊ
+		enum oil_grammer_error
+		{
+			open_brace , close_brace , semicolon , equal , keyword , comma
+		};
+		// ¶@G[^è`
+		typedef assertion<oil_grammer_error> oil_assertion;
+		typedef boost::spirit::guard<oil_grammer_error> oil_error_guard;
+		
+		// G[nh
+		struct error_handler
+		{
+			oil_parser* container;
+			error_handler(oil_parser* _container) : container(_container)
+			{
+			}
+			template < class Scanner, class oil_grammer_error >
+			boost::spirit::error_status<> operator()( Scanner const& scan, oil_grammer_error const& error ) const
+			{
+				std::string message;
+				int pos;
+				boost::spirit::error_status<> result =
+					boost::spirit::error_status<>( boost::spirit::error_status<>::fail );
+
+				// G[o»ÊuÌZo
+				pos = error.where - &((container->get_description()->c_str())[0]);
+				
+				// bZ[WÌo^
+				switch ( error.descriptor )
+				{
+				case open_brace:
+					message = "missing '{'";
+					break;
+				case close_brace:
+					message = "missing '}'";
+					break;
+				case semicolon:
+					message = "missing ';'";
+					break;
+				case equal:
+					message = "missing '='";
+					break;
+				case keyword:
+					message = "can't use keyword";
+					break;
+				case comma:
+					message = "missing ','";
+					break;
+				}
+
+				container->set_error(pos , message);
+				return result;
+			}
+		};
+
+		// t@N^
+		struct match_objimpl_name
+		{
+			oil_parser* container;
+			match_objimpl_name(oil_parser* _container) : container(_container)
+			{
+			}
+			void operator()(char const *first, char const *last) const
+			{
+				std::string str(first , last);
+				std::vector<std::string>::iterator p;
+				bool hit = false;
+
+				for(p = container->m_object_list.begin() ; p != container->m_object_list.end() ; p++)
+				{
+					if(*p == str)
+					{
+						hit = true;
+						break;
+					}
+				}
+				container->start_objimpl_analysis(str);
+			}
+		};
+
+		struct find_implparam_name
+		{
+			oil_parser* container;
+			find_implparam_name(oil_parser* _container) : container(_container)
+			{
+			}
+
+			void operator()(char const *first, char const *last) const
+			{
+				string str(first , last);
+				container->set_nextparam_name(str);
+			}
+		};
+
+		struct match_impl_parameter
+		{
+			oil_parser* container;
+			match_impl_parameter(oil_parser* _container) : container(_container)
+			{
+			}
+
+			void operator()(char const *first, char const *last) const
+			{
+				string str(first , last);
+				container->add_parameter_objimpl(str);
+			}
+		};
+		
+		// ÀÌÂ¶Êðo·ét@N^
+		struct match_objimpl_end
+		{
+			oil_parser* container;
+			match_objimpl_end(oil_parser* _container) : container(_container)
+			{
+			}
+
+			void operator()(char val) const
+			{
+				container->end_objimpl_analysis();
+			}
+		};
+		
+		// IuWFNgè`æªðo·ét@N^
+		struct match_objdef_name
+		{
+			oil_parser* container;
+			match_objdef_name(oil_parser* _container) : container(_container)
+			{
+			}
+			void operator()(char const *first, char const *last) const
+			{
+				string str(first , last);
+				container->start_objdef_analysis(str);
+			}
+		};
+
+		// p[^è`ðÇÁ·ét@N^
+		struct find_attrname
+		{
+			oil_parser* container;
+			find_attrname(oil_parser* _container) : container(_container)
+			{
+			}
+			void operator()(char const *first, char const *last) const
+			{
+				string str(first , last);
+				container->set_nextparam_name(str);
+			}
+		};
+
+		// IuWFNgè`I[ðo·ét@N^
+		struct match_objdef_end
+		{
+			oil_parser* container;
+			match_objdef_end(oil_parser* _container) : container(_container){}
+
+			void operator()(char val) const
+			{
+				container->end_objdef_analysis();
+			}
+		};
+		
+		// è`Ìp[^^Cvð¯Ê·ét@N^
+		struct find_attribute
+		{
+			oil_parser* container;
+			find_attribute(oil_parser* _container) : container(_container)
+			{
+			}
+			void operator()(char const *first, char const *last) const
+			{
+				string str(first , last);
+				container->add_attr_value(str);
+			}
+		};
+
+		// è`Ìp[^^Cvð¯Ê·é(®¬_Å)
+		struct find_attribute_float
+		{
+			oil_parser* container;
+			find_attribute_float(oil_parser* _container) : container(_container)
+			{
+			}
+			void operator()(double val) const
+			{
+				char buf[256];
+				sprintf_s(buf , "%lf" , val);
+				string str(buf);
+				
+				container->add_attr_value(str);
+			}
+		};
+
+
+		
+		// ENUMÌp[^³·é½ßÌt@N^
+		struct enum_start
+		{
+			oil_parser* container;
+			enum_start(oil_parser* _container) : container(_container){}
+
+			void operator()(char val) const
+			{
+				container->enable_addparam(false);
+			}
+		};
+
+		// ENUMÌp[^³ðð·é½ßÌt@N^
+		struct enum_end
+		{
+			oil_parser* container;
+			enum_end(oil_parser* _container) : container(_container){}
+
+			void operator()(char val) const
+			{
+				container->enable_addparam(true);
+			}
+		};
+		
+		// OILp[TNX
+		struct oil_grammer :  public grammar<oil_grammer>
+		{
+			oil_parser* m_container;
+			oil_grammer(oil_parser* container)
+			{
+				m_container = container;
+			}
+			template <typename T> struct definition
+			{
+				// ¶@G[íÞè`
+				oil_assertion assertion_open_brace , assertion_close_brace , assertion_semicolon;
+				oil_assertion assertion_equal , assertion_keyword , assertion_comma;
+				// G[nhOè`
+				oil_error_guard guard_implementation , guard_object , guard_object_def;
+
+				// BNF
+				rule<T> file;
+				rule<T> oil_version , implementation_definition , application_definition;
+				rule<T> implementation_spec_list , implementation_spec , implementation_def;
+				rule<T> object , object_ref_type , object_name , object_temp;
+				
+				rule<T> name , null_str , boolean , string_literal;
+				rule<T> multiple_specifier , auto_specifier;
+				rule<T> number_range , number_list , number , float_range , default_number , default_float;
+				rule<T> attribute_name;
+				rule<T> default_string , default_bool , default_name;
+				rule<T> bool_values;
+				rule<T> enumerator , enumeration , enumerator_list;
+				
+				rule<T> impl_parameter_list;
+				
+				rule<T> uint32_impl_attr_def , int32_impl_attr_def , uint64_impl_attr_def , int64_impl_attr_def;
+				rule<T> float_impl_attr_def , string_impl_attr_def , bool_impl_attr_def , enum_impl_attr_def;
+				rule<T> reference_name;
+				rule<T> impl_attr_def , impl_ref_def;
+				
+				rule<T> object_definition;
+				rule<T> parameter , attribute_value;
+
+				definition(oil_grammer const& self) :
+					assertion_open_brace(open_brace) ,
+					assertion_close_brace(close_brace) ,
+					assertion_semicolon(semicolon) ,
+					assertion_equal(equal) ,
+					assertion_keyword(keyword) ,
+					assertion_comma(comma)
+				{
+					// LÖW
+					null_str = str_p("");
+					name = (alpha_p | ch_p('_')) >> +(alnum_p | ch_p('_'));
+					string_literal = ch_p('"') >> name >> ch_p('"');
+					multiple_specifier = !(ch_p('[') >> ch_p(']'));
+					auto_specifier = !str_p("WITH_AUTO");
+					number = (str_p("0x") >> +xdigit_p) | (str_p("0X") >> xdigit_p) | int_p | uint_p;
+					boolean = str_p("TRUE") | str_p("FALSE");
+					
+					// WAftHgl
+					number_list = ch_p('[') >> number >> *(ch_p(',') >> number) >> ch_p(']');
+					number_range = !((ch_p('[') >> number >> str_p("..") >> number >> ch_p(']'))
+									| number_list);
+					default_number = !((ch_p('=') >> number)
+										| (ch_p('=') >> str_p("NO_DEFAULT"))
+										| (ch_p('=') >> str_p("AUTO")));
+					float_range = !(ch_p('[') >> real_p >> str_p("..") >> real_p >> ch_p(']'));
+					default_float = !((ch_p('=') >> real_p)
+										| (ch_p('=') >> str_p("NO_DEFAULT"))
+										| (ch_p('=') >> str_p("AUTO")));
+					
+					enumerator = name >> !(ch_p('{') >> implementation_def >> ch_p('}'));
+					enumerator_list = enumerator >> *(ch_p(',') >> enumerator);
+					enumeration = ch_p('[')[enum_start(self.m_container)] >> 
+										enumerator_list >> ch_p(']')[enum_end(self.m_container)];
+
+					default_name = !((ch_p('=') >> name)
+										| (ch_p('=') >> str_p("NO_DEFAULT"))
+										| (ch_p('=') >> str_p("AUTO")));
+					
+					attribute_name = name | object;
+					attribute_value = (boolean >> !(ch_p('{')[enum_start(self.m_container)] >>
+											*parameter >> (ch_p('}')[enum_end(self.m_container)])))
+											[find_attribute(self.m_container)]
+										| number[find_attribute(self.m_container)]
+										| real_p[find_attribute_float(self.m_container)]
+										| string_literal[find_attribute(self.m_container)]
+										// AUTOÍºÌè`ÅãpÂ\
+										| (name >> !(ch_p('{')[enum_start(self.m_container)] >>
+											*parameter >> ch_p('}')[enum_end(self.m_container)]))
+											[find_attribute(self.m_container)];
+
+					default_string = !((ch_p('=') >> ch_p('"') >> name >> ch_p('"'))
+										| (ch_p('=') >> str_p("NO_DEFAULT"))
+										| (ch_p('=') >> str_p("AUTO")));
+					default_bool = !((ch_p('=') >> boolean)
+										| (ch_p('=') >> str_p("NO_DEFAULT"))
+										| (ch_p('=') >> str_p("AUTO")));
+					bool_values = !(ch_p('[')[enum_start(self.m_container)] >>
+											str_p("TRUE") >> !(ch_p('{') >> implementation_def >> ch_p('}')) >>
+									ch_p(',') >>
+											str_p("FALSE") >> !(ch_p('{') >> implementation_def >> ch_p('}')) >>
+									ch_p(']')[enum_end(self.m_container)]);
+
+					std::vector<std::string>::iterator p;
+					std::string objtype = "(" , objref = "(";
+					
+					// ³K\»ÌXgðì¬
+					for(p = self.m_container->m_object_list.begin() ; p != self.m_container->m_object_list.end() ; p++)
+					{
+						objtype += (*p) + "|";
+						objref += (*p) + "_TYPE" + "|";
+					}
+					
+					objtype[objtype.size() - 1] = ')';
+					objref[objref.size() - 1] = ')';
+
+					object = regex_p(objtype.c_str());
+					object_ref_type = regex_p(objref.c_str());
+					
+					// IuWFNgè`
+					parameter = attribute_name[find_attrname(self.m_container)] >>
+								assertion_equal(ch_p("=")) >> attribute_value >>
+								assertion_semicolon(ch_p(";"));
+					object_name = (object >> name)[match_objdef_name(self.m_container)];
+					object_definition = guard_object(
+											object_name >> assertion_open_brace(ch_p('{')) >> 
+											*parameter >> assertion_close_brace(ch_p('}')) >> 
+											assertion_semicolon(ch_p(';'))[match_objdef_end(self.m_container)])
+											[error_handler(self.m_container)];
+
+					// ^ÊÌp[^wèq
+					uint32_impl_attr_def = str_p("UINT32") >> auto_specifier >> number_range >>
+										attribute_name[find_implparam_name(self.m_container)] >> 
+										multiple_specifier >> default_number >> 
+										assertion_semicolon(ch_p(';'));
+					int32_impl_attr_def = str_p("INT32") >> auto_specifier  >> number_range >> 
+										attribute_name[find_implparam_name(self.m_container)] >>
+										multiple_specifier >> default_number >>
+										assertion_semicolon(ch_p(';'));
+					uint64_impl_attr_def = str_p("UINT64") >> auto_specifier  >> number_range >> 
+										attribute_name[find_implparam_name(self.m_container)] >>
+										multiple_specifier >> default_number >>
+										assertion_semicolon(ch_p(';'));
+					int64_impl_attr_def = str_p("INT64") >> auto_specifier  >> number_range >> 
+										attribute_name[find_implparam_name(self.m_container)] >>
+										multiple_specifier >> default_number >>
+										assertion_semicolon(ch_p(';'));
+					float_impl_attr_def = str_p("FLOAT") >> auto_specifier  >> float_range >> 
+										attribute_name[find_implparam_name(self.m_container)] >>
+										multiple_specifier >> default_float >>
+										assertion_semicolon(ch_p(';'));
+					string_impl_attr_def = str_p("STRING") >> auto_specifier >> 
+										attribute_name[find_implparam_name(self.m_container)] >>
+										multiple_specifier >> default_string >>
+										assertion_semicolon(ch_p(';'));
+					bool_impl_attr_def = str_p("BOOLEAN") >>
+										auto_specifier >> bool_values >>
+										attribute_name[find_implparam_name(self.m_container)] >>
+										multiple_specifier >> default_bool >>
+										assertion_semicolon(ch_p(';'));
+					enum_impl_attr_def = str_p("ENUM") >>
+										auto_specifier >> enumeration >>
+										attribute_name[find_implparam_name(self.m_container)] >>
+										multiple_specifier >> default_name >>
+										assertion_semicolon(ch_p(';'));
+
+					// ®«l
+					impl_attr_def = uint32_impl_attr_def | int32_impl_attr_def
+									| uint64_impl_attr_def | int64_impl_attr_def
+									| float_impl_attr_def | string_impl_attr_def
+									| bool_impl_attr_def | enum_impl_attr_def;
+					
+					reference_name = name | object;
+					impl_ref_def = object_ref_type >> reference_name[find_implparam_name(self.m_container)] >>
+									multiple_specifier >> assertion_semicolon(ch_p(';'));
+					
+					// p[^Ì`®
+					implementation_def = *((impl_attr_def | impl_ref_def)
+												[match_impl_parameter(self.m_container)]);
+
+					// {Ìè`
+					application_definition = 
+							str_p("CPU") >> name >> ch_p('{') >> 
+							*object_definition >> ch_p('}') >> ch_p(';');
+
+					// å«ÈPÊÌ¶@
+					implementation_spec = 
+						guard_object(object[match_objimpl_name(self.m_container)] >>
+										assertion_open_brace(ch_p('{')) >>
+										implementation_def >>
+										assertion_close_brace(ch_p('}')) >>
+										assertion_semicolon(ch_p(';')[match_objimpl_end(self.m_container)]))
+										[error_handler(self.m_container)];
+					implementation_spec_list = *implementation_spec;
+					
+					implementation_definition = "IMPLEMENTATION" >> name >> ch_p('{')
+						>> implementation_spec_list >> ch_p('}') >> ch_p(';');
+
+					oil_version = str_p("OIL_VERSION") 
+								>> ch_p('=') >> ch_p('\"') >> real_p >> ch_p('\"') >> ch_p(';');	//
+					file = oil_version >> implementation_definition >> application_definition >> *space_p;
+				};
+				rule<T> const& start() const
+				{
+					return file;                    // è`µ½[ðÔ·
+				}
+			};
+			
+		};
+
+
+	}
+}
+
+#endif	/* OIL_PARSER_H */
Index: /cfg_oil/trunk/toppers/oil/preprocess.cpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/preprocess.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/preprocess.cpp	(revision 8)
@@ -0,0 +1,208 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ *
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <cstring>
+#include <algorithm>
+#include <iostream>
+#include <iterator>
+#include "toppers/io.hpp"
+#include "toppers/cpp.hpp"
+#include "toppers/global.hpp"
+#include "toppers/diagnostics.hpp"
+#include "toppers/oil/preprocess.hpp"
+#include <boost/spirit.hpp>
+
+namespace toppers
+{
+  namespace oil
+  {
+
+    /*!
+     *  \brief  ÃIAPI `INCLUDE'ÌWJ
+     *  \param[in]  in      üÍt@CÌàe
+     *  \param[out] out     oÍt@CÌàe
+     *  \param[in]  codeset ¶R[h
+     *  \param[out] dependencies  Ë¶ÖWÌi[æiNULLÌêÍi[µÈ¢j
+     *  \param[out] onces   #pragma onceªLq³êÄ¢½t@C¼Ìi[æiNULLÌêÍi[µÈ¢j
+     *
+     *  `INCLUDE' ÌøÍAÊITRON dlÌàÌÆÍÙÈèAñdøpÅÍÜ¸É #include wßÆ
+     *  ¯¶`®ðp¢éB
+     */
+    void expand_include( text const& in, text& out, codeset_t codeset, std::set< std::string >* dependencies, std::set< std::string >* onces )
+    {
+      typedef text::container::const_iterator const_row_iterator;
+      typedef std::string::size_type size_type;
+      size_type const npos = std::string::npos;
+      const_row_iterator first( in.begin().get_row() ), last( in.end().get_row() );
+
+      out.set_line( first->line.file, first->line.line );
+      for ( const_row_iterator iter( first ); iter != last; ++iter )
+      {
+        std::string const& buf = iter->buf;
+        char state = 0;
+
+        for ( size_type i = 0, n = buf.size(); i != n; ++i )
+        {
+          char c = buf[i];
+          if ( c == '\'' || c == '\"' )
+          {
+            if ( state == 0 )
+            {
+              state = c;    // ¶iñjeJn
+            }
+            else if ( buf[i - 1] != '\\' ) //  \' Ü½Í \" ÅÍÈ¢
+            {
+              state = 0;    // ¶iñjeI¹
+            }
+            else if ( ( codeset == shift_jis ) && ( i >= 2 ) && is_lead< shift_jis >( buf[i - 2] ) )
+            {
+              state = 0;
+            }
+            out.push_back( c );
+          }
+          else if ( state != 0 )  // ¶iñjeà
+          {
+            out.push_back( c );
+          }
+          else
+          {
+            using namespace boost::spirit;
+            std::string headername;
+            if ( iter == last )
+            {
+              return;
+            }
+            text::const_iterator iter2( iter, i );
+            if ( iter2 == in.end() )
+            {
+              break;
+            }
+            parse_info< text::const_iterator > info
+              = parse( iter2, in.end(),
+				( str_p( "#include" ) >> *space_p
+                            >> '\"' >> ( +( anychar_p - '\"' ) )[ assign( headername ) ] >> '\"'
+                           ) );  // sÔª¸êéÌÅAXLbvp[TÍgpµÈ¢
+            if ( info.hit )
+            {
+              std::vector< std::string > include_paths = get_global< std::vector< std::string > >( "include-path" );
+              std::string hname = search_include_file( include_paths.begin(), include_paths.end(), headername );
+              if ( hname.empty() )  // wb_¼ª©Â©çÈ¢
+              {
+                error( iter->line, _( "cannot open file `%1%\'" ), headername );
+              }
+              else if ( onces == 0 || onces->find( hname ) == onces->end() )
+              {
+                if ( dependencies != 0 )
+                {
+                  dependencies->insert( hname );
+                }
+                out.push_back( ' ' ); // _~[ð}üµÄ¨©È¢ÆsÔª¸êé
+                preprocess( hname, out, codeset, dependencies, onces );  // wb_¼Åwè³ê½t@CÉÎµÄOðÄAIÉs¤
+                iter = info.stop.get_row();
+                i = info.stop.get_col() - 1;
+                if ( iter != last )
+                {
+                  out.set_line( iter->line.file, iter->line.line );
+                }
+              }
+            }
+            else
+            {
+              if ( iter2.get_col() == 0 )
+              {
+                info = parse( iter2, in.end(),
+                              ( *( space_p - eol_p ) >>
+                                  ch_p( '#' ) >> *space_p >> "pragma" >> *space_p
+                                    >> "once"
+                                    >> *( space_p - eol_p ) >> eol_p ) );
+                if ( info.hit )
+                {
+                  if ( onces != 0 )
+                  {
+                    onces->insert( iter2.line().file );
+                  }
+                  out.push_back( ' ' );
+                  iter = info.stop.get_row();
+                  if ( iter != last )
+                  {
+                    out.set_line( iter->line.file, iter->line.line );
+                  }
+                  --iter;   // CNg³êéÌÅ¢Á½ñß·B
+                  break;
+                }
+              }
+              if ( parse( iter2, in.end(),
+				  ( str_p( "#include" ) >> *space_p >> '\"' >> +( anychar_p - ')' ) >> '\"') ).hit )
+              {
+                warning( iter->line, _( "probably, %1% argument of `%2%\' is illegal" ), _( "1st" ), "INCLUDE" );
+              }
+              out.push_back( c );
+            }
+          }
+        }
+      }
+    }
+
+    /*!
+     *  \brief  RtBM
+[Vt@CÌO
+     *  \param[in]  file    RtBM
+[Vt@C¼
+     *  \param[out] result  OãÌàe
+     *  \param[in]  codeset ¶R[h
+     *  \param[out] dependencies  Ë¶ÖWÌi[æiNULLÌêÍi[µÈ¢j
+     *  \param[out] onces   #pragma onceªLq³êÄ¢½t@C¼Ìi[æiNULLÌêÍi[µÈ¢j
+     */
+    void preprocess( std::string const& file, text& result, codeset_t codeset, std::set< std::string >* dependencies, std::set< std::string >* onces )
+    {
+      std::string buf;
+      read( file, buf );
+      if ( buf.empty() )
+      {
+        return;
+      }
+      text txt;
+      txt.set_line( file, 1 );
+      remove_comment( buf.begin(), buf.end(), std::back_inserter( txt ), codeset );
+      expand_include( txt, result, codeset, dependencies, onces );
+    }
+
+  }
+}
Index: /cfg_oil/trunk/toppers/oil/preprocess.hpp
===================================================================
--- /cfg_oil/trunk/toppers/oil/preprocess.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/oil/preprocess.hpp	(revision 8)
@@ -0,0 +1,65 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/oil/preprocess.hpp
+ *  \brief  VXeRtBM
+[Vt@CÌOÉÖ·éé¾è`
+ */
+#ifndef TOPPERS_OIL__PREPROCESSOR_HPP_
+#define TOPPERS_OIL__PREPROCESSOR_HPP_
+
+#include <string>
+#include <set>
+#include "toppers/text.hpp"
+#include "toppers/cpp.hpp"
+
+namespace toppers
+{
+  namespace oil
+  {
+
+    void expand_include( text const& in, text& out, codeset_t codeset = ascii, std::set< std::string >* dependencies = 0, std::set< std::string >* onces = 0 );
+    void preprocess( std::string const& file, text& result, codeset_t codeset = ascii, std::set< std::string >* dependencies = 0, std::set< std::string >* onces = 0 );
+
+  }
+}
+
+#endif  // ! TOPPERS_OIL__PREPROCESSOR_HPP_
Index: /cfg_oil/trunk/toppers/output_file.cpp
===================================================================
--- /cfg_oil/trunk/toppers/output_file.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/output_file.cpp	(revision 8)
@@ -0,0 +1,244 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+#include <map>
+#include <iostream>
+#include <sstream>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+#include "toppers/workaround.hpp"
+#include "toppers/output_file.hpp"
+#include "toppers/io.hpp"
+#include "toppers/global.hpp"
+#include "toppers/diagnostics.hpp"
+
+namespace toppers
+{
+  namespace
+  {
+    struct context
+    {
+      std::ostringstream ostr;
+      std::string tempname;
+    };
+
+    typedef std::map< std::string, std::tr1::shared_ptr< context > > context_map;
+
+    inline context_map& get_context_map()
+    {
+      static context_map m;
+      return m;
+    }
+  }
+
+  /*!
+   *  \brief  oÍXg[ÌQÆ
+   *  \return oÍXg[
+   *
+   *  Ýè³êÄ¢ét@CÉoÍ·é½ßÌoÍXg[ðÔ·B
+   *  ùÉoÍXg[ª¶¬³êÄ¢éêÍ»ÌQÆðÔµA»¤ÅÈ¯êÎV½ÉoÍXg[ð¶¬·éB
+   *
+   *  t@C¼ÆµÄA"stdout"ªÝè³êÄ¢êÎWoÍA"stderr"ªÝè³êÄ¢êÎWG[oÍÉÈéB
+   */
+  std::ostream& output_file::ostr() const
+  {
+    if ( filename_ == "stdout" )
+    {
+      return std::cout;
+    }
+    else if ( filename_ == "stderr" )
+    {
+      return std::cerr;
+    }
+
+    std::string path( path_name( filename_ ) );
+    context_map::const_iterator iter( get_context_map().find( path ) );
+    if ( iter == get_context_map().end() )
+    {
+      std::tr1::shared_ptr< context > ctx( new context );
+      get_context_map().insert( std::make_pair( path, ctx ) );
+      return ctx->ostr;
+    }
+    return iter->second->ostr;
+  }
+
+  /*!
+   *  \brief  ãÉi[³êÄ¢éàeðÀÛÉt@CÉoÍ·éB
+   *
+   *  context_map ÆµÄãÉi[³ê½àeðA»ê¼êÌt@CÉÎµÄoÍ·éB
+   *  oÍ·éÉ ½èAÜ¸³Ìt@Cð .org ðt¯½t@C¼ÉÏX·éB
+   *  ±±ÅAÈOÉ Á½ .org Íjó³êéB
+   *  t@CðÉ«ÝArÅG[ª­¶µ½êÍA.org ð³Ìt@C¼Éß·B
+   *  rÅÐÆÂÅàG[ª­¶µ½êÍASt@CÉÂ¢Ä .org ð³Éß·B
+   *  ÈOÉ Á½ .org ÍµÈ¢B
+   */
+  void output_file::save()
+  {
+    namespace fs = boost::filesystem;
+    std::vector< std::string > saved_files;
+
+    try
+    {
+      for ( context_map::const_iterator iter( get_context_map().begin() ), last( get_context_map().end() );
+            iter != last;
+            ++iter )
+      {
+        if ( iter->first != "" )
+        {
+          fs::path filename( iter->first, fs::native );
+          fs::path backup( iter->first + ".org", fs::native );
+          bool existed = fs::exists( filename );
+
+          try
+          {
+            std::string file( filename.native_file_string() );
+            if ( existed )
+            {
+              fs::rename( filename, backup );
+            }
+            write( file, iter->second->ostr.str() );  // ±±Å«Þ
+            saved_files.push_back( file );
+            fs::remove( backup );
+          }
+          catch ( ... )
+          {
+            if ( existed )
+            {
+              fs::remove( filename );
+              fs::rename( backup, filename ); 
+            }
+            throw;
+          }
+        }
+      }
+    }
+    catch ( ... )
+    {
+      // ·ÅÉ«ñ¾t@Cð³Éß·B
+      for ( std::vector< std::string >::const_iterator iter( saved_files.begin() ), last( saved_files.end() );
+            iter != last;
+            ++iter )
+      {
+        fs::path filename( *iter, fs::native );
+        fs::remove( filename );
+        fs::path backup( *iter + ".org", fs::native );
+        if ( fs::exists( backup ) )
+        {
+          fs::rename( backup, filename );
+        }
+      }
+      throw;
+    }
+  }
+
+  /*!
+   *  \brief  wèµ½t@C¼ÉÎµ½pX¼ðÔ·B
+   *  \param[in]  filename  t@C¼
+   *  \return     pX¼
+   *
+   *  --output-directory IvVÅwèµ½oÍæfBNgð½fµ½pX¼ð¶¬·éB
+   *  ½¾µAºLÌt@C¼ÌêÍ»ÌÜÜÌ¶ñðÔ·B
+   *  - "stdout"
+   *  - "stderr"
+   *  - ""
+   */
+  std::string output_file::path_name( std::string const& filename )
+  {
+    if ( filename == "stdin" || filename == "stderr" || filename == "" )
+    {
+      return filename;
+    }
+    namespace fs = boost::filesystem;
+    boost::any output_directory = global( "output-directory" );
+    if ( output_directory.empty() )
+    {
+      return filename;
+    }
+    fs::path dir( get_global< std::string >( "output-directory" ), fs::native  );
+    return ( dir/filename ).native_file_string();
+  }
+
+  /*!
+   *  \brief  wèt@CÖÌ«Ýf[^ðQÆ
+   *  \param[in]  filename  oÍæÌt@C¼
+   *  \return     «Ýf[^
+   */
+  std::string output_file::get_file_data( std::string const& filename )
+  {
+    context_map::const_iterator iter( get_context_map().find( path_name( filename ) ) ), last( get_context_map().end() );
+    if ( iter != last )
+    {
+      return iter->second->ostr.str();
+    }
+    return "";
+  }
+
+  /*!
+   *  \brief  wèt@CÖÌ«Ýf[^ðÝè
+   *  \param[in]  filename  oÍæÌt@C¼
+   *  \param[in]  data      «Ýf[^
+   *  \retval     true      Ýè¬÷
+   *  \retval     false     Ýè¸s
+   */
+  bool output_file::set_file_data( std::string const& filename, std::string const& data )
+  {
+    output_file ofile( filename, std::ios_base::out );
+    dynamic_cast< std::ostringstream& >( ofile.ostr() ).str( data );
+    return true;
+  }
+
+  /*!
+   *  \brief  ãÉi[³êÄ¢é«Ýæ¤f[^ðÁ
+   *  \param[in]  filename  oÍæÌt@C¼
+   *  \retval     true      f[^ÌÁ¬÷
+   *  \retval     false     wèµ½t@CÖÌoÍf[^ª¶ÝµÈ¢
+   */
+  bool output_file::clear_file_data( std::string const& filename )
+  {
+    context_map::const_iterator iter( get_context_map().find( path_name( filename ) ) ), last( get_context_map().end() );
+    if ( iter != last )
+    {
+      iter->second->ostr.str( "" );
+      return true;
+    }
+    return false;
+  }
+
+}
Index: /cfg_oil/trunk/toppers/output_file.hpp
===================================================================
--- /cfg_oil/trunk/toppers/output_file.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/output_file.hpp	(revision 8)
@@ -0,0 +1,107 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+/*!
+ *  \file   toppers/output_file.hpp
+ *  \brief  oÍt@CÇðµ¤½ßÌé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  class output_file;
+ *  \endcode
+ */
+#ifndef TOPPERS_OUTPUT_FILE_HPP_
+#define TOPPERS_OUTPUT_FILE_HPP_
+
+#include <ostream>
+#include <string>
+#include "toppers/config.hpp"
+
+namespace toppers
+{
+
+  /*!
+   *  \class  output_file output_file.hpp "toppers/output_file.hpp"
+   *  \brief  oÍt@CÇNX
+   */
+  class output_file
+  {
+  public:
+    output_file() : omode_( static_cast< std::ios_base::openmode >( 0 ) ) {}
+    output_file( std::string const& filename, std::ios_base::openmode omode )
+      : filename_( filename ), omode_( omode ), enable_( true ) {}
+    virtual ~output_file() {}
+
+    std::ostream& ostr() const;
+    std::string const& file_name() const { return filename_; }
+    bool is_enable() const { return enable_; }
+    void enable( bool flag = true ) { enable_ = flag; }
+    void push_back( char c )
+    {
+      if ( enable_ )
+      {
+        ostr() << c;
+      }
+    }
+
+    static std::string path_name( std::string const& filename );
+    static std::string get_file_data( std::string const& filename );
+    static bool set_file_data( std::string const& filename, std::string const& data );
+    static bool clear_file_data( std::string const& filename );
+    static void save();
+  private:
+    std::string filename_;
+    std::ios_base::openmode omode_;
+    bool enable_;
+  };
+
+  template < typename T >
+    inline output_file const& operator << ( output_file const& ofile, T const& value )
+  {
+    if ( ofile.is_enable() )
+    {
+      ofile.ostr() << value;
+    }
+    return ofile;
+  }
+
+}
+
+#endif  // ! TOPPERS_OUTPUT_FILE_HPP_
Index: /cfg_oil/trunk/toppers/s_record.cpp
===================================================================
--- /cfg_oil/trunk/toppers/s_record.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/s_record.cpp	(revision 8)
@@ -0,0 +1,271 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/s_record.cpp
+ */
+#include "toppers/s_record.hpp"
+#include <istream>
+#include <algorithm>
+#include <cctype>
+#include <cstring>
+
+namespace toppers
+{
+
+  /*!
+   *  \brief  SR[hÌ[h
+   *  \param  istr  üÍXg[
+   */
+  void s_record::load( std::istream& istr )
+  {
+    int type = -1;
+
+    while ( istr )
+    {
+      std::string buf;
+      std::getline( istr, buf );
+      if ( buf.empty() )
+      {
+        break;
+      }
+      record rec = read_record( buf );
+
+      //  Üèµ§ÉÍµÈ¢
+      if ( '1' <= rec.type && rec.type <= '3' )
+      {
+        bool done = false;
+        typedef std::vector< value_type >::iterator iterator;
+        for ( iterator iter( data_.begin() ), last( data_.end() ); iter != last; ++iter )
+        {
+          if ( rec.address == iter->first + iter->second.size() )
+          {
+            std::copy( rec.data.begin(), rec.data.end(), std::back_inserter( iter->second ) );
+            done = true;
+          }
+        }
+        if ( !done )
+        {
+          data_.push_back( value_type( rec.address, std::vector< unsigned char >( rec.data.begin(), rec.data.end() ) ) );
+        }
+      }
+      type = rec.type;
+    }
+
+    cache_ = data_.begin();
+  }
+
+  /*!
+   *  \brief  wèAhXÌoCgf[^æ¾
+   *  \param  address   AhXwè
+   *  \return address Åwèµ½AhXÌoCgf[^ðÔ·
+   */
+  int s_record::operator[]( size_type address ) const
+  {
+    typedef std::vector< value_type >::const_iterator const_iterator;
+    if ( cache_ != data_.end() )
+    {
+      const_iterator iter( cache_ );
+      if ( iter->first <= address && address < iter->first + iter->second.size() )
+      {
+        return iter->second.at( address - iter->first );
+      }
+    }
+    for ( const_iterator iter( cache_ ), last( data_.end() ); iter != last; ++iter )
+    {
+      if ( iter->first <= address && address < iter->first + iter->second.size() )
+      {
+        cache_ = iter;
+        return iter->second.at( address - iter->first );
+      }
+    }
+    for ( const_iterator iter( data_.begin() ), last( cache_ ); iter != last; ++iter )
+    {
+      if ( iter->first <= address && address < iter->first + iter->second.size() )
+      {
+        cache_ = iter;
+        return iter->second.at( address - iter->first );
+      }
+    }
+    return -1;
+  }
+
+  /*!
+   *  \brief  SR[hÌ®lÇÝÝ
+   *  \param  base  ÇÝÝÊuÌæªAhX
+   *  \param  size  ®lÌoCg
+   *  \param  little_endian gGfBAÈç trueArbOGfBAÈç false ðwè
+   *  \return ÇÝñ¾®lðÔ·
+   */
+  boost::uintmax_t s_record::get_value( std::size_t base, std::size_t size, bool little_endian ) const
+  {
+    boost::uintmax_t value = 0;
+    if ( little_endian )
+    {
+      for ( long j = static_cast< long >( size-1 ); j >= 0; j-- )
+      {
+        int t = ( *this )[ base + j ];
+        if ( t < 0 )
+        {
+          throw data_error();
+        }
+        value = ( value << 8 ) | ( t & 0xff );
+      }
+    }
+    else
+    {
+      for ( std::size_t j = 0; j < size; j++ )
+      {
+        int t = ( *this )[ base + j ];
+        if ( t < 0 )
+        {
+          throw data_error();
+        }
+        value = ( value << 8 ) | ( t & 0xff );
+      }
+    }
+    return value;
+  }
+
+  unsigned long s_record::lower_bound() const
+  {
+    return data_.front().first;
+  }
+
+  unsigned long s_record::upper_bound() const
+  {
+    return data_.back().first + data_.back().second.size();
+  }
+
+  /*!
+   *  \brief  SR[hÌPsÇÝÝ
+   *  \param  rec_buf Psobt@
+   *  \return ÇÝÝÊðÔ·
+   */
+  s_record::record const s_record::read_record( std::string const& rec_buf )
+  {
+    std::string buf( rec_buf );
+
+    // sÉ'\r'Ü½Í'\n'ªc¯µÄ¢éêÌÎô
+    while ( std::isspace( static_cast< unsigned char >( *buf.rbegin() ) ) )
+    {
+      buf = buf.substr( 0, buf.size()-1 );
+    }
+
+    if ( buf.size() < 10 || buf[0] != 'S' )
+    {
+      throw format_error();
+    }
+    int ch = static_cast< unsigned char >( buf[1] );
+    int address_length = 4;
+    std::string::size_type size = buf.size();
+
+    switch ( ch )
+    {
+    case '1':
+    case '9':
+      address_length = 4;
+      break;
+    case '2':
+    case '8':
+      address_length = 6;
+      break;
+    case '3':
+    case '7':
+      address_length = 8;
+      break;
+    default:
+      if ( !std::isdigit( static_cast< unsigned char >( ch ) ) )
+      {
+        throw format_error();
+      }
+      break;
+    }
+    
+    record rec;
+    rec.type = ch;
+    rec.length = xdigit_to_int( buf[2] ) << 4 | xdigit_to_int( buf[3] );
+    if ( rec.length * 2u + 4 != buf.size() )
+    {
+      throw format_error();
+    }
+    rec.length -= address_length/2 + 1; // AhXÆ`FbNTÌ·³ðø¢ÄAf[^·É¼·
+
+    rec.address = 0;
+    int base = 4;
+    for ( int i = 0; i < address_length; i++ )
+    {
+      rec.address = rec.address << 4 | xdigit_to_int( buf[base+i] );
+    }
+
+    base += address_length;
+    rec.data.reserve( rec.length );
+    for ( int i = 0; i < rec.length; i++ )
+    {
+      rec.data.push_back( static_cast< unsigned char >( xdigit_to_int( buf[base+i*2] ) << 4 | xdigit_to_int( buf[base+i*2+1] ) ) );
+    }
+
+    rec.checksum = xdigit_to_int( buf[size-2] ) << 4 | xdigit_to_int( buf[size-1] );
+
+    // `FbNT»èÍÈª
+
+    return rec;
+  }
+
+  /*!
+   *  \brief  \Zi©çlÖÌÏ·
+   *  \param  ch  \Zii¶j
+   *  \return ch ÉÎ·él
+   */
+  int s_record::xdigit_to_int( int ch )
+  {
+    static char const xdigits[] = "0123456789abcdef";
+
+    ch = std::tolower( static_cast< unsigned char >( ch ) );
+    char const* s = std::strchr( xdigits, ch );
+    if ( s == 0 )
+    {
+      return -1;
+    }
+    return s - xdigits;
+  }
+
+}
Index: /cfg_oil/trunk/toppers/s_record.hpp
===================================================================
--- /cfg_oil/trunk/toppers/s_record.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/s_record.hpp	(revision 8)
@@ -0,0 +1,152 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa  
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/s_record.hpp
+ *  \brief  g[SR[hðµ¤½ßÌé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  class s_record;
+ *  struct s_record::record;
+ *  class s_record::format_error;
+ *  class s_record::checksum_error;
+ *  \endcode
+ */
+#ifndef TOPPERS_S_RECORD_HPP_
+#define TOPPERS_S_RECORD_HPP_
+
+#include "toppers/config.hpp"
+#include <iosfwd>
+#include <string>
+#include <vector>
+#include <utility>
+#include <stdexcept>
+#include <boost/cstdint.hpp>
+
+namespace toppers
+{
+
+  /*!
+   *  \class  s_record s_record.hpp "toppers/s_recored.hpp"
+   *  \brief  g[SR[hðµ¤½ßÌNX
+   *
+   *  \sa s_record::record, s_record::format_error, s_record::checksum_error
+   */
+  class s_record
+  {
+  public:
+    typedef std::pair< unsigned long, std::vector< unsigned char > > value_type;
+    typedef std::vector< value_type >::size_type size_type;
+
+    /*!
+     *  \struct record s_record.hpp "toppers/s_record.hpp"
+     *  \brief  SR[hÌPsR[hîñði[·é½ßÌ\¢Ì
+     */
+    struct record
+    {
+      int type;
+      int length;
+      unsigned long address;
+      std::vector< unsigned char > data;
+      int checksum;
+    };
+
+    /*!
+     *  \class  data_error s_record.hpp "toppers/s_record.hpp"
+     *  \brief  SR[hÌf[^G[áONX
+     */
+    class data_error : public std::runtime_error
+    {
+    public:
+      data_error() : std::runtime_error( "S-record data error" ) {}
+    };
+    /*!
+     *  \class  format_error s_record.hpp "toppers/s_record.hpp"
+     *  \brief  SR[hÌ®G[áONX
+     */
+    class format_error : public std::runtime_error
+    {
+    public:
+      format_error() : std::runtime_error( "S-record format error" ) {}
+    };
+    /*!
+     *  \class  checksum_error s_record.hpp "toppers/s_record.hpp"
+     *  \brief  SR[hÌ`FbNTG[áONX
+     */
+    class checksum_error : public std::runtime_error
+    {
+    public:
+      checksum_error() : std::runtime_error( "S-record checksum error" ) {}
+    };
+
+    /*!
+     *  \brief  ftHgRXgN^
+     */
+    s_record() : cache_( data_.end() ) {}
+    /*!
+     *  \brief  RXgN^
+     *  \param  istr  üÍXg[
+     *
+     *  s_record NXÌ¶¬Æ¯Éf[^Ì[hðs¢Ü·B
+     */
+    explicit s_record( std::istream& istr ) { load( istr ); }
+    /*!
+     *  \brief  fXgN^
+     */
+    virtual ~s_record() {}
+
+    void load( std::istream& istr );
+    int operator[]( size_type address ) const;
+    boost::uintmax_t get_value( std::size_t base, std::size_t size, bool little_endian ) const;
+    unsigned long lower_bound() const;
+    unsigned long upper_bound() const;
+  protected:
+    static record const read_record( std::string const& rec_buf );
+    static int xdigit_to_int( int ch );
+  private:
+    std::vector< value_type > data_;
+    mutable std::vector< value_type >::const_iterator cache_;
+  };
+
+}
+
+#endif  // ! TOPPERS_S_RECORD_HPP_
Index: /cfg_oil/trunk/toppers/text.hpp
===================================================================
--- /cfg_oil/trunk/toppers/text.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/text.hpp	(revision 8)
@@ -0,0 +1,838 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/text.hpp
+ *  \brief  eLXgf[^ÇÉÖ·éé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  class basic_text< Container, CharT, Traits, Allocator >;
+ *  \endcode
+ */
+#ifndef TOPPERS_TEXT_HPP_
+#define TOPPERS_TEXT_HPP_
+
+#include <algorithm>
+#include <iterator>
+#include <vector>
+#include <numeric>
+#include "toppers/text_line.hpp"
+#include "toppers/misc.hpp"
+#include <boost/utility.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/format.hpp>
+
+namespace toppers
+{
+
+  /*!
+   *  \class  basic_text  text.hpp "toppers/text.hpp"
+   *  \brief  eLXgf[^Çev[gNX
+   *
+   *  t@C©çÇÝñ¾eLXgf[^ÌÇðs¤½ßÌNXÅ·B
+   *  ±ÌNXÅÍAeLXgf[^ðPÈé¶ñÆµÄÅÍÈ­AüÍ³Ì
+   *  t@C¼ÆsÔðtÁµ½`ÅÇµÜ·B
+   *
+   *  \note   ±ÌNXÍeLXgÒWÌprðzèµ½àÌÅÍ èÜ¹ñB
+   */
+  template
+  <
+    template < typename, class > class Container,
+    typename CharT,
+    class Traits = std::char_traits< CharT >,
+    class Allocator = std::allocator< CharT >
+  >
+    class basic_text
+  {
+  public:
+    typedef basic_text< Container, CharT, Traits, Allocator > self_t;
+    typedef std::basic_string< CharT, Traits, Allocator > string_type;
+    typedef ::toppers::text_line line_type;
+    typedef basic_line_buf< CharT, Traits, Allocator > line_buf;
+
+    //  ÈºÍêÊIÈReiÆÌÝ·Ì½ßÌ^è`
+    ////////////////////////////////////////////////////////////////////////////////
+    typedef CharT value_type;
+    typedef Container< line_buf, std::allocator< line_buf > > container;
+    typedef value_type& reference;
+    typedef value_type const& const_reference;
+    typedef value_type* pointer;
+    typedef value_type const* const_pointer;
+    typedef Allocator allocator_type;
+    typedef typename Allocator::difference_type difference_type;
+    typedef typename Allocator::size_type size_type;
+
+    /*!
+     *  \class  const_iterator text.hpp "toppers/text.hpp"
+     *  \brief  toppers::basic_text ÌCe[^
+     */
+    class const_iterator : public boost::iterator_facade< const_iterator, CharT, boost::random_access_traversal_tag, CharT const& >
+    {
+      friend class boost::iterator_core_access;
+    public:
+      typedef boost::iterator_facade< const_iterator, CharT, boost::random_access_traversal_tag, CharT const& > base_t;
+      typedef typename container::const_iterator row_iterator;
+      typedef typename base_t::value_type value_type;
+      typedef typename base_t::reference reference;
+      typedef typename base_t::pointer pointer;
+      typedef typename base_t::difference_type difference_type;
+
+      const_iterator() : row_(), col_( 0 ) {}
+      const_iterator( row_iterator row, size_type col = 0 ) : row_( row ), col_( col ) {}
+      line_type const& line() const { return row_->line; }
+      row_iterator const& get_row() const { return row_; }
+      size_type get_col() const { return col_; }
+    protected:
+      reference dereference() const { return row_->buf[col_]; }
+      bool equal( const_iterator const& rhs ) const { return row_ == rhs.row_ && col_ == rhs.col_; }
+      void increment() { if ( ++col_ == row_->buf.size() ) { col_ = 0; ++row_; } }
+      void decrement() { if ( col_ == 0 ) col_ = ( --row_ )->buf.size(); --col_; }
+      void advance( difference_type n )
+      {
+        typename container::const_iterator row = row_;
+        difference_type col = static_cast< difference_type >( col_ );
+        if ( n >= 0 )
+        {
+          while ( static_cast< size_type>( col + n ) > row->buf.size() )
+          {
+            n -= row->buf.size() - col;
+            ++row;
+            col = 0;
+          }
+          col += n;
+          if ( col == row->buf.size() )
+          {
+            col = 0;
+            ++row;
+          }
+        }
+        else  // n < 0
+        {
+          while ( col + n < -1 )
+          {
+            n += col;
+            --row;
+            col = row->buf.size() - 1;
+          }
+          col += n;
+          if ( col == -1 )
+          {
+            --row;
+            col = row->buf.size() - 1;
+          }
+        }
+        row_ = row;
+        col_ = col;
+      }
+      difference_type distance_to( const_iterator const& rhs ) const
+      {
+        difference_type n;
+        typename container::const_iterator row = row_;
+        if ( rhs.row_ < row_ )
+        {
+          n = -static_cast< difference_type >( col_ + ( rhs.row_->buf.size() - rhs.col_ ) );
+          while ( --row != rhs.row_ )
+          {
+            n -= row->buf.size();
+          }
+        }
+        else if ( row_ < rhs.row_ )
+        {
+          n = col_ + rhs.col_;
+          while ( ++row != rhs.row_ )
+          {
+            n += row->buf.size();
+          }
+        }
+        else
+        {
+          n = static_cast< difference_type >( rhs.col_ ) - static_cast< difference_type >( col_ );
+        }
+        return n;
+      }
+    private:
+      typename container::const_iterator row_;
+      size_type col_;
+    };
+
+    /*!
+     *  \class  iterator text.hpp "toppers/text.hpp"
+     *  \brief  toppers::basic_text ÌCe[^
+     */
+    class iterator : public const_iterator
+    {
+    public:
+      typedef typename container::iterator row_iterator;
+      typedef typename const_iterator::value_type value_type;
+      typedef typename const_iterator::reference reference;
+      typedef typename const_iterator::pointer pointer;
+      typedef typename const_iterator::difference_type difference_type;
+
+      iterator() {}
+      explicit iterator( row_iterator row, size_type col = 0 ) : const_iterator( row, col ) {}
+      value_type& operator*() const { return const_cast< value_type& >( const_iterator::dereference() ); }
+      iterator& operator++() { const_iterator::increment(); return *this; }
+      iterator operator++( int ) { iterator t( *this ); const_iterator::increment(); return t; }
+      iterator& operator--() { const_iterator::decrement(); return *this; }
+      iterator operator--( int ) { iterator t( *this ); const_iterator::decrement(); return t; }
+    };
+
+    typedef std::reverse_iterator< const_iterator > const_reverse_iterator;
+    typedef std::reverse_iterator< iterator > reverse_iterator;
+
+  public:
+    /*!
+     *  \brief  ftHgRXgN^
+     */
+    basic_text() {}
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  first   ú»Ép¢éf[^ñÌæª
+     *  \param  last    ú»Ép¢éf[^ñÌI[+1
+     */
+    basic_text( const_iterator const& first, const_iterator const& last )
+    {
+      if ( first != last )
+      {
+        init( first, last );
+      }
+    }
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  first   ú»Ép¢éf[^ñÌæª
+     *  \param  last    ú»Ép¢éf[^ñÌI[+1
+     *  \note   t@C¼Í"unknown"ÉÈèÜ·B
+     */
+    template < class InputIterator >
+      basic_text( InputIterator first, InputIterator last )
+    {
+      if ( first != last )
+      {
+        init( first, last, append_directive );
+      }
+    }
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  first   ú»Ép¢éf[^ñÌæª
+     *  \param  last    ú»Ép¢éf[^ñÌI[+1
+     *  \param  directive PsðReiÉi[·é½ßÌ
+     *  \note   t@C¼Í"unknown"ÉÈèÜ·B
+     *
+     *  directive Í void directive( container& cont, line_buf& buf )Ì`®ð
+     *  ÆéÖÖÌ|C^Ü½Ít@N^Å é±ÆðzèµÄ¢Ü·B
+     *  cont ÍàÅf[^Ìi[Égp·éReiA buf ÍPsªÌ¶
+     *  ñÆt@C¼EsÔði[µ½obt@Å·B
+     */
+    template < class InputIterator, class Directive >
+      basic_text( InputIterator first, InputIterator last, Directive directive )
+    {
+      if ( first != last )
+      {
+        init( first, last, directive );
+      }
+    }
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  istr    ú»Ép¢éüÍXg[
+     *  \note   t@C¼Í"unknown"ÉÈèÜ·B
+     */
+    basic_text( std::basic_istream< CharT, Traits >& istr )
+    {
+      init( istr, append_directive );
+    }
+
+    /*!
+     *  \brief  RXgN^
+     *  \param  istr    ú»Ép¢éüÍXg[
+     *  \param  directive PsðReiÉi[·é½ßÌ
+     *  \note   t@C¼Í"unknown"ÉÈèÜ·B
+     *
+     *  directive Í void directive( container& cont, line_buf& buf )Ì`®ð
+     *  ÆéÖÖÌ|C^Ü½Ít@N^Å é±ÆðzèµÄ¢Ü·B
+     *  cont ÍàÅf[^Ìi[Égp·éReiA buf ÍPsªÌ¶
+     *  ñÆt@C¼EsÔði[µ½obt@Å·B
+     */
+    template < class Directive >
+      basic_text( std::basic_istream< CharT, Traits >& istr, Directive directive )
+    {
+      init( istr, directive );
+    }
+
+    /*!
+     *  \brief  æªÊuÌæ¾
+     *  \return æª¶ÖÌCe[^ðÔ·
+     */
+    const_iterator begin() const
+    {
+      return const_iterator( container_.begin() );
+    }
+
+    /*!
+     *  \brief  æªÊuÌæ¾
+     *  \return æª¶ÖÌCe[^ðÔ·
+     */
+    iterator begin()
+    {
+      return iterator( container_.begin() );
+    }
+    
+    /*!
+     *  \brief  sÌæ¾
+     *  \param  pos  æª¶©çÌItZbg
+     *  \return posÅwè³ê½ItZbg©çsðßCCe[^ðÔ·
+     */
+    const_iterator line_at(size_type pos) const
+    {
+        typedef text::container::const_iterator const_row_iterator;
+        const_iterator first( container_.begin() ), last( container_.end() );
+        int count = 0 , buf_size , i;
+        size_type sum = 0;
+
+        while((sum < pos) && (first != last))
+        {
+            const_row_iterator current( first.get_row() );
+            buf_size = current->buf.size();
+            sum += buf_size;
+            i = 0;
+            while(i < buf_size)
+            {
+                i++;
+                first++;
+            }
+            count += 1;
+        }
+        
+        if(first < last)
+        {
+            first -= buf_size;
+            return const_iterator(first);
+        }
+        else
+        {
+            return const_iterator( --last );
+        }
+    }   
+    /*!
+     *  \brief  I[Êu+1Ìæ¾
+     *  \return I[¶ÌvfÖÌCe[^ðÔ·
+     */
+    const_iterator end() const
+    {
+      return const_iterator( container_.end() );
+    }
+
+    /*!
+     *  \brief  I[Êu+1Ìæ¾
+     *  \return I[¶ÌvfÖÌCe[^ðÔ·
+     */
+    iterator end()
+    {
+      return iterator( container_.end() );
+    }
+
+    /*!
+     *  \brief  tæªÊuÌæ¾
+     *  \return tæª¶ÖÌtCe[^ðÔ·
+     */
+    const_reverse_iterator rbegin() const
+    {
+      string_type const* pbuf = &container_.back().buf;
+      return const_reverse_iterator( container_.rbegin() + pbuf->empty() ? 0 : pbuf->size()-1 );
+    }
+
+    /*!
+     *  \brief  tæªÊuÌæ¾
+     *  \return tæª¶ÖÌtCe[^ðÔ·
+     */
+    reverse_iterator rbegin()
+    {
+      string_type* pbuf = &container_.back().buf;
+      return reverse_iterator( container_.rbegin() + pbuf->empty() ? 0 : pbuf->size()-1 );
+    }
+
+    /*!
+     *  \brief  tI[Êu+1Ìæ¾
+     *  \return tI[¶ÌvfÖÌtCe[^ðÔ·
+     */
+    const_reverse_iterator rend() const
+    {
+      return const_reverse_iterator( container_.rend() );
+    }
+
+    /*!
+     *  \brief  tI[Êu+1Ìæ¾
+     *  \return tI[¶ÌvfÖÌtCe[^ðÔ·
+     */
+    reverse_iterator rend()
+    {
+      return reverse_iterator( container_.rend() );
+    }
+
+    /*!
+     *  \brief  æª¶ÌQÆ
+     *  \return æª¶ÖÌQÆðÔ·
+     */
+    const_reference front() const
+    {
+      return container_.front().buf[0];
+    }
+
+    /*!
+     *  \brief  æª¶ÌQÆ
+     *  \return æª¶ÖÌQÆðÔ·
+     */
+    reference front()
+    {
+      return container_.front().buf[0];
+    }
+
+    /*!
+     *  \brief  I[¶ÌQÆ
+     *  \return I[¶ÖÌQÆðÔ·
+     */
+    const_reference back() const
+    {
+      string_type const* pbuf = &container_.back().buf;
+      return pbuf->at( pbuf->size()-1 );
+    }
+
+    /*!
+     *  \brief  I[¶ÌQÆ
+     *  \return I[¶ÖÌQÆðÔ·
+     */
+    reference back()
+    {
+      string_type* pbuf = &container_.back().buf;
+      return pbuf->at( pbuf->size()-1 );
+    }
+
+    /*!
+     *  \brief  wèÊuÌ¶ÌQÆ
+     *  \return wèÊuÌ¶ÖÌQÆðÔ·
+     */
+    const_reference at( size_type pos ) const
+    {
+      return container_.front().buf[pos];
+    }
+
+    /*!
+     *  \brief  wèÊuÌ¶ÌQÆ
+     *  \return wèÊuÌ¶ÖÌQÆðÔ·
+     */
+    reference at( size_type pos )
+    {
+      return container_.front().buf[pos];
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðÇÁ
+     *  \param  first ÇÁÉp¢éf[^ñÌæª
+     *  \param  last  ÇÁÉp¢éf[^ñÌI[+1
+     */
+    void append( const_iterator const& first, const_iterator const& last )
+    {
+      if ( first != last )
+      {
+        self_t t( *this );
+        t.init( first, last );
+        swap( t );
+      }
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðÇÁ
+     *  \param  first ÇÁÉp¢éf[^ñÌæª
+     *  \param  last  ÇÁÉp¢éf[^ñÌI[+1
+     *  \note   t@C¼ÆsÔÍÇÁæÌI[ÌàÌðp±µÜ·B
+     *          ÇÁæÉf[^ªÈ¢êÍ"unknown"ÉÈèÜ·B
+     */
+    template < class InputIterator >
+      void append( InputIterator first, InputIterator last )
+    {
+      append( first, last, append_directive );
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðÇÁ
+     *  \param  first ÇÁÉp¢éf[^ñÌæª
+     *  \param  last  ÇÁÉp¢éf[^ñÌI[+1
+     *  \param  directive PsðReiÉi[·é½ßÌ
+     *  \note   t@C¼ÆsÔÍÇÁæÌI[ÌàÌðp±µÜ·B
+     *          ÇÁæÉf[^ªÈ¢êÍ"unknown"ÉÈèÜ·B
+     *
+     *  directive Í void directive( container& cont, line_buf& buf )Ì`®ð
+     *  ÆéÖÖÌ|C^Ü½Ít@N^Å é±ÆðzèµÄ¢Ü·B
+     *  cont ÍàÅf[^Ìi[Égp·éReiA buf ÍPsªÌ¶
+     *  ñÆt@C¼EsÔði[µ½obt@Å·B
+     */
+    template < class InputIterator, class Directive >
+      void append( InputIterator first, InputIterator last, Directive directive )
+    {
+      if ( first != last )
+      {
+        self_t t( *this );
+        t.init( first, last, directive );
+        swap( t );
+      }
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðÇÁ
+     *  \param  istr      ÇÁÉp¢éüÍXg[
+     *  \note   t@C¼ÆsÔÍÇÁæÌI[ÌàÌðp±µÜ·B
+     *          ÇÁæÉf[^ªÈ¢êÍ"unknown"ÉÈèÜ·B
+     */
+    void append( std::basic_istream< CharT, Traits >& istr )
+    {
+      append( istr, append_directive );
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðÇÁ
+     *  \param  istr      ÇÁÉp¢éüÍXg[
+     *  \param  directive PsðReiÉi[·é½ßÌ
+     *  \note   t@C¼ÆsÔÍÇÁæÌI[ÌàÌðp±µÜ·B
+     *          ÇÁæÉf[^ªÈ¢êÍ"unknown"ÉÈèÜ·B
+     *
+     *  directive Í void directive( container& cont, line_buf& buf )Ì`®ð
+     *  ÆéÖÖÌ|C^Ü½Ít@N^Å é±ÆðzèµÄ¢Ü·B
+     *  cont ÍàÅf[^Ìi[Égp·éReiA buf ÍPsªÌ¶
+     *  ñÆt@C¼EsÔði[µ½obt@Å·B
+     */
+    template < class Directive >
+      void append( std::basic_istream< CharT, Traits >& istr, Directive directive )
+    {
+      self_t t( *this );
+      t.init( istr, directive );
+      swap( t );
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðãü
+     *  \param  first ãüÉp¢éf[^ñÌæª
+     *  \param  last  ãüÉp¢éf[^ñÌI[+1
+     */
+    void assign( const_iterator const& first, const_iterator const& last )
+    {
+      self_t t( first, last );
+      swap( t );
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðãü
+     *  \param  first ãüÉp¢éf[^ñÌæª
+     *  \param  last  ãüÉp¢éf[^ñÌI[+1
+     *  \note   t@C¼Í"unknown"ÉÈèÜ·B
+     */
+    template < class InputIterator >
+      void assign( InputIterator first, InputIterator last )
+    {
+      self_t t( first, last, append_directive );
+      swap( t );
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðãü
+     *  \param  first ãüÉp¢éf[^ñÌæª
+     *  \param  last  ãüÉp¢éf[^ñÌI[+1
+     *  \param  directive PsðReiÉi[·é½ßÌ
+     *  \note   t@C¼Í"unknown"ÉÈèÜ·B
+     *
+     *  directive Í void directive( container& cont, line_buf& buf )Ì`®ð
+     *  ÆéÖÖÌ|C^Ü½Ít@N^Å é±ÆðzèµÄ¢Ü·B
+     *  cont ÍàÅf[^Ìi[Égp·éReiA buf ÍPsªÌ¶
+     *  ñÆt@C¼EsÔði[µ½obt@Å·B
+     */
+    template < class InputIterator, class Directive >
+      void assign( InputIterator first, InputIterator last, Directive directive )
+    {
+      self_t t( first, last, directive );
+      swap( t );
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðãü
+     *  \param  istr      ãüÉp¢éüÍXg[
+     *  \note   t@C¼ÆsÔÍãüæÌI[ÌàÌðp±µÜ·B
+     *          ÇÁæÉf[^ªÈ¢êÍ"unknown"ÉÈèÜ·B
+     */
+    void assign( std::basic_istream< CharT, Traits >& istr )
+    {
+      self_t t( istr, append_directive );
+      swap( t );
+    }
+
+    /*!
+     *  \brief  wèÍÍÌeLXgf[^ðãü
+     *  \param  istr      ãüÉp¢éüÍXg[
+     *  \param  directive PsðReiÉi[·é½ßÌ
+     *  \note   t@C¼ÆsÔÍãüæÌI[ÌàÌðp±µÜ·B
+     *          ÇÁæÉf[^ªÈ¢êÍ"unknown"ÉÈèÜ·B
+     *
+     *  directive Í void directive( container& cont, line_buf& buf )Ì`®ð
+     *  ÆéÖÖÌ|C^Ü½Ít@N^Å é±ÆðzèµÄ¢Ü·B
+     *  cont ÍàÅf[^Ìi[Égp·éReiA buf ÍPsªÌ¶
+     *  ñÆt@C¼EsÔði[µ½obt@Å·B
+     */
+    template < class Directive >
+      void assign( std::basic_istream< CharT, Traits >& istr, Directive directive )
+    {
+      self_t t( istr, directive );
+      swap( t );
+    }
+
+    /*!
+     *  \brief  I[É¶ðÇÁ
+     *  \param  value ÇÁ·é¶
+     */
+    void push_back( value_type value )
+    {
+      if ( container_.empty() || container_.back().line.file != line_.file )
+      {
+        line_buf buf( initial_line(), string_type( 1, value ) );
+        container_.push_back( buf );
+      }
+      else
+      {
+        string_type const* pbuf = &container_.back().buf;
+        if ( pbuf->at( pbuf->size()-1 ) == widen( '\n' ) )
+        {
+          ++line_.line;
+          line_buf buf( initial_line(), string_type( 1, value ) );
+          container_.push_back( buf );
+        }
+        else
+        {
+          container_.back().buf += value;
+        }
+      }
+    }
+
+    /*!
+     *  \brief  I[©ç¶ðí
+     */
+    void pop_back()
+    {
+      if ( container_.empty() )
+      {
+        container_.pop_back();
+      }
+      else
+      {
+        string_type const* pbuf = &container_.back().buf;
+        pbuf->resize( pbuf->size()-1 );
+        if ( container_.back().buf.empty() )
+        {
+          container_.pop_back();
+        }
+      }
+    }
+
+    /*!
+     *  \brief  Reiªó©Ç¤©Ì»Ê
+     *  \return óÌêÍ true ðÔ·
+     */
+    bool empty() const
+    {
+      return container_.empty();
+    }
+
+    /*!
+     *  \brief  ReiÌTCY
+     *  \return ReiÉÜÜêÄ¢é¶ðÔ·
+     */
+    size_type size() const
+    {
+      return std::accumulate( container_.begin(), container_.end(), size_type( 0 ), add_line_size );
+    }
+
+    /*!
+     *  \brief  ReiÌð·
+     *  \param  other   ð·ÎÛÆÈéRei
+     */
+    void swap( self_t& other )
+    {
+      container_.swap( other.container_ );
+      line_.swap( other.line_ );
+    }
+
+    /*!
+     *  \brief  ReiÌNA
+     */
+    void clear()
+    {
+      container_.clear();
+      line_.file.clear();
+      line_.line = 0;
+    }
+
+    void set_line( std::string const& file, long line )
+    {
+      line_.file = file;
+      line_.line = line;
+    }
+
+    line_type get_line() const
+    {
+      return line_;
+    }
+  private:
+    //! ¯íÌReiðüÍ³Æ·éú»
+    void init( const_iterator const& first, const_iterator const& last )
+    {
+      line_buf buf( *first.get_row() );
+      if ( first.get_col() > 0 )
+      {
+        buf.buf = buf.buf.substr( first.get_col() );
+      }
+      container_.push_back( buf );
+      std::copy( boost::next( first ).get_row(), last.get_row(), std::back_inserter( container_ ) );
+      buf = *last.get_row();
+      buf.buf = buf.buf.substr( 0, last.get_col() );
+      container_.push_back( buf );
+      line_ = buf.line;
+    }
+
+    //! ÙíÌReiðüÍ³Æ·éú»
+    template < class InputIterator, class Directive >
+      void init( InputIterator first, InputIterator last, Directive directive )
+    {
+      line_buf buf( initial_line() );
+      value_type const nl = widen( '\n' );
+      for ( InputIterator iter = first; iter != last; ++iter )
+      {
+        value_type ch = *iter;
+        buf.buf += ch;
+        if ( ch == nl )
+        {
+          directive( container_, buf );
+          line_ = buf.line;
+        }
+      }
+      if ( !buf.buf.empty() )
+      {
+        container_.push_back( buf );
+      }
+      line_ = buf.line;
+    }
+
+    //! üÍXg[ðüÍ³Æ·éú»
+    template < class Directive >
+      void init( std::basic_istream< CharT, Traits >& istr, Directive directive )
+    {
+      line_buf buf( initial_line() );
+      value_type const nl = widen( '\n' );
+      while ( istr )
+      {
+        value_type ch;
+        istr.get( ch );
+        buf.buf += ch;
+        if ( ch == nl )
+        {
+          directive( container_, buf );
+          line_ = buf.line;
+        }
+      }
+      if ( !buf.buf.empty() )
+      {
+        container_.push_back( buf );
+      }
+      line_ = buf.line;
+    }
+
+    //! t@C¼EsÔÌúîñÌæ¾
+    line_type const initial_line() const
+    {
+      if ( line_.line > 0 )
+      {
+        return line_;
+      }
+      if ( container_.empty() )
+      {
+        return line_type( "unknown", 1 );
+      }
+      return container_.back().line;
+    }
+
+    //! VOoCg¶©çÊ`®Ì¶^ÖÌÏ·
+    static value_type widen( char ch )
+    {
+      return ::toppers::widen< value_type >( ch );
+    }
+
+    //! size ÖàÅgp·éÝZ
+    static size_type add_line_size( size_type value, line_buf const& buf )
+    {
+      return value + buf.buf.size();
+    }
+
+    //! Directive ÌftHg
+    static void append_directive( container& cont, line_buf& buf )
+    {
+      cont.push_back( buf );
+      ++buf.line.line;
+      buf.buf.clear();
+    }
+  private:
+    container container_;
+    line_type line_;
+  };
+
+  typedef basic_text< std::vector, char > text;
+
+  inline text_line const& get_text_line( text::const_iterator iter )
+  {
+    return iter.line();
+  }
+
+  inline text_line const& get_text_line( text::iterator iter )
+  {
+    return iter.line();
+  }
+
+}
+
+#endif  // ! TOPPERS_TEXT_HPP_
Index: /cfg_oil/trunk/toppers/text_line.hpp
===================================================================
--- /cfg_oil/trunk/toppers/text_line.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/text_line.hpp	(revision 8)
@@ -0,0 +1,170 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/text_line.hpp
+ *  \brief  eLXgf[^ÌsÉÖ·éé¾è`
+ *
+ *  ±Ìt@CÅè`³êéNX
+ *  \code
+ *  struct text_line;
+ *  struct basic_line_buf< CharT, Traits, Allocator >;
+ *  \endcode
+ */
+#ifndef TOPPERS_TEXTLINE_HPP_
+#define TOPPERS_TEXTLINE_HPP_
+
+#include <iosfwd>
+#include <string>
+#include <algorithm>
+#include "toppers/config.hpp"
+
+namespace toppers
+{
+
+  /*!
+   *  \struct text_line text_line.hpp "toppers/text_line.hpp"
+   *  \brief  t@C¼ÆsÔÌÛNX
+   */
+  struct text_line
+  {
+    std::string file;   //!< t@C¼
+    long line;          //!< sÔi1`j
+
+    /*!
+     *  \brief  ftHgRXgN^
+     */
+    text_line()
+      : line( 0 )
+    {
+    }
+    /*!
+     *  \brief  RXgN^
+     *  \param  filename  t@C¼
+     *  \param  lineno    sÔ
+     */
+    explicit text_line( std::string const& filename, long lineno = 0 )
+      : file( filename ), line( lineno )
+    {
+    }
+    /*!
+     *  \brief  RXgN^
+     *  \param  filename  t@C¼
+     *  \param  lineno    sÔ
+     */
+    explicit text_line( char const* filename, long lineno = 0 )
+      : file( filename ), line( lineno )
+    {
+    }
+    /*!
+     *  \brief  IuWFNgÌð·
+     *  \param  other   ð·ÎÛÌIuWFNg
+     */
+    void swap( text_line& other ) throw()
+    {
+      std::swap( line, other.line );
+      file.swap( other.file );
+    }
+  };
+
+  /*!
+   *  \struct line_buf text_line.hpp "toppers/text_line.hpp"
+   *  \brief  1 seLXgÌÇNX
+   */
+  template
+  <
+    typename CharT,
+    class Traits = std::char_traits< CharT >,
+    class Allocator = std::allocator< CharT >
+  >
+  struct basic_line_buf
+  {
+    typedef std::basic_string< CharT, Traits, Allocator > string_type;
+
+    string_type buf; //!< sf[^ð\·¶ñ
+    text_line line;  //!< sÔîñ
+
+    /*!
+     *  \brief  ftHgRXgN^
+     */
+    basic_line_buf()
+    {
+    }
+    /*!
+     *  \brief  RXgN^
+     *  \param  line  sÔîñ
+     */
+    basic_line_buf( text_line const& line )
+      : line( line )
+    {
+    }
+    /*!
+     *  \brief  RXgN^
+     *  \param  line  sÔîñ
+     *  \param  data  sf[^
+     */
+    basic_line_buf( text_line const& line, string_type const& data )
+      : buf( data ), line( line )
+    {
+    }
+  };
+
+  //! char ÅÌ 1 seLXgÇNX
+  typedef basic_line_buf< char > line_buf;
+
+  /*!
+   *  \brief  Ce[^ªÛ·ésÔîñÌæ¾
+   *  \param  iter  Ce[^
+   *  \return sÔîñÖÌQÆðÔ·
+   *
+   *  iter Åwèµ½Ce[^ªsÔîñðÛµÄ¢éÈçA»ÌsÔîñðÔµÜ·B
+   *  sÔîñðÛµÄ¢È¢êÍ_~[IuWFNgÖÌQÆðÔµÜ·B
+   */
+  template < class Iterator >
+  inline text_line const& get_text_line( Iterator iter )
+  {
+    static text_line dummy;
+    return dummy;
+  }
+
+}
+
+#endif  // ! TOPPERS_TEXTLINE_HPP_
Index: /cfg_oil/trunk/toppers/ucn_parser.cpp
===================================================================
--- /cfg_oil/trunk/toppers/ucn_parser.cpp	(revision 8)
+++ /cfg_oil/trunk/toppers/ucn_parser.cpp	(revision 8)
@@ -0,0 +1,53 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2005-2008 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*
+ *  toppers/ucn_parser.cpp
+ */
+#include "toppers/c_parser.hpp"
+
+namespace toppers
+{
+
+  //! Û¶¼p[T[
+  boost::spirit::functor_parser< detail::ucn_parse_functor > const ucn_p;
+
+}
Index: /cfg_oil/trunk/toppers/workaround.hpp
===================================================================
--- /cfg_oil/trunk/toppers/workaround.hpp	(revision 8)
+++ /cfg_oil/trunk/toppers/workaround.hpp	(revision 8)
@@ -0,0 +1,80 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ *
+ *  Copyright (C) 2007-2009 by TAKAGI Nobuhisa
+ * 
+ *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
+ *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
+ *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
+ *      ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
+ *        ñ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
+ *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
+ *      ÆÓ·é±ÆD
+ * 
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
+ *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
+ *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
+ *  ÌÓCðíÈ¢D
+ * 
+ */
+
+/*!
+ *  \file   toppers/workaroound.hpp
+ *  \brief  n¢ÎÌ@\ÉÎ·éãÖèi
+ */
+#ifndef TOPPERS_WORKAROUND_HPP_
+#define TOPPERS_WORKAROUND_HPP_
+
+#include "toppers/config.hpp"
+
+#ifndef __STDC_CONSTANT_MACROS
+#define __STDC_CONSTANT_MACROS
+#endif
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS
+#endif
+
+#ifdef TOPPERS_HAS_TR1_LIBRARY
+
+#include <memory>
+#include <cstdint>
+
+#else
+
+#define BOOST_SP_DISABLE_THREADS  1   // shared_ptr Ìr¼§äð}~
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <boost/cstdint.hpp>
+
+namespace std
+{
+  namespace tr1
+  {
+    using namespace boost;
+  }
+}
+
+#endif
+
+#endif  // ! TOPPERS_WORKAROUND_HPP_
