OSDN Git Service

Merge branch 'master' of github.com:myun2/roast_work into refact_2011_07
authorMyun2 <myun2@nwhite.info>
Tue, 29 May 2012 09:28:29 +0000 (18:28 +0900)
committerMyun2 <myun2@nwhite.info>
Tue, 29 May 2012 09:28:29 +0000 (18:28 +0900)
1  2 
roast/include/roast/lexical/util.hpp

@@@ -5,9 -5,8 +5,10 @@@
  #define __SFJP_ROAST__lexical__util_HPP__
  
  //#include <string>   //      str_generate()
+ #include "roast/lexical/iterator_util.hpp"
  #include "roast/stream/string_stream.hpp"
 +#include "roast/stream/console_stream.hpp"
 +//#include <iostream>
  
  namespace roast
  {
                        return to_string(r, null_document);
                }
                
+               template <typename _Rule>
+               ::std::string to_string2(_Rule& r)
+               {
+                       
+                       ::std::string s;
+                       ::roast::string_output_stream ss(s);
+                       //generate(ss,r);
+                       //if ( r.generate(ss,doc) == false )
+                       r.generate(ss,r);
+                       return s;
+               }
+               
                //////////////////////////////////////////////////////////////////////////////////
 +
 +              template <typename _Rule, typename _Document>
 +              void print(_Rule& r, _Document& doc){
 +                      //r.generate(::std::cout, doc);
 +                      r.generate(::roast::stream::cout, doc);
 +              }
 +
 +              template <typename _Rule>
 +              void print(_Rule& r){
 +                      //r.generate(::std::cout, doc);
 +                      r.generate(::roast::stream::cout, null_document);
 +              }
 +              
 +              //////////////////////////////////////////////////////////////////////////////////
        }
+       
+       template <typename _Rule>
+       ::std::string lex_to_string(_Rule& r)
+       {
+               return lexical::to_string2(r);
+       }
  }
  
  #include "roast/lexical/iterator_util.hpp"