Changeset 44608


Ignore:
Timestamp:
Apr 20, 2008, 1:42:27 AM (10 years ago)
Author:
Hartmut Kaiser
Message:

Spirit.Lex: First version of wrapped semantic actions.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp

    r44478 r44608  
    2121#include <boost/spirit/home/support/detail/lexer/state_machine.hpp>
    2222#include <boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp>
     23#include <boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp>
    2324
    2425#if 0 != __COMO_VERSION__ || !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
     
    4748
    4849            typedef unused_type semantic_actions_type;
     50
     51            typedef
     52                detail::wrap_action<unused_type, iterpair_type, Data>
     53            wrap_action_type;
    4954
    5055            // initialize the shared data
     
    8489        {
    8590            typedef Data<Iterator, mpl::false_, mpl::false_> base_type;
    86            
     91
    8792            // initialize the shared data
    8893            template <typename IterData>
     
    128133            char_type;
    129134
    130             typedef void functor_type(iterpair_type, std::size_t, Data&, bool&);
     135            typedef void functor_type(iterpair_type, std::size_t, bool&, Data&);
    131136            typedef boost::function<functor_type> functor_wrapper_type;
    132137            typedef std::multimap<std::size_t, functor_wrapper_type>
    133138                semantic_actions_type;
     139
     140            typedef
     141                detail::wrap_action<functor_wrapper_type, iterpair_type, Data>
     142            wrap_action_type;
    134143
    135144            template <typename IterData>
     
    155164                while (p.first != p.second)
    156165                {
    157                     ((*p.first).second)(itp, id, *this, match);
     166                    ((*p.first).second)(itp, id, match, *this);
    158167                    if (!match)
    159168                        return false;   // return a 'no-match'
     
    231240    public:
    232241        lexertl_functor()
    233 #if 0 != __DECCXX_VER || BOOST_INTEL_CXX_VERSION > 900 || defined(__PGI)
     242#if /*0 != __DECCXX_VER || BOOST_INTEL_CXX_VERSION > 900 || */defined(__PGI)
    234243          : eof()
    235244#endif // 0 != __DECCXX_VER
     
    248257        typedef typename shared::semantic_actions_type semantic_actions_type;
    249258
     259        // this is needed to wrap the semantic actions in a proper way
     260        typedef typename shared::wrap_action_type wrap_action_type;
     261
     262        ///////////////////////////////////////////////////////////////////////
    250263        template <typename MultiPass>
    251264        static result_type& get_next(MultiPass& mp, result_type& result)
  • trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_lexer.hpp

    r44541 r44608  
    294294            value_type;
    295295           
    296             actions.insert(value_type(id, act));
     296            typedef typename Functor::wrap_action_type wrapper_type;
     297
     298            actions.insert(value_type(id, wrapper_type::call(act)));
    297299        }
    298300               
  • trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp

    r44358 r44608  
    5151            typedef unused_type semantic_actions_type;
    5252
     53            typedef
     54                detail::wrap_action<unused_type, iterpair_type, Data>
     55            wrap_action_type;
     56
    5357            // initialize the shared data
    5458            template <typename IterData>
     
    122126            char_type;
    123127
    124             typedef void functor_type(iterpair_type, std::size_t, Data&, bool&);
     128            typedef void functor_type(iterpair_type, std::size_t, bool&, Data&);
    125129            typedef boost::function<functor_type> functor_wrapper_type;
    126130            typedef std::multimap<std::size_t, functor_wrapper_type>
    127131                semantic_actions_type;
     132
     133            typedef
     134                detail::wrap_action<functor_wrapper_type, iterpair_type, Data>
     135            wrap_action_type;
    128136
    129137            template <typename IterData>
     
    149157                while (p.first != p.second)
    150158                {
    151                     ((*p.first).second)(itp, id, *this, match);
     159                    ((*p.first).second)(itp, id, match, *this);
    152160                    if (!match)
    153161                        return false;   // return a 'no-match'
     
    225233    public:
    226234        lexertl_static_functor()
    227 #if 0 != __DECCXX_VER || BOOST_INTEL_CXX_VERSION > 900
    228           , eof()
     235#if /*0 != __DECCXX_VER || BOOST_INTEL_CXX_VERSION > 900 || */defined(__PGI)
     236          : eof()
    229237#endif // 0 != __DECCXX_VER
    230238        {}
     
    243251        typedef typename shared::next_token_functor next_token_functor;
    244252
     253        // this is needed to wrap the semantic actions in a proper way
     254        typedef typename shared::wrap_action_type wrap_action_type;
     255
     256        ///////////////////////////////////////////////////////////////////////
    245257        template <typename MultiPass>
    246258        result_type& operator()(MultiPass& mp, result_type& result)
  • trunk/libs/spirit/example/lex/word_count_lexer.cpp

    r44360 r44608  
    3434
    3535//[wcl_includes
     36#include <boost/spirit/include/support_argument.hpp>
    3637#include <boost/spirit/include/lex_lexer_lexertl.hpp>
    3738#include <boost/spirit/include/phoenix_operator.hpp>
     
    7879        // Using the wrong placeholders leads to subtle compilation errors
    7980        // which are difficult to backtrack to their cause.
    80         using boost::phoenix::arg_names::_1;
     81        using boost::spirit::arg_names::_1;
    8182
    8283        // associate tokens with the lexer
Note: See TracChangeset for help on using the changeset viewer.