pretty-print.h revision 117395
1/* Various declarations for language-independent pretty-print subroutines.
2   Copyright (C) 2002 Free Software Foundation, Inc.
3   Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 2, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING.  If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA.  */
21
22#ifndef GCC_PRETTY_PRINT_H
23#define GCC_PRETTY_PRINT_H
24
25#include "diagnostic.h"
26
27/* The type of pretty-printer flags passed to clients.  */
28typedef unsigned int pp_flags;
29
30typedef enum
31{
32  pp_none, pp_before, pp_after
33} pp_padding;
34
35struct pretty_print_info
36{
37  /* Where we print external representation of ENTITY.  */
38  output_buffer *buffer;
39  pp_flags flags;
40  /* Where to put whitespace around the entity being formatted.  */
41  pp_padding padding;
42};
43
44#define pp_left_paren(PPI)      output_add_character (pp_buffer (PPI), '(')
45#define pp_right_paren(PPI)     output_add_character (pp_buffer (PPI), ')')
46#define pp_left_bracket(PPI)    output_add_character (pp_buffer (PPI), '[')
47#define pp_right_bracket(PPI)   output_add_character (pp_buffer (PPI), ']')
48#define pp_left_brace(PPI)      output_add_character (pp_buffer (PPI), '{')
49#define pp_right_brace(PPI)     output_add_character (pp_buffer (PPI), '}')
50#define pp_semicolon(PPI)       output_add_character (pp_buffer (PPI), ';')
51#define pp_comma(PPI)           output_add_string (pp_buffer (PPI), ", ")
52#define pp_dot(PPI)             output_add_character (pp_buffer (PPI), '.')
53#define pp_colon(PPI)           output_add_character (pp_buffer (PPI), ':')
54#define pp_colon_colon(PPI)     output_add_string (pp_buffer (PPI), "::")
55#define pp_arrow(PPI)           output_add_string (pp_buffer (PPI), "->")
56#define pp_equal(PPI)           output_add_character (pp_buffer (PPI), '=')
57#define pp_question(PPI)        output_add_character (pp_buffer (PPI), '?')
58#define pp_bar(PPI)             output_add_character (pp_buffer (PPI), '|')
59#define pp_carret(PPI)          output_add_character (pp_buffer (PPI), '^')
60#define pp_ampersand(PPI)       output_add_character (pp_buffer (PPI), '&')
61#define pp_less(PPI)            output_add_character (pp_buffer (PPI), '<')
62#define pp_greater(PPI)         output_add_character (pp_buffer (PPI), '>')
63#define pp_plus(PPI)            output_add_character (pp_buffer (PPI), '+')
64#define pp_minus(PPI)           output_add_character (pp_buffer (PPI), '-')
65#define pp_star(PPI)            output_add_character (pp_buffer (PPI), '*')
66#define pp_slash(PPI)           output_add_character (pp_buffer (PPI), '/')
67#define pp_modulo(PPI)          output_add_character (pp_buffer (PPI), '%')
68#define pp_exclamation(PPI)     output_add_character (pp_buffer (PPI), '!')
69#define pp_complement(PPI)      output_add_character (pp_buffer (PPI), '~')
70#define pp_quote(PPI)           output_add_character (pp_buffer (PPI), '\'')
71#define pp_backquote(PPI)       output_add_character (pp_buffer (PPI), '`')
72#define pp_doublequote(PPI)     output_add_character (pp_buffer (PPI), '"')
73#define pp_newline(PPI)         output_add_newline (pp_buffer (PPI))
74#define pp_character(PPI, C)    output_add_character (pp_buffer (PPI), C)
75#define pp_whitespace(PPI)      output_add_space (pp_buffer (PPI))
76#define pp_indentation(PPI)     output_indentation (pp_buffer (PPI))
77#define pp_newline_and_indent(PPI, N) \
78  do {                                \
79    pp_indentation (PPI) += N;        \
80    pp_newline (PPI);                 \
81  } while (0)
82#define pp_separate_with(PPI, C) \
83   do {                          \
84     pp_character (PPI, C);      \
85     pp_whitespace (PPI);        \
86   } while (0)
87#define pp_format_scalar(PPI, F, S) \
88   output_formatted_scalar (pp_buffer (PPI), F, S)
89#define pp_wide_integer(PPI, I) \
90   pp_format_scalar (PPI, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) I)
91#define pp_pointer(PPI, P) pp_format_scalar (PPI, "%p", p)
92
93#define pp_identifier(PPI, ID)  output_add_string (pp_buffer (PPI), ID)
94#define pp_tree_identifier(PPI, T) pp_identifier(PPI, IDENTIFIER_POINTER (T))
95
96#define pp_unsupported_tree(PPI, T) \
97  output_verbatim (pp_buffer(PPI), "#`%s' not supported by %s#",\
98                   tree_code_name[(int) TREE_CODE (T)], __FUNCTION__)
99
100#endif /* GCC_PRETTY_PRINT_H */
101