CTTL on
SourceForge |
Download
Latest |
Documentation
Index |
Library
News |
CVS
Repository |
Other
Links |
Demonstrates policy_space< flag_follow_region >
, a white space policy that relies on pre-defined regions of the input text.
// sample code: client_regions.cpp // demonstrates // const_edge< policy_space< flag_follow_region > > //#define CTTL_TRACE_EVERYTHING //#define CTTL_TRACE_RULES //define to turn light tracing on //#define CTTL_TRACE_TRIVIAL //define for trace messages only mode #include <iostream> #include "cttl/cttl.h" using namespace cttl; int main() { input<> inp( "0123456789" ); std::cout << " the input is /" << inp.text() << '/' << std::endl << "valid chars are /" ; policy_space< flag_follow_region > void_region; void_region.region_insert( 0, 1 ); void_region.region_insert( 9, 10 ); void_region.region_insert( 5, 8 ); size_t valid_offset = 0; while ( valid_offset < inp.length() ) { valid_offset = void_region.lower_bound( valid_offset, inp.length() ); if ( valid_offset >= inp.length() ) break; std::cout << inp.text()[ valid_offset ]; ++valid_offset; } const_edge< policy_space< flag_follow_region > > universe( new_edge( inp ), void_region ); std::cout << '/' << std::endl << " universe.region_difference() is /" << universe.region_difference() << '/' << std::endl ; universe.first.go_bof(); universe.second.go_eof(); const_edge<> data( new_edge( inp ) ); std::cout << "the symbols are /" ; while( ( data( !first( isdigit ) ) ).match( universe ) != std::string::npos ) std::cout << data.text() ; std::cout << '/' << std::endl ; return 0; }
the input is /0123456789/ valid chars are /12348/ region diff is /12348/ the symbols are /12348/
Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.