os/ossrv/ossrv_pub/boost_apis/boost/spirit/debug.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*=============================================================================
sl@0
     2
    Copyright (c) 2001-2003 Joel de Guzman
sl@0
     3
    Copyright (c) 2002-2003 Hartmut Kaiser
sl@0
     4
    http://spirit.sourceforge.net/
sl@0
     5
sl@0
     6
    Use, modification and distribution is subject to the Boost Software
sl@0
     7
    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
sl@0
     8
    http://www.boost.org/LICENSE_1_0.txt)
sl@0
     9
=============================================================================*/
sl@0
    10
#if !defined(BOOST_SPIRIT_DEBUG_MAIN_HPP)
sl@0
    11
#define BOOST_SPIRIT_DEBUG_MAIN_HPP
sl@0
    12
sl@0
    13
///////////////////////////////////////////////////////////////////////////
sl@0
    14
#if defined(BOOST_SPIRIT_DEBUG)
sl@0
    15
sl@0
    16
#include <boost/spirit/version.hpp>
sl@0
    17
sl@0
    18
///////////////////////////////////////////////////////////////////////////////
sl@0
    19
//
sl@0
    20
//  Spirit.Debug includes and defines
sl@0
    21
//
sl@0
    22
///////////////////////////////////////////////////////////////////////////////
sl@0
    23
sl@0
    24
    #include <iostream>
sl@0
    25
sl@0
    26
    ///////////////////////////////////////////////////////////////////////////
sl@0
    27
    //
sl@0
    28
    //  The BOOST_SPIRIT_DEBUG_OUT defines the stream object, which should be used
sl@0
    29
    //  for debug diagnostics. This defaults to std::cout.
sl@0
    30
    //
sl@0
    31
    ///////////////////////////////////////////////////////////////////////////
sl@0
    32
    #if !defined(BOOST_SPIRIT_DEBUG_OUT)
sl@0
    33
    #define BOOST_SPIRIT_DEBUG_OUT std::cout
sl@0
    34
    #endif
sl@0
    35
sl@0
    36
    ///////////////////////////////////////////////////////////////////////////
sl@0
    37
    //
sl@0
    38
    //  The BOOST_SPIRIT_DEBUG_PRINT_SOME constant defines the number of characters
sl@0
    39
    //  from the stream to be printed for diagnosis. This defaults to the first
sl@0
    40
    //  20 characters.
sl@0
    41
    //
sl@0
    42
    ///////////////////////////////////////////////////////////////////////////
sl@0
    43
    #if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME)
sl@0
    44
    #define BOOST_SPIRIT_DEBUG_PRINT_SOME 20
sl@0
    45
    #endif
sl@0
    46
sl@0
    47
    ///////////////////////////////////////////////////////////////////////////
sl@0
    48
    //
sl@0
    49
    //  Additional BOOST_SPIRIT_DEBUG_FLAGS control the level of diagnostics printed
sl@0
    50
    //  Basic constants are defined in debug/minimal.hpp.
sl@0
    51
    //
sl@0
    52
    ///////////////////////////////////////////////////////////////////////////
sl@0
    53
    #define BOOST_SPIRIT_DEBUG_FLAGS_NODES        0x0001  // node diagnostics
sl@0
    54
    #define BOOST_SPIRIT_DEBUG_FLAGS_ESCAPE_CHAR  0x0002  // escape_char_parse diagnostics
sl@0
    55
    #define BOOST_SPIRIT_DEBUG_FLAGS_TREES        0x0004  // parse tree/ast diagnostics
sl@0
    56
    #define BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES     0x0008  // closure diagnostics
sl@0
    57
    #define BOOST_SPIRIT_DEBUG_FLAGS_SLEX         0x8000  // slex diagnostics
sl@0
    58
sl@0
    59
    #define BOOST_SPIRIT_DEBUG_FLAGS_MAX          0xFFFF  // print maximal diagnostics
sl@0
    60
sl@0
    61
    #if !defined(BOOST_SPIRIT_DEBUG_FLAGS)
sl@0
    62
    #define BOOST_SPIRIT_DEBUG_FLAGS BOOST_SPIRIT_DEBUG_FLAGS_MAX
sl@0
    63
    #endif
sl@0
    64
sl@0
    65
    ///////////////////////////////////////////////////////////////////////////
sl@0
    66
    //
sl@0
    67
    //  By default all nodes are traced (even those, not registered with
sl@0
    68
    //  BOOST_SPIRIT_DEBUG_RULE et.al. - see below). The following constant may be
