source: NonGTP/Boost/boost/spirit/core/composite/no_actions.hpp @ 857

Revision 857, 4.1 KB checked in by igarcia, 19 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 1998-2003 Joel de Guzman
3    Copyright (c) 2003 Vaclav Vesely
4    http://spirit.sourceforge.net/
5
6    Use, modification and distribution is subject to the Boost Software
7    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8    http://www.boost.org/LICENSE_1_0.txt)
9=============================================================================*/
10#if !defined(BOOST_SPIRIT_NO_ACTIONS_HPP)
11#define BOOST_SPIRIT_NO_ACTIONS_HPP
12
13#include <boost/spirit/core/parser.hpp>
14#include <boost/spirit/core/composite/composite.hpp>
15#include <boost/spirit/core/non_terminal/rule.hpp>
16
17namespace boost {
18namespace spirit {
19//-----------------------------------------------------------------------------
20// no_actions_action_policy
21
22template<typename BaseT = action_policy>
23struct no_actions_action_policy:
24    public BaseT
25{
26    typedef BaseT base_t;
27
28    no_actions_action_policy():
29        BaseT()
30    {}
31
32    template<typename PolicyT>
33    no_actions_action_policy(PolicyT const& other):
34        BaseT(other)
35    {}
36
37    template<typename ActorT, typename AttrT, typename IteratorT>
38    void
39    do_action(
40        ActorT const&       actor,
41        AttrT&              val,
42        IteratorT const&    first,
43        IteratorT const&    last) const
44    {}
45};
46
47//-----------------------------------------------------------------------------
48// no_actions_scanner
49
50template<typename ScannerT = scanner<> >
51struct no_actions_scanner
52{
53    typedef scanner_policies<
54        typename ScannerT::iteration_policy_t,
55        typename ScannerT::match_policy_t,
56        no_actions_action_policy<typename ScannerT::action_policy_t>
57    > policies_t;
58
59    typedef typename
60        rebind_scanner_policies<ScannerT, policies_t>::type type;
61};
62
63#if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1
64
65template<typename ScannerT = scanner<> >
66struct no_actions_scanner_list
67{
68    typedef
69        scanner_list<
70            ScannerT,
71            typename no_actions_scanner<ScannerT>::type
72        >
73            type;
74};
75
76#endif // BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1
77
78//-----------------------------------------------------------------------------
79// no_actions_parser
80
81struct no_actions_parser_gen;
82
83template<typename ParserT>
84struct no_actions_parser:
85    public unary<ParserT, parser<no_actions_parser<ParserT> > >
86{
87    typedef no_actions_parser<ParserT>      self_t;
88    typedef unary_parser_category           parser_category_t;
89    typedef no_actions_parser_gen           parser_generator_t;
90    typedef unary<ParserT, parser<self_t> > base_t;
91
92    template<typename ScannerT>
93    struct result
94    {
95        typedef typename parser_result<ParserT, ScannerT>::type type;
96    };
97
98    no_actions_parser(ParserT const& p)
99    :   base_t(p)
100    {}
101
102    template<typename ScannerT>
103    typename result<ScannerT>::type
104    parse(ScannerT const& scan) const
105    {
106        typedef typename no_actions_scanner<ScannerT>::policies_t policies_t;
107
108        return this->subject().parse(scan.change_policies(policies_t(scan)));
109    }
110};
111
112//-----------------------------------------------------------------------------
113// no_actions_parser_gen
114
115struct no_actions_parser_gen
116{
117    template<typename ParserT>
118    struct result
119    {
120        typedef no_actions_parser<ParserT> type;
121    };
122
123    template<typename ParserT>
124    static no_actions_parser<ParserT>
125    generate(parser<ParserT> const& subject)
126    {
127        return no_actions_parser<ParserT>(subject.derived());
128    }
129
130    template<typename ParserT>
131    no_actions_parser<ParserT>
132    operator[](parser<ParserT> const& subject) const
133    {
134        return no_actions_parser<ParserT>(subject.derived());
135    }
136};
137
138//-----------------------------------------------------------------------------
139// no_actions_d
140
141const no_actions_parser_gen no_actions_d = no_actions_parser_gen();
142
143//-----------------------------------------------------------------------------
144} // namespace spirit
145} // namespace boost
146
147#endif // !defined(BOOST_SPIRIT_NO_ACTIONS_HPP)
Note: See TracBrowser for help on using the repository browser.