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

action_handler.cpp


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

Demonstrates semantic action implemented as member function template:

// sample code: action_handler.cpp
// demonstrates semantic action implemented as member function template.

#include "cttl/cttl.h"

using namespace cttl;

class handler
{
    //...
public:
    template< typename UniverseT >
    size_t action( UniverseT& universe_ )
    {
        //...
        return universe_.first.offset();
    }
};


int main(int argc, char* argv[])
{
    input<> inp;                            // construct input object
    typedef const_edge<> universe_T;        // type of parseable universe
    universe_T universe( new_edge( inp ) ); // construct universe
    handler sa_handler;                     // handler class implements
                                            // semantic actions
    // VC7.1 error C2784 workaround:
    typedef size_t ( handler::* action_T ) ( universe_T& );
    
    size_t result = rule(
        sa_handler,
        action_T( &handler::action< universe_T > )
        ).match( universe );

    assert( result != std::string::npos );  // assert that match 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:54 2006 for Common Text Transformation Library by  doxygen 1.3.9.1