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