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