• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2003 Joel de Guzman
3     Copyright (c) 2002-2003 Hartmut Kaiser
4     http://spirit.sourceforge.net/
5 
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
11 
12 ///////////////////////////////////////////////////////////////////////////
13 #if defined(BOOST_SPIRIT_DEBUG)
14 
15 #include <boost/spirit/home/classic/version.hpp>
16 
17 ///////////////////////////////////////////////////////////////////////////////
18 //
19 //  Spirit.Debug includes and defines
20 //
21 ///////////////////////////////////////////////////////////////////////////////
22 
23     #include <iostream>
24 
25     ///////////////////////////////////////////////////////////////////////////
26     //
27     //  The BOOST_SPIRIT_DEBUG_OUT defines the stream object, which should be used
28     //  for debug diagnostics. This defaults to std::cout.
29     //
30     ///////////////////////////////////////////////////////////////////////////
31     #if !defined(BOOST_SPIRIT_DEBUG_OUT)
32     #define BOOST_SPIRIT_DEBUG_OUT std::cout
33     #endif
34 
35     ///////////////////////////////////////////////////////////////////////////
36     //
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
39     //  20 characters.
40     //
41     ///////////////////////////////////////////////////////////////////////////
42     #if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME)
43     #define BOOST_SPIRIT_DEBUG_PRINT_SOME 20
44     #endif
45 
46     ///////////////////////////////////////////////////////////////////////////
47     //
48     //  Additional BOOST_SPIRIT_DEBUG_FLAGS control the level of diagnostics printed
49     //  Basic constants are defined in debug/minimal.hpp.
50     //
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
57 
58     #define BOOST_SPIRIT_DEBUG_FLAGS_MAX          0xFFFF  // print maximal diagnostics
59 
60     #if !defined(BOOST_SPIRIT_DEBUG_FLAGS)
61     #define BOOST_SPIRIT_DEBUG_FLAGS BOOST_SPIRIT_DEBUG_FLAGS_MAX
62     #endif
63 
64     ///////////////////////////////////////////////////////////////////////////
65     //
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.
69     //
70     ///////////////////////////////////////////////////////////////////////////
71     #if !defined(BOOST_SPIRIT_DEBUG_TRACENODE)
72     #define BOOST_SPIRIT_DEBUG_TRACENODE          (true)
73     #endif // !defined(BOOST_SPIRIT_DEBUG_TRACENODE)
74 
75     ///////////////////////////////////////////////////////////////////////////
76     //
77     //  Helper macros for giving rules and subrules a name accessible through
78     //  parser_name() functions (see parser_names.hpp).
79     //
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.
84     //
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.
88     //
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)
95 
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)
101 
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)
107 
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)
113 
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)
119 
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)
125 
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)
131 
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)
137 
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)
143 
144     //////////////////////////////////
145     #include <boost/spirit/home/classic/debug/debug_node.hpp>
146 
147 #else
148     //////////////////////////////////
149     #include <boost/spirit/home/classic/debug/minimal.hpp>
150 
151 #endif // BOOST_SPIRIT_DEBUG
152 
153 #endif
154 
155