Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

line_parser.cpp


SourceForge.net Logo     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;
}
This program displays the following output:
Line: line1
Line: line2
Line: line3



Copyright © 1997-2006 Igor Kholodov mailto:cttl@users.sourceforge.net.

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.


Generated on Thu Nov 2 17:44:55 2006 for Common Text Transformation Library by  doxygen 1.3.9.1