First public contribution.
1 /*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
3 Copyright (c) 2002-2003 Hartmut Kaiser
4 http://spirit.sourceforge.net/
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_DEBUG_MAIN_HPP)
11 #define BOOST_SPIRIT_DEBUG_MAIN_HPP
13 ///////////////////////////////////////////////////////////////////////////
14 #if defined(BOOST_SPIRIT_DEBUG)
16 #include <boost/spirit/version.hpp>
18 ///////////////////////////////////////////////////////////////////////////////
20 // Spirit.Debug includes and defines
22 ///////////////////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////////////
28 // The BOOST_SPIRIT_DEBUG_OUT defines the stream object, which should be used
29 // for debug diagnostics. This defaults to std::cout.
31 ///////////////////////////////////////////////////////////////////////////
32 #if !defined(BOOST_SPIRIT_DEBUG_OUT)
33 #define BOOST_SPIRIT_DEBUG_OUT std::cout
36 ///////////////////////////////////////////////////////////////////////////
38 // The BOOST_SPIRIT_DEBUG_PRINT_SOME constant defines the number of characters
39 // from the stream to be printed for diagnosis. This defaults to the first
42 ///////////////////////////////////////////////////////////////////////////
43 #if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME)
44 #define BOOST_SPIRIT_DEBUG_PRINT_SOME 20
47 ///////////////////////////////////////////////////////////////////////////
49 // Additional BOOST_SPIRIT_DEBUG_FLAGS control the level of diagnostics printed
50 // Basic constants are defined in debug/minimal.hpp.
52 ///////////////////////////////////////////////////////////////////////////
53 #define BOOST_SPIRIT_DEBUG_FLAGS_NODES 0x0001 // node diagnostics
54 #define BOOST_SPIRIT_DEBUG_FLAGS_ESCAPE_CHAR 0x0002 // escape_char_parse diagnostics
55 #define BOOST_SPIRIT_DEBUG_FLAGS_TREES 0x0004 // parse tree/ast diagnostics
56 #define BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES 0x0008 // closure diagnostics
57 #define BOOST_SPIRIT_DEBUG_FLAGS_SLEX 0x8000 // slex diagnostics
59 #define BOOST_SPIRIT_DEBUG_FLAGS_MAX 0xFFFF // print maximal diagnostics
61 #if !defined(BOOST_SPIRIT_DEBUG_FLAGS)
62 #define BOOST_SPIRIT_DEBUG_FLAGS BOOST_SPIRIT_DEBUG_FLAGS_MAX
65 ///////////////////////////////////////////////////////////////////////////
67 // By default all nodes are traced (even those, not registered with
68 // BOOST_SPIRIT_DEBUG_RULE et.al. - see below). The following constant may be
69 // used to redefine this default.
71 ///////////////////////////////////////////////////////////////////////////
72 #if !defined(BOOST_SPIRIT_DEBUG_TRACENODE)
73 #define BOOST_SPIRIT_DEBUG_TRACENODE (true)
74 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACENODE)
76 ///////////////////////////////////////////////////////////////////////////
78 // Helper macros for giving rules and subrules a name accessible through
79 // parser_name() functions (see parser_names.hpp).
81 // Additionally, the macros BOOST_SPIRIT_DEBUG_RULE, SPIRIT_DEBUG_NODE and
82 // BOOST_SPIRIT_DEBUG_GRAMMAR enable/disable the tracing of the
83 // correspondingnode accordingly to the PP constant
84 // BOOST_SPIRIT_DEBUG_TRACENODE.
86 // The macros BOOST_SPIRIT_DEBUG_TRACE_RULE, BOOST_SPIRIT_DEBUG_TRACE_NODE
87 // and BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR allow to specify a flag to define,
88 // whether the corresponding node is to be traced or not.
90 ///////////////////////////////////////////////////////////////////////////
91 #if !defined(BOOST_SPIRIT_DEBUG_RULE)
92 #define BOOST_SPIRIT_DEBUG_RULE(r) \
93 ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE)
94 #endif // !defined(BOOST_SPIRIT_DEBUG_RULE)
96 #if !defined(BOOST_SPIRIT_DEBUG_NODE)
97 #define BOOST_SPIRIT_DEBUG_NODE(r) \
98 ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE)
99 #endif // !defined(BOOST_SPIRIT_DEBUG_NODE)
101 #if !defined(BOOST_SPIRIT_DEBUG_GRAMMAR)
102 #define BOOST_SPIRIT_DEBUG_GRAMMAR(r) \
103 ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE)
104 #endif // !defined(BOOST_SPIRIT_DEBUG_GRAMMAR)
106 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE)
107 #define BOOST_SPIRIT_DEBUG_TRACE_RULE(r, t) \
108 ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t))
109 #endif // !defined(BOOST_SPIRIT_TRACE_RULE)
111 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE)
112 #define BOOST_SPIRIT_DEBUG_TRACE_NODE(r, t) \
113 ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t))
114 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE)
116 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR)
117 #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR(r, t) \
118 ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t))
119 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR)
121 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME)
122 #define BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(r, n, t) \
123 ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t))
124 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME)
126 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME)
127 #define BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME(r, n, t) \
128 ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t))
129 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME)
131 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME)
132 #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(r, n, t) \
133 ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t))
134 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME)
136 //////////////////////////////////
137 #include <boost/spirit/debug/debug_node.hpp>
140 //////////////////////////////////
141 #include <boost/spirit/debug/minimal.hpp>
143 #endif // BOOST_SPIRIT_DEBUG