CTTL on
SourceForge |
Download
Latest |
Documentation
Index |
Library
News |
CVS
Repository |
Other
Links |
Demonstrates text line parser which uses asymmetric quote, quote(true,RM,RR)
, to parse individual lines inside user input.
// sample code: line_parser.cpp // demonstrates text line parser that uses quote( true, middle_expr, right_expr ) //#define CTTL_TRACE_EVERYTHING //define to turn tracing on //#define CTTL_TRACE_RULES //define to turn light tracing on #include "cttl/cttl.h" using namespace cttl; int main() { input<> inp( "line1\nline2\nline3" ); const_edge<> universe( new_edge( inp ) ); const_edge<> line( new_edge( inp ) ); while ( universe.length() && quote( true, line( entity() ), '\n' | end() ).match( universe ) != std::string::npos ) { std::cout << "Line: " << line.text() << std::endl; } return 0; }
Line: line1 Line: line2 Line: line3
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.