Check-in [81c17f4e8b]

Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:81c17f4e8b46b2a6f283949c7c2d4fb04fa1ef6f
Date: 2008-09-18 18:57:39
User: stephan
Comment:added test of C comment parser
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to test.cpp

Old (f12927700b2af25c) New (cd60735783c556d4)
1 //////////////////////////////////////////////////////////////////////// 1 ////////////////////////////////////////////////////////////////////////
2 // Test/demo code for flatestream 2 // Test/demo code for flatestream
3 //////////////////////////////////////////////////////////////////////// 3 ////////////////////////////////////////////////////////////////////////
4 #include <iostream> 4 #include <iostream>
5 #include <iterator> 5 #include <iterator>
7 #define COUT std::cout << __FILE__ << ":" << std::dec << __LINE__ << " : " 7 #define COUT std::cout << __FILE__ << ":" << std::dec << __LINE__ << " : "
8 8
9 #include "parsepp.hpp" 9 #include "parsepp.hpp"
10 #include "parsepp_numeric.hpp" 10 #include "parsepp_numeric.hpp"
11 #include "parsepp_calc.hpp" 11 #include "parsepp_calc.hpp"
> 12 #include "parsepp_url.hpp"
> 13 #include "parsepp_cish.hpp"
> 14 #include "parsepp_err.hpp"
12 #include "parsepp_append.hpp" 15 #include "parsepp_append.hpp"
13 16
14 struct MyAction 17 struct MyAction
15 { 18 {
16 template <typename ClientState> 19 template <typename ClientState>
98 hidden lines
115 std::copy( accum.begin(), accum.end(), 118 std::copy( accum.begin(), accum.end(),
116 std::ostream_iterator<std::string>(std::cout,"\n") ); 119 std::ostream_iterator<std::string>(std::cout,"\n") );
117 120
118 } 121 }
119 122
> 123 void do_generic()
> 124 {
> 125 using namespace Ps;
> 126
> 127 COUT << "****************************** generic stuff:\n";
> 128 typedef std::vector<std::string> ListT;
> 129 ListT vec;
> 130 vec.push_back("/** closed C comment*/");
> 131 vec.push_back("/** unclosed C comment\n\nand going... going...");
> 132
> 133 typedef r_comment_c MyRule;
> 134
> 135 ListT::const_iterator it = vec.begin();
> 136 ListT accum;
> 137 for( ; vec.end() != it; ++it )
> 138 {
> 139 try
> 140 {
> 141 std::string arg = *it;
> 142 COUT << "Trying: " << arg << '\n';
> 143 if( parse< MyRule >( arg, accum ) )
> 144 {
> 145 COUT << "OK: " << arg <<'\n';
> 146 }
> 147 else
> 148 {
> 149 CERR << "parse failed for: " << arg << '\n';
> 150 }
> 151 }
> 152 catch( std::exception const & ex )
> 153 {
> 154 CERR << "Exception: " << ex.what() << '\n';
> 155 }
> 156 }
> 157 COUT << "accum.size() == " <<accum.size()<<" Entries:\n";
> 158 std::copy( accum.begin(), accum.end(),
> 159 std::ostream_iterator<std::string>(std::cout,"\n") );
> 160
> 161 }
> 162
120 163
121 164
122 int main(int argc, char *argv[]) 165 int main(int argc, char *argv[])
123 { 166 {
124 try 167 try
125 { 168 {
126 do_parse(); 169 do_parse();
127 do_calc(); 170 do_calc();
128 do_append(); 171 do_append();
> 172 do_generic();
129 } 173 }
130 catch(std::exception const & ex) 174 catch(std::exception const & ex)
131 { 175 {
132 CERR << "EXCEPTION: " << ex.what() << '\n'; 176 CERR << "EXCEPTION: " << ex.what() << '\n';
133 return 1; 177 return 1;
134 } 178 }
135 return 0; 179 return 0;
136 } 180 }
137 #undef DO_PARSE 181 #undef DO_PARSE