IntroductionEvery lexer, which should be used in conjunction with the Wave library, has to return tokens formed from the input stream. These tokens should conform to the synopsis described in the topic The Token Type. The lexer type should expose an interface which conforms at least to a forward_iterator (in the sense defined by the the C++ Standard) returning the token type. The code sample below does not show the definition of this forward iterator interface because this is highly implementation defined. Wave lexer synopsis (header: wave/cpplexer/cpp_lexer_interface.hpp)struct lex_iterator { typedef boost::wave::lex_token<> token_type; // Every lex_iterator should implement at least a complete // forward_iterator interface (not shown here) typedef std::forward_iterator_tag iterator_category; // additional requirements lex_iterator(); template <typename Iterator> lex_iterator(Iterator const &first, Iterator const &last typename token_type::position_type const &pos, boost::wave::language_support language) }; Please note, that the lex_iterator defined in the library header wave/cpplexer/cpp_lexer_interface.hpp actually is a template class taking the token type to use as its template parameter. This is omitted in the synopsis above because it is an implementation detail of the Re2C lexer provided as part of the Wave library. If you want to use Wave in conjunction with your own lexing component this will have to conform to the interface described above only. Public TypedefsBesides the typedefs mandated for a forward_iterator by the C++ standard every lexer to be used with the Wave library should define the following typedefs:
Member functionsBesides the functions, which should be provided for forward_iterators as mandated by the C++ Standard, every lexer must implement the following functions to be used with the Wave library: lex_iterator();
template <typename Iterator> lex_iterator(Iterator const &first, Iterator const &last, typename token_type::position_type const &pos, boost::wave::language_support language);
Copyright © 2003-2008 Hartmut Kaiser Last updated: Sunday, October 12, 2008 20:15 |