tree.c (build_tree_list): Fix parameter names in comment.
[official-gcc.git] / gcc / c-pretty-print.h
blob3bdd6fec4a745fdc7ec17ac71d9c1946bf44f6cf
1 /* Various declarations for the C and C++ pretty-printers.
2 Copyright (C) 2002 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
22 #ifndef GCC_C_PRETTY_PRINTER
23 #define GCC_C_PRETTY_PRINTER
25 #include "tree.h"
26 #include "c-common.h"
27 #include "pretty-print.h"
30 /* The data type used to bundle information necessary for pretty-printing
31 a C or C++ entity. */
32 typedef struct c_pretty_print_info *c_pretty_printer;
34 /* The type of a C pretty-printer 'member' function. */
35 typedef void (*c_pretty_print_fn) PARAMS ((c_pretty_printer, tree));
37 struct c_pretty_print_info
39 struct pretty_print_info base;
40 /* Points to the first element of an array of offset-list.
41 Not used yet. */
42 int *offset_list;
44 /* These must be overridden by each of the C and C++ front-end to
45 reflect their understanding of syntactic productions when they differ. */
46 c_pretty_print_fn declaration;
47 c_pretty_print_fn declaration_specifiers;
48 c_pretty_print_fn type_specifier;
49 c_pretty_print_fn declarator;
50 c_pretty_print_fn direct_declarator;
51 c_pretty_print_fn parameter_declaration;
52 c_pretty_print_fn type_id;
54 c_pretty_print_fn statement;
56 c_pretty_print_fn primary_expression;
57 c_pretty_print_fn postfix_expression;
58 c_pretty_print_fn unary_expression;
59 c_pretty_print_fn initializer;
60 c_pretty_print_fn multiplicative_expression;
61 c_pretty_print_fn conditional_expression;
62 c_pretty_print_fn assignment_expression;
65 #define pp_c_left_paren(PPI) \
66 do { \
67 pp_left_paren (PPI); \
68 pp_c_base (PPI)->base.padding = pp_none; \
69 } while (0)
70 #define pp_c_right_paren(PPI) \
71 do { \
72 pp_right_paren (PPI); \
73 pp_c_base (PPI)->base.padding = pp_none; \
74 } while (0)
75 #define pp_c_left_bracket(PPI) \
76 do { \
77 pp_left_bracket (PPI); \
78 pp_c_base (PPI)->base.padding = pp_none; \
79 } while (0)
80 #define pp_c_right_bracket(PPI) \
81 do { \
82 pp_right_bracket (PPI); \
83 pp_c_base (PPI)->base.padding = pp_none; \
84 } while (0)
85 #define pp_c_whitespace(PPI) \
86 do { \
87 pp_whitespace (PPI); \
88 pp_c_base (PPI)->base.padding = pp_none; \
89 } while (0)
90 #define pp_c_maybe_whitespace(PPI) \
91 do { \
92 if (pp_c_base (PPI)->base.padding != pp_none) \
93 pp_c_whitespace (PPI); \
94 } while (0)
95 #define pp_c_identifier(PPI, ID) \
96 do { \
97 pp_c_maybe_whitespace (PPI); \
98 pp_identifier (PPI, ID); \
99 pp_c_base (PPI)->base.padding = pp_before; \
100 } while (0)
102 #define pp_c_tree_identifier(PPI, ID) \
103 pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
105 /* Returns the 'output_buffer *' associated with a PRETTY-PRINTER, the latter
106 being something digestible by pp_c_base. */
107 #define pp_buffer(PPI) pp_c_base (PPI)->base.buffer
109 #define pp_declaration(PPI, T) \
110 (*pp_c_base (PPI)->declaration) (pp_c_base (PPI), T)
111 #define pp_declaration_specifiers(PPI, D) \
112 (*pp_c_base (PPI)->declaration_specifiers) (pp_c_base (PPI), D)
113 #define pp_type_specifier(PPI, D) \
114 (*pp_c_base (PPI)->type_specifier) (pp_c_base (PPI), D)
115 #define pp_declarator(PPI, D) \
116 (*pp_c_base (PPI)->declarator) (pp_c_base (PPI), D)
117 #define pp_direct_declarator(PPI, D) \
118 (*pp_c_base (PPI)->direct_declarator) (pp_c_base (PPI), D)
119 #define pp_parameter_declaration(PPI, T) \
120 (*pp_c_base (PPI)->parameter_declaration) (pp_c_base (PPI), T)
121 #define pp_type_id(PPI, D) \
122 (*pp_c_base (PPI)->type_id) (pp_c_base (PPI), D)
124 #define pp_statement(PPI, S) \
125 (*pp_c_base (PPI)->statement) (pp_c_base (PPI), S)
127 #define pp_primary_expression(PPI, E) \
128 (*pp_c_base (PPI)->primary_expression) (pp_c_base (PPI), E)
129 #define pp_postfix_expression(PPI, E) \
130 (*pp_c_base (PPI)->postfix_expression) (pp_c_base (PPI), E)
131 #define pp_unary_expression(PPI, E) \
132 (*pp_c_base (PPI)->unary_expression) (pp_c_base (PPI), E)
133 #define pp_initializer(PPI, E) \
134 (*pp_c_base (PPI)->initializer) (pp_c_base (PPI), E)
135 #define pp_multiplicative_expression(PPI, E) \
136 (*pp_c_base (PPI)->multiplicative_expression) (pp_c_base (PPI), E)
137 #define pp_conditional_expression(PPI, E) \
138 (*pp_c_base (PPI)->conditional_expression) (pp_c_base (PPI), E)
139 #define pp_assignment_expression(PPI, E) \
140 (*pp_c_base (PPI)->assignment_expression) (pp_c_base (PPI), E)
143 /* Returns the c_pretty_printer base object of PRETTY-PRINTER. This
144 macro must be overridden by any subclass of c_pretty_print_info. */
145 #define pp_c_base(PP) (PP)
147 extern void pp_c_pretty_printer_init PARAMS ((c_pretty_printer));
149 /* Declarations. */
150 void pp_c_attributes PARAMS ((c_pretty_printer, tree));
151 void pp_c_cv_qualifier PARAMS ((c_pretty_printer, int));
152 void pp_c_parameter_declaration_clause PARAMS ((c_pretty_printer, tree));
153 void pp_c_declaration PARAMS ((c_pretty_printer, tree));
154 /* Statements. */
155 void pp_c_statement PARAMS ((c_pretty_printer, tree));
156 /* Expressions. */
157 void pp_c_expression PARAMS ((c_pretty_printer, tree));
158 void pp_c_logical_or_expression PARAMS ((c_pretty_printer, tree));
159 void pp_c_expression_list PARAMS ((c_pretty_printer, tree));
160 void pp_c_cast_expression PARAMS ((c_pretty_printer, tree));
161 void pp_c_postfix_expression PARAMS ((c_pretty_printer, tree));
162 void pp_c_initializer PARAMS ((c_pretty_printer, tree));
163 void pp_c_literal PARAMS ((c_pretty_printer, tree));
165 #endif /* GCC_C_PRETTY_PRINTER */