cfg_.cpp

00001 /*
00002  *  TOPPERS/FDMP Kernel
00003  *      Toyohashi Open Platform for Embedded Real-Time Systems/
00004  *      Function Distributed Multiprocessor Kernel
00005  *
00006  *  Copyright (C) 2005 by Takagi Nobuhisa
00007  * 
00008  *  上記著作権者は,以下の (1)〜(4) の条件か,Free Software Foundation 
00009  *  によって公表されている GNU General Public License の Version 2 に記
00010  *  述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
00011  *  を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
00012  *  利用と呼ぶ)することを無償で許諾する.
00013  *  (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
00014  *      権表示,この利用条件および下記の無保証規定が,そのままの形でソー
00015  *      スコード中に含まれていること.
00016  *  (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
00017  *      用できる形で再配布する場合には,再配布に伴うドキュメント(利用
00018  *      者マニュアルなど)に,上記の著作権表示,この利用条件および下記
00019  *      の無保証規定を掲載すること.
00020  *  (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
00021  *      用できない形で再配布する場合には,次のいずれかの条件を満たすこ
00022  *      と.
00023  *    (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
00024  *        作権表示,この利用条件および下記の無保証規定を掲載すること.
00025  *    (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
00026  *        報告すること.
00027  *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
00028  *      害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
00029  * 
00030  *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
00031  *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
00032  *  含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
00033  *  接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
00034  * 
00035  */
00036 
00037 #include "toppers/text.hpp"
00038 #include "toppers/c_expr.hpp"
00039 #include "toppers/itron/static_api.hpp"
00040 #include <iostream>
00041 #include <iomanip>
00042 #include <iterator>
00043 #include <string>
00044 #include <boost/spirit/tree/parse_tree.hpp>
00045 #include <boost/spirit/tree/ast.hpp>
00046 #include <boost/spirit/tree/tree_to_xml.hpp>
00047 
00048 using namespace std;
00049 using namespace boost::spirit;
00050 using namespace toppers;
00051 
00052 struct test_expr : c_expr_grammar_base<test_expr>
00053 {
00054   typedef c_expr_grammar_base<test_expr> base_t;
00055 
00056   template <class Scanner>
00057   struct definition : base_t::definition<Scanner>
00058   {
00059     definition( const test_expr& self ) : base_t::definition<Scanner>( self ) {}
00060     const rule_t& start() const { return constant_expression; };
00061   };
00062 
00063   explicit test_expr( bool ucn = false, codeset_t codeset = ascii ) : c_expr_grammar_base<test_expr>( ucn, codeset ) {}
00064 };
00065 
00066 typedef itron::static_api_grammar test_static_api;
00067 
00068 int main()
00069 {
00070 #if 1
00071   c_const_expr_grammar cexpr_p( true, shift_jis );
00072   test_static_api api( cexpr_p );
00073   string str;
00074   
00075   while ( cout << "# ", getline( cin, str ) )
00076   {
00077     cout << str << endl;
00078     if ( str == "q" )
00079       break;
00080 //    parse_info<string::const_iterator> info = parse( str.begin(), str.end(), api, space_p );
00081     tree_parse_info<const char*> pt_info = pt_parse( str.c_str(), api, space_p );
00082     cout << ( pt_info.full ? "okay" : "fail" ) << endl;
00083 //    tree_to_xml( cout, pt_info.trees );
00084 
00085     itron::static_api test;
00086     bool result = test.analyze( pt_info.trees[0].children[0].children.begin(), pt_info.trees[0].children[0].children.end() );   
00087     cout << boolalpha << result << endl;
00088     for ( itron::static_api::const_iterator iter = test.begin(); iter != test.end(); ++iter )
00089     {
00090       cout << *iter << ' ';
00091     }
00092     cout << endl;
00093   }
00094 #endif
00095 
00096 #if 0
00097   test_expr expr( true, shift_jis );
00098   string str;
00099   
00100   while ( cout << "# ", getline( cin, str ) )
00101   {
00102     cout << str << endl;
00103     if ( str == "q" )
00104       break;
00105     parse_info<string::const_iterator> info = parse( str.begin(), str.end(), expr, space_p );
00106     cout << ( info.full ? "okay" : "fail" ) << endl;
00107 
00108     tree_parse_info<const char*> pt_info = ast_parse( str.c_str(), expr, space_p );
00109     tree_to_xml( cout, pt_info.trees );
00110   }
00111 #endif
00112 
00113 #if 0
00114   toppers::text t;
00115   t.assign( std::cin );
00116   for ( toppers::text::const_iterator iter = t.begin(); iter != t.end(); iter+=1 )
00117   {
00118     std::cout << "(" << iter.line().file_.string() << ", " << iter.line().line_ << ") " << *iter << std::endl;
00119   }
00120 #endif
00121 
00122 #if 0
00123   integer_parser<> parser;
00124   string str( "12345678" );
00125   cout << str << endl;
00126   parse_info<string::const_iterator> info = parse( str.begin(), str.end(), parser );
00127   cout << ( info.full ? "okay" : "fail" ) << endl;
00128 //  cout << parser.value() << endl;
00129 #endif
00130 
00131 #if 0
00132   string str( "\"あい\x2f\25う\u3124abc\\\"表\"" );
00133   cout << str << endl;
00134   parse_info<string::const_iterator> info = parse( str.begin(), str.end(), c_strlit_parser( shift_jis ) );
00135   cout << ( info.full ? "okay" : "fail" ) << endl;
00136 #endif
00137 
00138 #if 0
00139   ucn_parser parser;
00140   string str( "\\u1234");
00141   cout << str << endl;
00142   parse_info<string::const_iterator> info = parse( str.begin(), str.end(), parser, space_p );
00143   cout << ( info.full ? "okay" : "fail" ) << endl;
00144 #endif
00145 
00146 #if 0
00147   string str( "_abc\\u3526345" );
00148   cout << str << endl;
00149   parse_info<string::const_iterator> info = parse( str.begin(), str.end(), c_ident_p );
00150   cout << ( info.full ? "okay" : "fail" ) << endl;
00151 #endif
00152 
00153   return 0;
00154 }

Copyright © 2006 by TAKAGI Nobuhisa.
このページは Wed Apr 12 16:31:55 2006 に Doxygen によって生成されました。