sl@0
    69
    //  used to redefine this default.
sl@0
    70
    //
sl@0
    71
    ///////////////////////////////////////////////////////////////////////////
sl@0
    72
    #if !defined(BOOST_SPIRIT_DEBUG_TRACENODE)
sl@0
    73
    #define BOOST_SPIRIT_DEBUG_TRACENODE          (true)
sl@0
    74
    #endif // !defined(BOOST_SPIRIT_DEBUG_TRACENODE)
sl@0
    75
sl@0
    76
    ///////////////////////////////////////////////////////////////////////////
sl@0
    77
    //
sl@0
    78
    //  Helper macros for giving rules and subrules a name accessible through
sl@0
    79
    //  parser_name() functions (see parser_names.hpp).
sl@0
    80
    //
sl@0
    81
    //  Additionally, the macros BOOST_SPIRIT_DEBUG_RULE, SPIRIT_DEBUG_NODE and
sl@0
    82
    //  BOOST_SPIRIT_DEBUG_GRAMMAR enable/disable the tracing of the 
sl@0
    83
    //  correspondingnode accordingly to the PP constant 
sl@0
    84
    //  BOOST_SPIRIT_DEBUG_TRACENODE.
sl@0
    85
    //
sl@0
    86
    //  The macros BOOST_SPIRIT_DEBUG_TRACE_RULE, BOOST_SPIRIT_DEBUG_TRACE_NODE 
sl@0
    87
    //  and BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR allow to specify a flag to define, 
sl@0
    88
    //  whether the corresponding node is to be traced or not.
sl@0
    89
    //
sl@0
    90
    ///////////////////////////////////////////////////////////////////////////
sl@0
    91
    #if !defined(BOOST_SPIRIT_DEBUG_RULE)
sl@0
    92
    #define BOOST_SPIRIT_DEBUG_RULE(r)    \
sl@0
    93
        ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE)
sl@0
    94
    #endif // !defined(BOOST_SPIRIT_DEBUG_RULE)
sl@0
    95
sl@0
    96
    #if !defined(BOOST_SPIRIT_DEBUG_NODE)
sl@0
    97
    #define BOOST_SPIRIT_DEBUG_NODE(r)    \
sl@0
    98
        ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE)
sl@0
    99
    #endif // !defined(BOOST_SPIRIT_DEBUG_NODE)
sl@0
   100
sl@0
   101
    #if !defined(BOOST_SPIRIT_DEBUG_GRAMMAR)
sl@0
   102
    #define BOOST_SPIRIT_DEBUG_GRAMMAR(r)    \
sl@0
   103
        ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE)
sl@0
   104
    #endif // !defined(BOOST_SPIRIT_DEBUG_GRAMMAR)
sl@0
   105
sl@0
   106
    #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE)
sl@0
   107
    #define BOOST_SPIRIT_DEBUG_TRACE_RULE(r, t)    \
sl@0
   108
        ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t))
sl@0
   109
    #endif // !defined(BOOST_SPIRIT_TRACE_RULE)
sl@0
   110
sl@0
   111
    #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE)
sl@0
   112
    #define BOOST_SPIRIT_DEBUG_TRACE_NODE(r, t)    \
sl@0
   113
        ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t))
sl@0
   114
    #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE)
sl@0
   115
sl@0
   116
    #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR)
sl@0
   117
    #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR(r, t)    \
sl@0
   118
        ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t))
sl@0
   119
    #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR)
sl@0
   120
sl@0
   121
    #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME)
sl@0
   122
    #define BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(r, n, t)    \
sl@0
   123
        ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t))
sl@0
   124
    #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME)
sl@0
   125
sl@0
   126
    #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME)
sl@0
   127
    #define BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME(r, n, t)    \
sl@0
   128
        ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t))
sl@0
   129
    #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME)
sl@0
   130
sl@0
   131
    #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME)
sl@0
   132
    #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(r, n, t)    \
sl@0
   133
        ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t))
sl@0
   134
    #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME)
sl@0
   135
sl@0
   136
    //////////////////////////////////
sl@0
   137
    #include <boost/spirit/debug/debug_node.hpp>
sl@0
   138
sl@0
   139
#else
sl@0
   140
    //////////////////////////////////
sl@0
   141
    #include <boost/spirit/debug/minimal.hpp>
sl@0
   142
sl@0
   143
#endif // BOOST_SPIRIT_DEBUG
sl@0
   144
sl@0
   145
#endif
sl@0
   146