1
/*=============================================================================
3
Copyright (c) 2001-2003 Joel de Guzman
4
Copyright (c) 2001 Daniel Nuffer
5
http://spirit.sourceforge.net/
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
15
///////////////////////////////////////////////////////////////////////////////
16
namespace boost { namespace spirit {
22
explicit parser_id(void const* prule) : p(prule) {}
23
parser_id(long l_) : l(l_) {}
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; }
39
#if defined(BOOST_SPIRIT_DEBUG)
41
operator<<(std::ostream& out, parser_id const& rid)
48
///////////////////////////////////////////////////////////////////////////
50
// parser_address_tag class: tags a parser with its address
52
///////////////////////////////////////////////////////////////////////////
53
struct parser_address_tag
55
template <typename ParserT>
56
static parser_id id(ParserT const& p)
57
{ return parser_id(&p); }
60
///////////////////////////////////////////////////////////////////////////
62
// parser_tag class: tags a parser with an integer ID
64
///////////////////////////////////////////////////////////////////////////
68
template <typename ParserT>
69
static parser_id id(ParserT const& p)
70
{ return parser_id(long(N)); }
73
///////////////////////////////////////////////////////////////////////////////
74
}} // namespace boost::spirit