lalr/AddLexerActionHandler.hpp
2018-04-03 19:09:26 +12:00

28 lines
902 B
C++

#ifndef LALR_ADDLEXERACTIONHANDLER_HPP_INCLUDED
#define LALR_ADDLEXERACTIONHANDLER_HPP_INCLUDED
#include <functional>
namespace lalr
{
template <class Iterator, class Char, class Traits, class Allocator> class Lexer;
/**
// A helper that provides a convenient syntax for adding handlers to a %Lexer.
*/
template <class Iterator, class Char, class Traits, class Allocator>
class AddLexerActionHandler
{
typedef std::function<void (Iterator* begin, Iterator end, std::basic_string<Char, Traits, Allocator>* lexeme, const void** symbol)> LexerActionFunction;
Lexer<Iterator, Char, Traits, Allocator>* lexer_; ///< The Lexer to add handlers to.
public:
AddLexerActionHandler( Lexer<Iterator, Char, Traits, Allocator>* lexer );
const AddLexerActionHandler& operator()( const char* identifier, LexerActionFunction function ) const;
};
}
#endif