1 // Copyright (c) 2001-2011 Hartmut Kaiser 2 // 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #ifndef BOOST_SPIRIT_LEX_LEXER_SEQUENCE_HPP 7 #define BOOST_SPIRIT_LEX_LEXER_SEQUENCE_HPP 8 9 #if defined(_MSC_VER) 10 #pragma once 11 #endif 12 13 #include <boost/spirit/home/lex/domain.hpp> 14 #include <boost/spirit/home/lex/lexer_type.hpp> 15 #include <boost/spirit/home/lex/meta_compiler.hpp> 16 #include <boost/spirit/home/lex/detail/sequence_function.hpp> 17 #include <boost/fusion/include/any.hpp> 18 #include <boost/proto/operators.hpp> 19 #include <boost/proto/tags.hpp> 20 21 namespace boost { namespace spirit 22 { 23 /////////////////////////////////////////////////////////////////////////// 24 // Enablers 25 /////////////////////////////////////////////////////////////////////////// 26 template <> 27 struct use_operator<lex::domain, proto::tag::bitwise_or> // enables | 28 : mpl::true_ {}; 29 30 template <> 31 struct flatten_tree<lex::domain, proto::tag::bitwise_or> // flattens | 32 : mpl::true_ {}; 33 34 }} 35 36 namespace boost { namespace spirit { namespace lex 37 { 38 template <typename Elements> 39 struct sequence : nary_lexer<sequence<Elements> > 40 { sequenceboost::spirit::lex::sequence41 sequence(Elements const& elements) 42 : elements(elements) {} 43 44 template <typename LexerDef, typename String> collectboost::spirit::lex::sequence45 void collect(LexerDef& lexdef, String const& state 46 , String const& targetstate) const 47 { 48 typedef detail::sequence_collect_function<LexerDef, String> 49 collect_function_type; 50 collect_function_type f (lexdef, state, targetstate); 51 fusion::any(elements, f); 52 } 53 54 template <typename LexerDef> add_actionsboost::spirit::lex::sequence55 void add_actions(LexerDef& lexdef) const 56 { 57 detail::sequence_add_actions_function<LexerDef> f (lexdef); 58 fusion::any(elements, f); 59 } 60 61 Elements elements; 62 }; 63 64 /////////////////////////////////////////////////////////////////////////// 65 // Lexer generator: make_xxx function (objects) 66 /////////////////////////////////////////////////////////////////////////// 67 template <typename Elements, typename Modifiers> 68 struct make_composite<proto::tag::bitwise_or, Elements, Modifiers> 69 : make_nary_composite<Elements, sequence> 70 {}; 71 72 }}} // namespace boost::spirit::lex 73 74 #endif 75