3 * Debugging facilities for parser. */
6 * GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef GINAC_PARSER_DEBUG_H
24 #define GINAC_PARSER_DEBUG_H
33 #if __STDC_VERSION__ < 199901L
34 #define __PRETTY_FUNCTION__ "<unknown>"
36 #define __PRETTY_FUNCTION__ __func__
40 #define bail_out(exception, message) \
42 std::ostringstream err; \
43 err << __PRETTY_FUNCTION__ << "(" << __FILE__ << ':' << __LINE__ << ": "; \
45 throw exception(err.str()); \
48 #define Parse_error_(message) \
50 std::ostringstream err; \
51 err << "GiNaC: parse error at line " << scanner->line_num << \
52 ", column " << scanner->column << ": "; \
53 err << message << std::endl; \
54 err << '[' << __PRETTY_FUNCTION__ << "(" << __FILE__ << ':' << __LINE__ << ")]" << std::endl; \
55 throw parse_error(err.str(), scanner->line_num, scanner->column); \
58 #define Parse_error(message) \
59 Parse_error_(message << ", got: " << scanner->tok2str(token))
61 #define bug(message) bail_out(std::logic_error, message)
63 #define dout(condition, message) \
65 if (unlikely(condition)) { \
66 std::cerr << __PRETTY_FUNCTION__ \
67 << " (" << __FILE__ << ':' << __LINE__ << "): " \
68 << message << std::endl; \
72 #endif // GINAC_PARSER_DEBUG_H