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

runtime_match.cpp


SourceForge.net Logo     CTTL on    
    SourceForge    
    Download    
    Latest    
    Documentation    
    Index    
    Library    
    News    
    CVS    
    Repository    
   Other    
   Links    

Program demonstrating application of runtime_match() grammar evaluation method, employed to support subrule searches.

// sample code: runtime_match.cpp

#include <iostream>
#define CTTL_TRACE_EVERYTHING   //define to turn tracing on
#include "cttl/cttl.h"

using namespace cttl;

struct parser {
    size_t subrule( const_edge< policy_space<> >& edge_ )
    {
        return ( symbol( "yellow" ) + "taxi" ).runtime_match( edge_ );
    }

    size_t start( const_edge< policy_space<> >& edge_ )
    {
        return ( !!rule( *this, &parser::subrule ) ).match( edge_ );
    }
};

int main()
{
    input<> inp( "yellow pages were found in yellow taxi" );
    const_edge< policy_space<> > U( new_edge( inp ) );
    parser parser_taxi;
    size_t P = parser_taxi.start( U );
    assert( P != std::string::npos );   // assert bang_find() succeeded
    return 0;
}



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:56 2006 for Common Text Transformation Library by  doxygen 1.3.9.1