1 /*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
3 Copyright (c) 2002-2003 Hartmut Kaiser
4 http://spirit.sourceforge.net/
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(BOOST_SPIRIT_DEBUG_MAIN_HPP)
10 #define BOOST_SPIRIT_DEBUG_MAIN_HPP
12 ///////////////////////////////////////////////////////////////////////////
13 #if defined(BOOST_SPIRIT_DEBUG)
15 #include <boost/spirit/home/classic/version.hpp>
17 ///////////////////////////////////////////////////////////////////////////////
19 // Spirit.Debug includes and defines
21 ///////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////
27 // The BOOST_SPIRIT_DEBUG_OUT defines the stream object, which should be used
28 // for debug diagnostics. This defaults to std::cout.
30 ///////////////////////////////////////////////////////////////////////////
31 #if !defined(BOOST_SPIRIT_DEBUG_OUT)
32 #define BOOST_SPIRIT_DEBUG_OUT std::cout
35 ///////////////////////////////////////////////////////////////////////////
37 // The BOOST_SPIRIT_DEBUG_PRINT_SOME constant defines the number of characters
38 // from the stream to be printed for diagnosis. This defaults to the first
41 ///////////////////////////////////////////////////////////////////////////
42 #if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME)
43 #define BOOST_SPIRIT_DEBUG_PRINT_SOME 20
46 ///////////////////////////////////////////////////////////////////////////
48 // Additional BOOST_SPIRIT_DEBUG_FLAGS control the level of diagnostics printed
49 // Basic constants are defined in debug/minimal.hpp.
51 ///////////////////////////////////////////////////////////////////////////
52 #define BOOST_SPIRIT_DEBUG_FLAGS_NODES 0x0001 // node diagnostics
53 #define BOOST_SPIRIT_DEBUG_FLAGS_ESCAPE_CHAR 0x0002 // escape_char_parse diagnostics
54 #define BOOST_SPIRIT_DEBUG_FLAGS_TREES 0x0004 // parse tree/ast diagnostics
55 #define BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES 0x0008 // closure diagnostics
56 #define BOOST_SPIRIT_DEBUG_FLAGS_SLEX 0x8000 // slex diagnostics
58 #define BOOST_SPIRIT_DEBUG_FLAGS_MAX 0xFFFF // print maximal diagnostics
60 #if !defined(BOOST_SPIRIT_DEBUG_FLAGS)
61 #define BOOST_SPIRIT_DEBUG_FLAGS BOOST_SPIRIT_DEBUG_FLAGS_MAX
64 ///////////////////////////////////////////////////////////////////////////
66 // By default all nodes are traced (even those, not registered with
67 // BOOST_SPIRIT_DEBUG_RULE et.al. - see below). The following constant may be
68 // used to redefine this default.
70 ///////////////////////////////////////////////////////////////////////////
71 #if !defined(BOOST_SPIRIT_DEBUG_TRACENODE)
72 #define BOOST_SPIRIT_DEBUG_TRACENODE (true)
73 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACENODE)
75 ///////////////////////////////////////////////////////////////////////////
77 // Helper macros for giving rules and subrules a name accessible through
78 // parser_name() functions (see parser_names.hpp).
80 // Additionally, the macros BOOST_SPIRIT_DEBUG_RULE, SPIRIT_DEBUG_NODE and
81 // BOOST_SPIRIT_DEBUG_GRAMMAR enable/disable the tracing of the
82 // correspondingnode accordingly to the PP constant
83 // BOOST_SPIRIT_DEBUG_TRACENODE.
85 // The macros BOOST_SPIRIT_DEBUG_TRACE_RULE, BOOST_SPIRIT_DEBUG_TRACE_NODE
86 // and BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR allow to specify a flag to define,
87 // whether the corresponding node is to be traced or not.
89 ///////////////////////////////////////////////////////////////////////////
90 #if !defined(BOOST_SPIRIT_DEBUG_RULE)
91 #define BOOST_SPIRIT_DEBUG_RULE(r) \
92 ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \
93 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_CLASSIC_NS::impl::get_node_registry(). \
99 register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE)
100 #endif // !defined(BOOST_SPIRIT_DEBUG_NODE)
102 #if !defined(BOOST_SPIRIT_DEBUG_GRAMMAR)
103 #define BOOST_SPIRIT_DEBUG_GRAMMAR(r) \
104 ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \
105 register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE)
106 #endif // !defined(BOOST_SPIRIT_DEBUG_GRAMMAR)
108 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE)
109 #define BOOST_SPIRIT_DEBUG_TRACE_RULE(r, t) \
110 ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \
111 register_node(&r, #r, (t))
112 #endif // !defined(BOOST_SPIRIT_TRACE_RULE)
114 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE)
115 #define BOOST_SPIRIT_DEBUG_TRACE_NODE(r, t) \
116 ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \
117 register_node(&r, #r, (t))
118 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE)
120 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR)
121 #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR(r, t) \
122 ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \
123 register_node(&r, #r, (t))
124 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR)
126 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME)
127 #define BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(r, n, t) \
128 ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \
129 register_node(&r, (n), (t))
130 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME)
132 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME)
133 #define BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME(r, n, t) \
134 ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \
135 register_node(&r, (n), (t))
136 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME)
138 #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME)
139 #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(r, n, t) \
140 ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \
141 register_node(&r, (n), (t))
142 #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME)
144 //////////////////////////////////
145 #include <boost/spirit/home/classic/debug/debug_node.hpp>
148 //////////////////////////////////
149 #include <boost/spirit/home/classic/debug/minimal.hpp>
151 #endif // BOOST_SPIRIT_DEBUG