~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/spirit/core/non_terminal/parser_id.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=============================================================================
 
2
    Spirit v1.6.1
 
3
    Copyright (c) 2001-2003 Joel de Guzman
 
4
    Copyright (c) 2001 Daniel Nuffer
 
5
    http://spirit.sourceforge.net/
 
6
 
 
7
    Permission to copy, use, modify, sell and distribute this software is
 
8
    granted provided this copyright notice appears in all copies. This
 
9
    software is provided "as is" without express or implied warranty, and
 
10
    with no claim as to its suitability for any purpose.
 
11
=============================================================================*/
 
12
#if !defined(BOOST_SPIRIT_PARSER_ID_HPP)
 
13
#define BOOST_SPIRIT_PARSER_ID_HPP
 
14
 
 
15
///////////////////////////////////////////////////////////////////////////////
 
16
namespace boost { namespace spirit {
 
17
 
 
18
    class parser_id
 
19
    {
 
20
    public:
 
21
                    parser_id()                     : p(0) {}
 
22
        explicit    parser_id(void const* prule)    : p(prule) {}
 
23
                    parser_id(long l_)              : l(l_) {}
 
24
 
 
25
        bool operator==(parser_id const& x) const   { return p == x.p; }
 
26
        bool operator!=(parser_id const& x) const   { return !(*this == x); }
 
27
        bool operator<(parser_id const& x) const    { return p < x.p; }
 
28
        long to_long() const                        { return l; }
 
29
 
 
30
    private:
 
31
 
 
32
        union
 
33
        {
 
34
            void const* p;
 
35
            long l;
 
36
        };
 
37
    };
 
38
 
 
39
    #if defined(BOOST_SPIRIT_DEBUG)
 
40
    inline std::ostream&
 
41
    operator<<(std::ostream& out, parser_id const& rid)
 
42
    {
 
43
        out << rid.to_long();
 
44
        return out;
 
45
    }
 
46
    #endif
 
47
 
 
48
    ///////////////////////////////////////////////////////////////////////////
 
49
    //
 
50
    //  parser_address_tag class: tags a parser with its address
 
51
    //
 
52
    ///////////////////////////////////////////////////////////////////////////
 
53
    struct parser_address_tag
 
54
    {
 
55
        template <typename ParserT>
 
56
        static parser_id id(ParserT const& p)
 
57
        { return parser_id(&p); }
 
58
    };
 
59
 
 
60
    ///////////////////////////////////////////////////////////////////////////
 
61
    //
 
62
    //  parser_tag class: tags a parser with an integer ID
 
63
    //
 
64
    ///////////////////////////////////////////////////////////////////////////
 
65
    template <int N>
 
66
    struct parser_tag
 
67
    {
 
68
        template <typename ParserT>
 
69
        static parser_id id(ParserT const& p)
 
70
        { return parser_id(long(N)); }
 
71
    };
 
72
 
 
73
///////////////////////////////////////////////////////////////////////////////
 
74
}} // namespace boost::spirit
 
75
 
 
76
#endif
 
77